1
我需要爲CodeSynthesis的XSD創建一個xsd文件。 對於不同的響應類型將會有多個模式。 正如您在示例XML文件中所看到的,某些元素具有類型屬性,而其中一些元素具有nil屬性。這些屬性沒有提供解析信息,我已經知道類型並將它們正確地設置在xsd文件中。除此之外,我不知道哪些元素是可用的。這些屬性可以在XSD架構某種程度上跳過,或者我應該寫爲每個元素:用於代碼生成的XSD文件,需要提示
<xsd:complexType>
<xsd:attribute name="type" type="TypeAttr" fixed="integer"/>
<xsd:attribute ref="nil"/>
</xsd:complexType>
其中
<xsd:attribute name="nil" type="xsd:boolean"/>
這就是XML文件中的一個:
<?xml version="1.0" encoding="UTF-8"?>
<account>
<access-key>bla-bla-bla</access-key>
<billing-error-date type="date" nil="true"></billing-error-date>
<default-ticket-report-id type="integer">0</default-ticket-report-id>
<default-time-zone nil="true"></default-time-zone>
<description nil="true"></description>
<disk-usage type="integer">38048</disk-usage>
<flagged-for-billing-error type="boolean">false</flagged-for-billing-error>
<force-ssl type="boolean">false</force-ssl>
<id type="integer">1</id>
<plan>micro</plan>
<subdomain>companyname</subdomain>
<text-markup>markdown,textile,plain</text-markup>
<title>companyname</title>
<features>
<attachments>true</attachments>
<ssl>false</ssl>
<storage>512</storage>
<time_tracking>false</time_tracking>
<max_people>10</max_people>
<max_pages>99999</max_pages>
<beta>false</beta>
</features>
<notebook_pages>0</notebook_pages>
<created-at>2011-02-16T13:50:09Z</created-at>
<updated-at>2011-04-07T09:11:10Z</updated-at>
</account>
根據http://www.w3.org/TR/2001/REC-xmlschema-0-20010502/#Nils,nil必須有xsi命名空間;這是一個錯字還是屬性名稱只是零(和任何其他的屬性)? – ThomasRS 2011-04-07 14:50:03
這只是一個像任何其他的屬性,xsi命名空間不在這裏使用。但它也用於指示空元素。 – vian 2011-04-08 01:59:05
是的,當你的問題只是任何屬性時,你的問題變得非常通用;) – ThomasRS 2011-04-08 02:24:19