[xsd-users] About using XPath Query

sun-rise sun.rise.ma at gmail.com
Fri Oct 2 07:06:16 EDT 2009


Hi,
I have questions about a XPath query on XSD.

1. I refers to the XPath example in the example/cxx/tree/xpath of XSD
distribution.
    The sample uses the DOMDocument object parsed from a XML file.
    I want to execute a XPath query for C++/Tree object model that
created from scratch.
    Can use an C++/Tree object model created from scratch be used instead of the
    DOMDocument parsed from a file?

    # Example code uses DOMImplementation object when prasing a XML file.
    # If I created C++/Tree object model from scratch (don't parse a
file), how should be
    # used DOMImplementation?

2. Can I add a new element to XPath result of C++/Tree object model?

Example
-------
<employee>
  <person id="001">
    <first-name>John</first-name>
    <first-name>Doe</first-name>
    <gender>male</gender>
    <age>32</age>
    <role>member</role>
  </person>

  <person id="002">
      ...
  </person>
</employee>
-------

Evalate a following XPath expression for C++/Tree object.
/employee/person[@id='001']

Then, add a new <role> element to /employee/person[@id='001'].

-------
<employee>
  <person id="001">
    <first-name>John</first-name>
    <first-name>Doe</first-name>
    <gender>male</gender>
    <age>32</age>
    <role>member</role>
    <role>admin</role>
  </person>

  <person id="002">
      ...
  </person>
</employee>
-------


Thanks.
--
Yu




More information about the xsd-users mailing list