问题描述
我通常使用GUI应用程序,因此此XSD非常复杂,对我来说似乎有点陌生.任何帮助将是巨大的! XSD中的工会让我失望了,Google返回了不相关的信息或我很难理解的信息.随着期限的临近,我需要尽快解决.感谢您的宝贵时间.
我在使用此API接受我的XML时遇到麻烦.传输后,我收到此响应:
提供的文档不符合该资源的XML架构-原因:XML验证失败(错误)-(1826)元素"{http://www.aURL.com/api/saleDetail/v1_0}lineItem": ""不是联合体类型"{http://www.aURL.com/api/saleDetail/v1_0}lineItemType"的有效值."
这是XSD的适用于创建lineItem元素的部分:
Im usually working with GUI applications, and so this XSD is complicated enough to seem a little foreign to me. Any help would be great! The union in the XSD is throwing me off, and google returns irrelevant information or something I am having a hard time understanding. As the deadline approaches, I need to solve this as soon as possible. I appreciate your time.
Im having trouble with this API accepting my XML. When transmitted I receive this response:
"Document supplied does not comply with the XML Schema for this resource - Reason: XML Validation failed (error) - (1826) Element ''{http://www.aURL.com/api/saleDetail/v1_0}lineItem'': '' '' is not a valid value of the union type ''{http://www.aURL.com/api/saleDetail/v1_0}lineItemType''. "
Here is the section of the XSD that applies to creating a lineItem element:
<xs:simpleType name="emptyString">
<xs:restriction base="xs:string">
<xs:enumeration value="" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="priceValue">
<xs:restriction base="xs:decimal">
<xs:totalDigits value='10'/>
<xs:fractionDigits value='2'/>
<xs:minInclusive value='0'/>
<xs:maxInclusive value='99999999.99'/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="lineItemType">
<xs:union memberTypes="priceValue emptyString" />
</xs:simpleType>
<xs:element name="lineItem">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="lineItemType">
<xs:attribute name="quantity" type="xs:unsignedInt" use="required"/>
<xs:attribute name="productID" type="xs:string"/>
<xs:attribute name="owned" type="booleanInt"/>
<xs:attribute name="productName" type="xs:string"/>
<xs:attribute name="productCampaignResourceURL" type="resourceURI"/>
<xs:attribute name="lineItemStatus" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="lineItems">
<xs:complexType>
<xs:sequence>
<xs:element ref="lineItem" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
和我拒绝的XML版本:
and my rejected XML build:
<lineItems>
<lineItem id="1">
<quantity>1</quantity>
<productId>$productID</productId>
<owned>0</owned>
</lineItem>
</lineItems>
推荐答案
任何想法或技巧将不胜感激!
Any Ideas or Tips would be greatly appreciated!
<!--Sample XML file generated by XMLSpy v2009 sp1 (http://www.altova.com)-->
<lineitems xsi:nonamespaceschemalocation="sample.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<lineitem owned="0" productname="String" quantity="0" productid="String" lineitemstatus="String">0</lineitem>
<lineitem owned="0" productname="String" quantity="0" productid="String" lineitemstatus="String">0</lineitem>
</lineitems>
看起来您的XML应该显示为:
It would look like your XML should read:
<lineitems>
<lineitem owned="0" quantity="1" productid="productID">1</lineitem>
</lineitems>
现在,另一方面,如果我们将您的XML固定下来,并要求Altova基于该XML片段生成模式,那么它将产生以下内容:
Now on the otherhand, if we take your XML as set in stone and ask Altova to generate a schema based on that piece of XML, this is what it produces:
<!--W3C Schema generated by XMLSpy v2009 sp1 (http://www.altova.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="quantity">
<xs:simpletype>
<xs:restriction base="xs:byte">
<xs:enumeration value="1" />
</xs:restriction>
</xs:simpletype>
</xs:element>
<xs:element name="productId">
<xs:simpletype>
<xs:restriction base="xs:string">
<xs:enumeration value="
这篇关于XSD到XML的麻烦,传输与联合返回错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!