English 中文(简体)
XML Schema的命令定义
原标题:Order definition in XML Schema
  • 时间:2012-04-04 17:11:35
  •  标签:
  • xsd

I want to define that the first element will be of a specific type, and the following will be some elements in any order. Like this:

<node>
<!-- always at first -->
<node-data>
...
</node-data>

<!-- other nodes in any order-->
<node3></node3>
<node1></node1>
<node2></node2>
</node>

I can t use <xsd:sequence> 因为它将迫使所有节点都符合规定。

Thanks for your help. Sorry on my english.

最佳回答

良好的开端布局可考虑这一点:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="node">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="node-data"/>
        <xs:choice minOccurs="0" maxOccurs="unbounded">         
          <xs:element name="node3" />
          <xs:element name="node1" />
          <xs:element name="node2" />
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

然后,你可以改进这些类型,在选择下增加更多节点等。 如果你想要支持野心,则需要使用<条码>x:任何

问题回答

暂无回答




相关问题
How to validate DataTable with XML Schema?

Does anyone know how to validate a DataTable against a particular DataTable XSD (Schema)? Which would be the best performance-optimized way of doing this? For example: <?xml version="1.0" ...

Deprecated XML validation code problem C#

I m trying to figure out how to correct his deprecated xml schema validation code. public static bool ValidateXml(string xmlFilename, string schemaFilename) { ⁞ //Forward stream reading ...

Getting an object representation of an .XSD file in Java

What is the easiest way to obtain a statically typed representation of an XML schema (.XSD) in Java? More specifically I want to be able to programatically traverse all defined simpleType:s and ...

xmlserializer validation

I m using XmlSerializer to deserialize Xml achives. But I found the class xsd.exe generated only offers capability to read the xml, but no validation. For example, if one node is missing in a document,...

regex for four-digit numbers (or "default")

I need a regex for four-digit numbers separated by comma ("default" can also be a value). Examples: 6755 3452,8767,9865,8766,3454 7678,9876 1234,9867,6876,9865 default Note: "default" ...

热门标签