次のポストは、要素が のルート要素のXMLスキーマであることを示すために、どのように求められます。XMLスキーマ:ルート要素
Is it possible to define a root element in an XML Document using Schema?
私はXMLスキーマにW3Schoolsのチュートリアルに従ってきたが、何かがまだあります定かでない。 例のスキーマ2をhttp://www.w3schools.com/schema/schema_example.asp (便宜上以下に再現)から考えてください。このコードは、<shiporder>
がルート要素であることをどのように示していますか?すべての要素 がルート要素として有効であるという例はありませんか?
------------------例--------------------------- -------
<?xml version="1.0" encoding="ISO-8859-1"?>
<shiporder orderid="889923"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="shiporder.xsd">
<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
<item>
<title>Empire Burlesque</title>
<note>Special Edition</note>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>1</xample saying that all elements are valid as root elements?quantity>
<price>9.90</price>
</item>
</shiporder>
-----------------------スキーマ------------デフ
- :------------私の視点から
<?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <!-- definition of simple elements --> <xs:element name="orderperson" type="xs:string"/> <xs:element name="name" type="xs:string"/> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/> <xs:element name="title" type="xs:string"/> <xs:element name="note" type="xs:string"/> <xs:element name="quantity" type="xs:positiveInteger"/> <xs:element name="price" type="xs:decimal"/> <!-- definition of attributes --> <xs:attribute name="orderid" type="xs:string"/> <!-- definition of complex elements --> <xs:element name="shipto"> <xs:complexType> <xs:sequence> <xs:element ref="name"/> <xs:element ref="address"/> <xs:element ref="city"/> <xs:element ref="country"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="item"> <xs:complexType> <xs:sequence> <xs:element ref="title"/> <xs:element ref="note" minOccurs="0"/> <xs:element ref="quantity"/> <xs:element ref="price"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="shiporder"> <xs:complexType> <xs:sequence> <xs:element ref="orderperson"/> <xs:element ref="shipto"/> <xs:element ref="item" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute ref="orderid" use="required"/> </xs:complexType> </xs:element> </xs:schema>
XMLスキーマは2つのことを行う必要がありますINE何を各ノードが
を配置することができる
私はリンクのアドバイスにちょうど従っていました。私は、上記のXMLスキーマで定義された要素のいずれかがドキュメントのルート要素として発生する可能性がありますが、正しいと思いますか?ありがとう。 – johngoche9999
質問者が間違ってやっていることと、彼がそれをどのように修正できるかについての深い説明のために、Brian Driscollさん、ありがとうございます。 – fool4jesus