2

我现在正在努力自动生成通向某种类型的 XSD 模式的 XPath。

在此示例中,我想获取通向“firstName”和“lastName”的 XPath,这意味着:

root/Friend/firstName, root/Friend/lastName, root/TenthGrader/firstName, root/tenthGrader/lastName, root/complicatedPerson/oldSelf/firstName, root/complicatedPerson/oldSelf/lastName

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="root">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Friend" type="Student"/>
            <xs:element name="TenthGrader">
                <xs:complexType>
                    <xs:complexContent>
                        <xs:extension base="Student">
                            <xs:element name="Sexyteacher"/>
                        </xs:extension>
                    </xs:complexContent>
                </xs:complexType>
            </xs:element>
            <xs:element ref="complicatedPerson"/>
            <xs:element name="IdoNothing"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:element name="complicatedPerson" type="Person"/>

<xs:complexType name="Person">
    <xs:sequence>
        <xs:element name="oldSelf" type="Student"/>
        <xs:element name="Age" type="xs:int"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name="Student">
    <xs:sequence>
        <xs:element name="firstName"/>
        <xs:element name="lastName"/>
    </xs:sequence>
</xs:complexType>

</xs:schema>

这已经让我很头疼了。

有没有已知的方法可以做到这一点?

非常感谢您!

4

0 回答 0