0

This is XML source:

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

when i was trying to parse the above data with below xsd i was getting the Error Msg: An error occurred while parsing: The markup in the document following the root element must be well-formed

<?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>

Please help me to parse the above data

user1658369
  • 99
  • 1
  • 11
  • You've got multiple `` elements in that document, with no containing `` to act as a root element. A properly formed XML document has only **ONE** root element, and you've got multiple. – Marc B Sep 10 '12 at 16:50
  • how to add as root element to the above record set. i am getting the same error when i was trying to add with XSLT transformation – user1658369 Sep 10 '12 at 16:52
  • To @MarcB's point, the source XML is invalid because it has no root element to begin with. "Fixing" it to be proper, valid XML most likely means contacting whoever is providing you with that XML and asking them to verify it. – ABach Sep 10 '12 at 19:32

1 Answers1

0

the above xml you have mentioned should have a root element. Probably looks like this

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

Also, to apply SalesInData to your XSLT, Just hardCode to your requirement.

<xsl:element name="SalesInData">Dump your required data </xsl:element>