English 中文(简体)
XSD 我的数据类型
原标题:XSD my data type
  • 时间:2012-05-24 08:43:21
  •  标签:
  • xsd

我想问一下. XSD 文件。 我找不到任何关于创建自己类型的信息, 例如 :

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

    <xs:complexType name="Client">
        <xs:sequence>
            <xs:element name="FirstName" type="string"/>
            <xs:element name="SecondName" type="string"/>
    </xs:sequence>
    </xs:complexType>

    <xs:complexType name="Contact">
        <xs:sequence>
            <xs:element name="contacts" type="Client"  minOccurs="1"/>
        </xs:sequence>
    </xs:complexType>   
</xsd:schema>

我想知道,这是正确的方式 定义我自己的类型接触?

最佳回答

有几点不完全正确。

  • xsd: 关闭公式标记上的命名空间别名应该只是 xs:

  • 原始字符串类型需要具备符合要求的类型, 即xxs:string。

  • 从样式的角度来看, 复杂类型应该结束类型 。

  • 如果您想要使用此方案( 可能通过联系人), 那么您需要声明一个根元素 。

"https://i.sstatic.net/Rtli1.png" alt="XML Schema的古典表示法"/ >

<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio 2012 Developer Edition (Trial) 10.0.1.3941 (http://www.liquid-technologies.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="ClientType">
        <xs:sequence>
            <xs:element name="FirstName" type="xs:string" />
            <xs:element name="SecondName" type="xs:string" />
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="ContactType">
        <xs:sequence>
            <xs:element name="contacts" type="ClientType" minOccurs="1" />
        </xs:sequence>
    </xs:complexType>
    <xs:element name="Client" type="ClientType" />
</xs:schema>

XML Schemas 基本上是一个没有工具就写成的复杂事物。 我认真研究如何获得一个好的系统设计师, 我建议< a href="http://www. liver-technology.com/Xml-Schema-Editor.aspx" rel=“ nofollow noreferrer' >Liquid XML演播室 。

问题回答

暂无回答




相关问题
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" ...

热门标签