私はXML検証の最終版のためのスキーマを作成しています。しかし、今私はXMLでもっとも奇妙なエラーが発生しています。スキーマを表示することから始めます。なぜなら、問題がどこにあるべきなのか、それではエラーが出ないからです。今 名前空間 "xSchema"の要素 "x"の名前空間 "xSchema"に無効な子要素 "y"があります。期待される要素のリスト: "y"
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:os="OrdersSchema"
targetNamespace="OrdersSchema"
elementFormDefault="unqualified"
attributeFormDefault="qualified">
<element name="orders" type="os:orders"/>
<complexType name="orders">
<sequence>
<element name="order" type="os:order" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="order">
<sequence>
<element name="deliveryAddress">
<complexType>
<sequence>
<element name='line1' type='os:lineType'/>
<element name='line2' type='os:lineType'/>
<element name='line3' type='os:lineType'/>
<element name='line4' type='os:lineType' minOccurs='0'/>
</sequence>
<attribute name="orderId" type="string" use="required" >
</attribute>
<attribute name="type" type="os:typeType" use="required"/>
</complexType>
<unique name="uniqueOrderIdPerOrder">
<selector xpath="os:order"/>
<field xpath="orderId"/>
</unique>
</element>
<element name='items'>
<complexType>
<attribute name='productId' type='os:productIdType'/>
<attribute name='quantity'>
<simpleType>
<restriction base='positiveInteger'>
</restriction>
</simpleType>
</attribute>
</complexType>
</element>
<element name='note' minOccurs='0' type='string'/>
</sequence>
</complexType>
<simpleType name='lineType'>
<restriction base='string'>
<minLength value='1'/>
</restriction>
</simpleType>
<simpleType name='typeType'>
<restriction base='string'>
<enumeration value='standard'/>
<enumeration value='express'/>
</restriction>
</simpleType>
<simpleType name='productIdType'>
<restriction base='string'>
<pattern value='(?i)p[-\s](150|1[0-4][0-9]|[[1-9][0-9]|[1-9])\.[a-z][a-z][a-z][a-z][a-z][a-z]'/>
<pattern value='A...+[$XYZ]\b'/>
</restriction>
</simpleType>
</schema>
は、私のスキーマはまったくエラーを与えていないが、私はそれに私のXMLファイルをリンクするとき、私はというエラーを取得:名前空間「OrdersSchema」内の要素の注文を 'に無効な子要素「注文」あり名前空間 'OrdersSchema'にあります。考えられる要素のリスト: 'order'。
ここで、検証する必要がありますコードだ誰もがそれを試してみたい場合:つまり
<?xml version="1.0" encoding="utf-8" ?>
<os:orders xmlns:os="OrdersSchema">
<os:order orderId="ord0001" type="standard">
<deliveryAddress>
<line1>5, Elmstreet</line1>
<line2>90210 Beverly Hills</line2>
<line3>California</line3>
</deliveryAddress>
<items>
<item productId="P 150.aabaac" quantity="5" />
</items>
<note>Deliver after 5 pm.</note>
</os:order>
<os:order orderId="ord0003" type="express">
<deliveryAddress>
<line1>Voskenslaan 30</line1>
<line2>BE9000 Gent</line2>
<line3>Oost-Vlaanderen</line3>
<line4>Belgium</line4>
</deliveryAddress>
<items>
<item productId="A3546sdfsdf6546sdf654Z" quantity="10" />
<item productId="p 149.SLKDOZ" quantity="5" />
<item productId="P 100.xcvZEr" quantity="15" />
</items>
</os:order>
<os:order orderId="ord0002" type="express">
<deliveryAddress>
<line1>Voskenslaan 32</line1>
<line2>BE9000 Gent</line2>
<line3>Oost-Vlaanderen</line3>
<line4>Belgium</line4>
</deliveryAddress>
<items>
<item productId="P-99.ruioze" quantity="15" />
<item productId="A123qze46548X" quantity="50" />
<item productId="P 1.sqmfze" quantity="1" />
<item productId="AoknY" quantity="20" />
</items>
<note>This is <b>very urgent</b> !</note>
</os:order>
</os:orders>
こんにちは@ user2843457、Voskenslaan 32、私はそれがどこにあるか知っています:-O – bvgheluwe