none
'Xslt' must be a valid XML error RRS feed

  • Question

  • Hi Team,

    Currently i have requirement to write simple xslt and use it for Development purpose, when i create it there have format invalid issue, Could you please support to correct it, For your reference here with attached input xml and current xslt and expected output.

    Input xml- 

      

    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:utrrada_Order xmlns:ns0="http://utrrada.com/3pl/FMS/XSDLibrary">
    <Orders>
       <Order>4202623821</Order>
       <DocType Variant="ZNB">PO</DocType>
       <Action>CHG</Action>

       <SoldTo>
          <ID>1000</ID>
        </SoldTo>

        <ShipTo>
          <ID>9001</ID>
        </ShipTo>

        <GoodsSupplier>
          <ID>0000602110</ID>
          <Name>NONSNOW LTD</Name>
        </GoodsSupplier>

        <Vendor>
          <ID>0000402062</ID>
          <Name>HON</Name>
        </Vendor>

     </Orders>
    </ns0:utrrada_Order>

    XSLT - :

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://utrrada.com/3pl/FMS/XSDLibrary" exclude-result-prefixes="ns0">
    <xsl:output indent="yes" method="xml"/>
    <xsl:template match="/">

    <UniversalShipment xmlns="http://www.cargowise.com/Schemas/Universal/2011/11" version="1.1">
      <Shipment>
      
        <DataContext>
          <DataTargetCollection>
            <DataTarget>
              <Type>OrderManagerOrder</Type>
      <Key><xsl:value-of select="Orders/Order"/></Key>
      
            </DataTarget>
          </DataTargetCollection>

          <Company>
            <Code>USA</Code>
          </Company>
      
      <EnterpriseID>EXK</EnterpriseID>
          <ServerID>TST</ServerID>  
    </DataContext>   

     
      </Shipment>
    </UniversalShipment>

    </xsl:template>
    </xsl:stylesheet>

     expected output-

        <UniversalShipment xmlns="http://www.cargowise.com/Schemas/Universal/2011/11" version="1.1">
      <Shipment>
        <DataContext>
          <DataTargetCollection>
            <DataTarget>
              <Type>OrderManagerOrder</Type>
              <Key>4202623821</Key>
            </DataTarget>
          </DataTargetCollection>

          <Company>
            <Code>USA</Code>
          </Company>
          <EnterpriseID>EXK</EnterpriseID>
     
          <ServerID>TST</ServerID>
        </DataContext>


      </Shipment>
    </UniversalShipment>

    Thursday, September 19, 2019 7:01 AM

Answers

  • Hi Maheshma,

    I made two adjustments to the XSLT to make it working:

    1. Added omit-xml-declaration="yes".
    2. Fixed the XPath expression to get the Order value.

    Input XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:utrrada_Order xmlns:ns0="http://utrrada.com/3pl/FMS/XSDLibrary">
    	<Orders>
    		<Order>4202623821</Order>
    		<DocType Variant="ZNB">PO</DocType>
    		<Action>CHG</Action>
    
    		<SoldTo>
    			<ID>1000</ID>
    		</SoldTo>
    
    		<ShipTo>
    			<ID>9001</ID>
    		</ShipTo>
    
    		<GoodsSupplier>
    			<ID>0000602110</ID>
    			<Name>NONSNOW LTD</Name>
    		</GoodsSupplier>
    
    		<Vendor>
    			<ID>0000402062</ID>
    			<Name>HON</Name>
    		</Vendor>
    	</Orders>
    </ns0:utrrada_Order>

    XSLT:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://utrrada.com/3pl/FMS/XSDLibrary" exclude-result-prefixes="ns0">
    	<xsl:output indent="yes" method="xml" omit-xml-declaration="yes"/>
    
    	<xsl:template match="/">
    		<UniversalShipment xmlns="http://www.cargowise.com/Schemas/Universal/2011/11" version="1.1">
    			<Shipment>
    				<DataContext>
    					<DataTargetCollection>
    						<DataTarget>
    							<Type>OrderManagerOrder</Type>
    							<Key>
    								<xsl:value-of select="ns0:utrrada_Order/Orders/Order"/>
    							</Key>
    						</DataTarget>
    					</DataTargetCollection>
    					<Company>
    						<Code>USA</Code>
    					</Company>
    					<EnterpriseID>EXK</EnterpriseID>
    					<ServerID>TST</ServerID>
    				</DataContext>
    			</Shipment>
    		</UniversalShipment>
    	</xsl:template>
    </xsl:stylesheet>

    Output:
    <UniversalShipment xmlns="http://www.cargowise.com/Schemas/Universal/2011/11" version="1.1">
      <Shipment>
        <DataContext>
          <DataTargetCollection>
            <DataTarget>
              <Type>OrderManagerOrder</Type>
              <Key>4202623821</Key>
            </DataTarget>
          </DataTargetCollection>
          <Company>
            <Code>USA</Code>
          </Company>
          <EnterpriseID>EXK</EnterpriseID>
          <ServerID>TST</ServerID>
        </DataContext>
      </Shipment>
    </UniversalShipment>

    • Marked as answer by Maheshma Friday, September 20, 2019 2:21 PM
    Thursday, September 19, 2019 1:04 PM

