tags:

views:

45

answers:

1

Can the Xpath of XSD schema text() elements be retrieved in vb.net? For example, how can you get this Xpath from the following schema;

parent/child/grandchild

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified"
           elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    <xs:element name="parent">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="child">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="grandchild"
                                        type="xs:string" />
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
A: 

My essential goal is to determine (in code) the xpath between any two nodes. For example, if the parent had a child2 node, I could obtain the child2 node of grandchild as ancestor::parent/child2

My thought was that if I have the full xpath to both nodes, I could determine the relative path (ancestor, descendant) between the nodes. I would store the full xpath of every text node in the database (a better approach would be appreciated).

My question was 'can i generate the full paths from the xsd schema?'

Alejandro, I thought of doing this from an instance document using //text() and that works.

LarsH, I believe there would only be one path between the grandchild node and the child2 node.

Thanks for your responses.

Stephen