这是XML源:
<SalesInRecord>
<ROW_NUM>8</ROW_NUM>
<BUY_QTY>5</BUY_QTY>
<HP_PRODUCT_ID>Apj45682#123</HP_PRODUCT_ID>
<LOCATION_ID>2-PQL-3403</LOCATION_ID>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<UNIT_BUY_PRICE>999999999</UNIT_BUY_PRICE>
<SUPPLIER_ID>2-PQL-3455</SUPPLIER_ID>
</SalesInRecord>
<SalesInRecord>
<ROW_NUM>5</ROW_NUM>
<BUY_QTY>5</BUY_QTY>
<PRODUCT_ID>Apj45683#123</PRODUCT_ID>
<LOCATION_ID>2-PQL-3403</LOCATION_ID>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<UNIT_BUY_PRICE>999999999</UNIT_BUY_PRICE>
<SUPPLIER_ID>2-PQL-3457</SUPPLIER_ID>
</SalesInRecord>
<SalesInRecord>
<ROW_NUM>6</ROW_NUM>
<BUY_QTY>5</BUY_QTY>
<PRODUCT_ID>Apj45684</PRODUCT_ID>
<LOCATION_ID/>
<LOCATION_NAME>XYZ XYZ</LOCATION_NAME>
<UNIT_BUY_PRICE>999999999</UNIT_BUY_PRICE>
<SUPPLIER_ID>2-PQL-3455</SUPPLIER_ID>
</SalesInRecord>
<SalesInRecord>
<ROW_NUM>7</ROW_NUM>
<BUY_QTY>5</BUY_QTY>
<PRODUCT_ID>Apj45685</PRODUCT_ID>
<LOCATION_ID/>
<LOCATION_NAME>XYZ XY</LOCATION_NAME>
<UNIT_BUY_PRICE>999999999</UNIT_BUY_PRICE>
<SUPPLIER_ID>2-PQL-3455</SUPPLIER_ID>
</SalesInRecord>
当我试图用下面的xsd解析上面的数据时,我得到了错误 消息:解析时发生错误:根元素后面的文档中的标记必须格式正确
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
<xs:element name="SalesInRecord">
<xs:complexType>
<xs:sequence>
<xs:element name="ROW_NUM" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="BUY_QTY" type="xs:integer" nillable="true" minOccurs="0"/>
<xs:element name="PRODUCT_ID" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="LOCATION_ID" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="LOCATION_NAME" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="UNIT_BUY_PRICE" type="xs:decimal" nillable="true" minOccurs="0"/>
<xs:element name="GOODS_RECEIVED_DATE" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="TRANSACTION_CURRENCY" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="TRANSACTION_DATE" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="TRANSACTION_DOCUMENT_ID" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="TRANSACTION_DOCUMENT_TYPE" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="SUPPLIER_ADDR_ASIAN" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="SUPPLIER_ADDR_STATE" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="SUPPLIER_ADDR_TOWN" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="SUPPLIER_ID" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="SUPPLIER_ISO_COUNTRY_CODE" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="SUPPLIER_NAME" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="SUPPLIER_POSTAL_CODE" type="xs:string" nillable="true" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
请帮我解析上述数据
答案 0 :(得分:0)
你提到的上面的xml应该有一个根元素。可能看起来像这样
<SalesInData>
<SalesInRecord>
<ROW_NUM>8</ROW_NUM>
<BUY_QTY>5</BUY_QTY>
<HP_PRODUCT_ID>Apj45682#123</HP_PRODUCT_ID>
<LOCATION_ID>2-PQL-3403</LOCATION_ID>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<UNIT_BUY_PRICE>999999999</UNIT_BUY_PRICE>
<SUPPLIER_ID>2-PQL-3455</SUPPLIER_ID>
</SalesInRecord>
<SalesInRecord>
<ROW_NUM>5</ROW_NUM>
<BUY_QTY>5</BUY_QTY>
<PRODUCT_ID>Apj45683#123</PRODUCT_ID>
<LOCATION_ID>2-PQL-3403</LOCATION_ID>
<LOCATION_NAME>XYZ el</LOCATION_NAME>
<UNIT_BUY_PRICE>999999999</UNIT_BUY_PRICE>
<SUPPLIER_ID>2-PQL-3457</SUPPLIER_ID>
</SalesInRecord>
<SalesInRecord>
<ROW_NUM>6</ROW_NUM>
<BUY_QTY>5</BUY_QTY>
<PRODUCT_ID>Apj45684</PRODUCT_ID>
<LOCATION_ID/>
<LOCATION_NAME>XYZ XYZ</LOCATION_NAME>
<UNIT_BUY_PRICE>999999999</UNIT_BUY_PRICE>
<SUPPLIER_ID>2-PQL-3455</SUPPLIER_ID>
</SalesInRecord>
<SalesInRecord>
<ROW_NUM>7</ROW_NUM>
<BUY_QTY>5</BUY_QTY>
<PRODUCT_ID>Apj45685</PRODUCT_ID>
<LOCATION_ID/>
<LOCATION_NAME>XYZ XY</LOCATION_NAME>
<UNIT_BUY_PRICE>999999999</UNIT_BUY_PRICE>
<SUPPLIER_ID>2-PQL-3455</SUPPLIER_ID>
</SalesInRecord>
<SalesInData>
此外,要将SalesInData应用于您的XSLT,只需硬编码即可满足您的要求。
<xsl:element name="SalesInData">Dump your required data </xsl:element>