0

这是 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>

请帮我解析上述数据

4

1 回答 1

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>
于 2012-09-10T20:05:50.073 回答