All replies

  • Hi Maheshma,

    I made two adjustments to the XSLT to make it working:

    1. Added omit-xml-declaration="yes".
    2. Fixed the XPath expression to get the Order value.

    Input XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:utrrada_Order xmlns:ns0="http://utrrada.com/3pl/FMS/XSDLibrary">
    	<Orders>
    		<Order>4202623821</Order>
    		<DocType Variant="ZNB">PO</DocType>
    		<Action>CHG</Action>
    
    		<SoldTo>
    			<ID>1000</ID>
    		</SoldTo>
    
    		<ShipTo>
    			<ID>9001</ID>
    		</ShipTo>
    
    		<GoodsSupplier>
    			<ID>0000602110</ID>
    			<Name>NONSNOW LTD</Name>
    		</GoodsSupplier>
    
    		<Vendor>
    			<ID>0000402062</ID>
    			<Name>HON</Name>
    		</Vendor>
    	</Orders>
    </ns0:utrrada_Order>

    XSLT:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://utrrada.com/3pl/FMS/XSDLibrary" exclude-result-prefixes="ns0">
    	<xsl:output indent="yes" method="xml" omit-xml-declaration="yes"/>
    
    	<xsl:template match="/">
    		<UniversalShipment xmlns="http://www.cargowise.com/Schemas/Universal/2011/11" version="1.1">
    			<Shipment>
    				<DataContext>
    					<DataTargetCollection>
    						<DataTarget>
    							<Type>OrderManagerOrder</Type>
    							<Key>
    								<xsl:value-of select="ns0:utrrada_Order/Orders/Order"/>
    							</Key>
    						</DataTarget>
    					</DataTargetCollection>
    					<Company>
    						<Code>USA</Code>
    					</Company>
    					<EnterpriseID>EXK</EnterpriseID>
    					<ServerID>TST</ServerID>
    				</DataContext>
    			</Shipment>
    		</UniversalShipment>
    	</xsl:template>
    </xsl:stylesheet>

    Output:
    <UniversalShipment xmlns="http://www.cargowise.com/Schemas/Universal/2011/11" version="1.1">
      <Shipment>
        <DataContext>
          <DataTargetCollection>
            <DataTarget>
              <Type>OrderManagerOrder</Type>
              <Key>4202623821</Key>
            </DataTarget>
          </DataTargetCollection>
          <Company>
            <Code>USA</Code>
          </Company>
          <EnterpriseID>EXK</EnterpriseID>
          <ServerID>TST</ServerID>
        </DataContext>
      </Shipment>
    </UniversalShipment>

    • Marked as answer by Maheshma Friday, September 20, 2019 2:21 PM
    Thursday, September 19, 2019 1:04 PM
  • Hi Yitzhak,

    Thank you very much its worked. 

    Thanks

    Mahesh

    Friday, September 20, 2019 2:22 PM