我已經3年了,因爲我與模式混淆,我記得他們對名稱空間前綴和所有非常特別。我還記得當在Eclipse中使用XML編輯器(我有Indigo)時,如果不展開,那麼複雜類型不會輕鬆解析。我的XSD XML模式有什麼問題?
所以你可能會有一位XML專家看看我的XML文件並告訴我前置XSD XML模式有什麼問題?
謝謝。
僑
+++++
的Eclipse抱怨的:
根元素下面的文檔中的標記必須被良好地形成。
我要指出,我創建用手XML並從中自動生成的XML在:
http://www.xmlforasp.net/codebank/system_xml_schema/buildschema/buildxmlschema.aspx
(獨立的複雜類型:因爲我3年前手工做了與亞馬遜的亞馬遜賣家中央XML文件手動)
如果在我看來應該在一個案例中使用ref,但我會推遲到專家。
+++++
<?xml version="1.0" encoding="utf-16"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="idioms" type="idiomsType" />
<xsd:complexType name="idiomsType">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="idiom" type="idiomType" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="idiomType">
<xsd:sequence>
<xsd:element name="phrase" type="xsd:string" />
<xsd:element name="meaning" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<idioms>
<idiom>
<phrase>A bit much</phrase>
<meaning>Excessive or annoying.</meaning>
</idiom>
<idiom>
<phrase>A bridge too far</phrase>
<meaning>Act of overreaching.</meaning>
</idiom>
</idioms>
OK,更新。將XSD包含在XML中的捷徑是非法的。所以我把它放回到XSD文件中。我還了解到,我無法使用xml開始前綴,因此我將其更改爲'tc'。
XSD現在是正確的(與我展開的Amazon Seller Central XSD相同)。
<?xml version="1.0" encoding="utf-16"?>
<xsd:schema xmlns:tcidioms="urn:tcidioms" targetNamespace="urn:tcidioms" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="idioms" type="tcidioms:idiomsType"/>
<xsd:complexType name="idiomsType">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="idiom" type="tcidioms:idiomType" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="idiomType">
<xsd:sequence>
<xsd:element name="phrase" type="xsd:string" />
<xsd:element name="meaning" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
但我有麻煩試圖包括該即時通訊我的XML文件,它現在看起來像這樣(的XML & XSD是在同一個目錄):
它抱怨:沒有語法限制(DTD或XML架構)檢測到的文檔。
這意味着我的XML文檔中的2行不正確。我已經嘗試了幾個變體來包含這個文件,但都沒有工作。保留在我的這個XML(和XSD)將被讀取本地文件系統而不是通過http。它仍然會以這種方式驗證嗎?
<?xml version="1.0" encoding="utf-16"?>
<idioms xmlns:tcidioms="urn:tcidioms" targetNamespace="urn:tcidioms ./EnglishIdioms.xsd">
<idiom>
<phrase>A bit much</phrase>
<meaning>Excessive or annoying.
</meaning>
</idiom>
<idiom>
<phrase>A bridge too far</phrase>
<meaning>Act of overreaching, going too far
and getting into trouble
or
failing.
</meaning>
</idiom>
</idioms>
的Visual Studio 2010(它創建的架構俄羅斯套娃風格):
XML文件雖然設置爲使用在VS2010接口的模式不表明代碼?
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="idioms">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="idiom">
<xs:complexType>
<xs:sequence>
<xs:element name="phrase" type="xs:string" />
<xs:element name="meaning" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="utf-8"?>
<idioms>
<idiom>
<phrase>A bit much</phrase>
<meaning>Excessive or annoying.</meaning>
</idiom>
<idiom>
<phrase>A bridge too far</phrase>
<meaning>Act of overreaching.</meaning>
</idiom>
<idiom>
<phrase>A chain is no stronger than its weakest link</phrase>
<meaning>The weakest part of an object is it's strength.</meaning>
</idiom>
</idioms>
對不起,這是我的錯字複製到互聯網。名單實際上更長,我縮短了。在Eclipse中,標籤被關閉。我也在這裏更正了標籤。 – RedlightGreenLight 2012-04-09 15:40:01
@RedlightGreenLight:已更新。 – leppie 2012-04-09 15:43:17
好的,我已經用命名空間更新了兩條相關的行(我也嘗試在命名空間前添加XML標籤:例如),但它仍然會給出相同的錯誤。 –
RedlightGreenLight
2012-04-09 18:03:31