none
XSLT not a valid format issue RRS feed

  • Question

  • When i  write simple xslt for Development purpose, when i have create a mapping conditions its getting error as a XSLT not a valid format error So there have format invalid issue according to data not mapped, Could you please support to correct it, For your reference here with attached input xml and current xslt and expected output.

    Sample Input-

     

    <?xml version="1.0" encoding="UTF-8"?>

    <ns0:utrrada_Order xmlns:ns0="http://utrrada.com/3pl/FMS/XSDLibrary">
    <Orders>
       <Order>4202623821</Order>
       <Action>CHG</Action>


        <DateTime>
          <Date DateQualifier="PODate">20190628</Date>
        </DateTime>
        <MessageID>0000000801362405</MessageID>

        <OrderDetails>
          <LineNum>00010</LineNum>
          <DateTime>
        <Date DateQualifier="DeliveryDate">20191021</Date>
          </DateTime>
          <Price>
               <Amount Type="Net">15.80</Amount>
          </Price
        </OrderDetails>
     </Orders>
    </ns0:utrrada_Order>

    Issue 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.case.com/Schemas/Universal/2011/11" version="1.1">
    <Shipment>

    <DataContext>
    <DataTargetCollection>
    <DataTarget>
    <Type>OrderManagerOrder</Type>

    <xsl:for-each select="ns0:utrrada_Order/Orders"> 
    <xsl:choose>
    <xsl:when test="not(Order[.= ''])">  
    <Key><xsl:value-of select="Order"/></Key>
    </xsl:when>
    <xsl:otherwise>
    <!--No Order element-->
    </xsl:otherwise>
    </xsl:choose>
    </xsl:for-each>

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


    <CustomizedFieldCollection>


    <!--PODate -->
    <xsl:for-each select="ns0:utrrada_Order/Orders/DateTime/Date"> 
    <xsl:choose>
    <xsl:when test="@DateQualifier = 'PODate'">
    <DateCollection>
                               <Date>
                                 <Type>OrderDate</Type>
                                 <IsEstimate>false</IsEstimate>
                                 <Value><xsl:value-of select="Date"/></Value>  <!--2019-09-12T15:23:00-->
       </Date>
    </DateCollection>

    </xsl:when>
    </xsl:choose>
    </xsl:for-each>


    </CustomizedFieldCollection>


    <!--DeliveryDate-->
    <xsl:for-each select="ns0:utrrada_Order/Orders/OrderDetails/DateTime/Date">
    <xsl:choose>
    <xsl:when test="@DateQualifier = 'DeliveryDate'">
       <LocalProcessing>
          <DeliveryRequiredBy>
      <xsl:value-of select="ns0:utrrada_Order/Orders/OrderDetails/DateTime/Date"/> 
          </DeliveryRequiredBy>
      </LocalProcessing>
    </xsl:when>
    </xsl:choose>
    </xsl:for-each

    </Shipment>
    </UniversalShipment>
    </xsl:template>
    </xsl:stylesheet>

    Sample output- 

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

    <DateCollection>
    <Date>
            <Type>OrderDate</Type>
            <IsEstimate>false</IsEstimate>
            <Value>2019-08-10T14:00:00</Value>
     </Date>
    </DateCollection>

    <LocalProcessing>
          <DeliveryRequiredBy>2019-10-21T00:00:00</DeliveryRequiredBy>
    </LocalProcessing>

      </Shipment>
    </UniversalShipment>

    Thursday, October 3, 2019 6:14 PM

Answers

  • Hi Maheshma,

    Both input XML and XSLT were not well-formed. I had to adjust both before I modified the XSLT.

    Input XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:utrrada_Order xmlns:ns0="http://utrrada.com/3pl/FMS/XSDLibrary">
    	<Orders>
    		<Order>4202623821</Order>
    		<Action>CHG</Action>
    		<DateTime>
    			<Date DateQualifier="PODate">20190628</Date>
    		</DateTime>
    		<MessageID>0000000801362405</MessageID>
    		<OrderDetails>
    			<LineNum>00010</LineNum>
    			<DateTime>
    				<Date DateQualifier="DeliveryDate">20191021</Date>
    			</DateTime>
    			<Price>
    				<Amount Type="Net">15.80</Amount>
    			</Price>
    		</OrderDetails>
    	</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.case.com/Schemas/Universal/2011/11" version="1.1">
    			<Shipment>
    				<DataContext>
    					<DataTargetCollection>
    						<DataTarget>
    							<Type>OrderManagerOrder</Type>
    							<xsl:for-each select="ns0:utrrada_Order/Orders">
    								<xsl:choose>
    									<xsl:when test="not(Order[.= ''])">
    										<Order>
    											<xsl:value-of select="Order"/>
    										</Order>
    									</xsl:when>
    									<xsl:otherwise>
    										<!--No Order element-->
    									</xsl:otherwise>
    								</xsl:choose>
    							</xsl:for-each>
    						</DataTarget>
    					</DataTargetCollection>
    					<Company>
    						<Code>USA</Code>
    					</Company>
    					<EnterpriseID>EXK</EnterpriseID>
    					<ServerID>TST</ServerID>
    				</DataContext>
    				<!--PODate -->
    				<xsl:for-each select="ns0:utrrada_Order/Orders/DateTime/Date">
    					<xsl:choose>
    						<xsl:when test="@DateQualifier = 'PODate'">
    							<DateCollection>
    								<Date>
    									<Type>OrderDate</Type>
    									<IsEstimate>false</IsEstimate>
    									<Value>
    										<xsl:value-of select="Date"/>
    									</Value>
    									<!--2019-09-12T15:23:00-->
    								</Date>
    							</DateCollection>
    						</xsl:when>
    					</xsl:choose>
    				</xsl:for-each>
    				<!--</CustomizedFieldCollection>-->
    				<!--DeliveryDate-->
    				<xsl:for-each select="ns0:utrrada_Order/Orders/OrderDetails/DateTime/Date">
    					<xsl:choose>
    						<xsl:when test="@DateQualifier = 'DeliveryDate'">
    							<LocalProcessing>
    								<DeliveryRequiredBy>
    									<xsl:value-of select="."/>
    								</DeliveryRequiredBy>
    							</LocalProcessing>
    						</xsl:when>
    					</xsl:choose>
    				</xsl:for-each>
    			</Shipment>
    		</UniversalShipment>
    	</xsl:template>
    </xsl:stylesheet>



    • Edited by Yitzhak Khabinsky Thursday, October 3, 2019 8:27 PM
    • Marked as answer by Maheshma Monday, October 7, 2019 12:27 PM
    Thursday, October 3, 2019 6:54 PM

All replies

  • Hi Maheshma,

    Both input XML and XSLT were not well-formed. I had to adjust both before I modified the XSLT.

    Input XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:utrrada_Order xmlns:ns0="http://utrrada.com/3pl/FMS/XSDLibrary">
    	<Orders>
    		<Order>4202623821</Order>
    		<Action>CHG</Action>
    		<DateTime>
    			<Date DateQualifier="PODate">20190628</Date>
    		</DateTime>
    		<MessageID>0000000801362405</MessageID>
    		<OrderDetails>
    			<LineNum>00010</LineNum>
    			<DateTime>
    				<Date DateQualifier="DeliveryDate">20191021</Date>
    			</DateTime>
    			<Price>
    				<Amount Type="Net">15.80</Amount>
    			</Price>
    		</OrderDetails>
    	</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.case.com/Schemas/Universal/2011/11" version="1.1">
    			<Shipment>
    				<DataContext>
    					<DataTargetCollection>
    						<DataTarget>
    							<Type>OrderManagerOrder</Type>
    							<xsl:for-each select="ns0:utrrada_Order/Orders">
    								<xsl:choose>
    									<xsl:when test="not(Order[.= ''])">
    										<Order>
    											<xsl:value-of select="Order"/>
    										</Order>
    									</xsl:when>
    									<xsl:otherwise>
    										<!--No Order element-->
    									</xsl:otherwise>
    								</xsl:choose>
    							</xsl:for-each>
    						</DataTarget>
    					</DataTargetCollection>
    					<Company>
    						<Code>USA</Code>
    					</Company>
    					<EnterpriseID>EXK</EnterpriseID>
    					<ServerID>TST</ServerID>
    				</DataContext>
    				<!--PODate -->
    				<xsl:for-each select="ns0:utrrada_Order/Orders/DateTime/Date">
    					<xsl:choose>
    						<xsl:when test="@DateQualifier = 'PODate'">
    							<DateCollection>
    								<Date>
    									<Type>OrderDate</Type>
    									<IsEstimate>false</IsEstimate>
    									<Value>
    										<xsl:value-of select="Date"/>
    									</Value>
    									<!--2019-09-12T15:23:00-->
    								</Date>
    							</DateCollection>
    						</xsl:when>
    					</xsl:choose>
    				</xsl:for-each>
    				<!--</CustomizedFieldCollection>-->
    				<!--DeliveryDate-->
    				<xsl:for-each select="ns0:utrrada_Order/Orders/OrderDetails/DateTime/Date">
    					<xsl:choose>
    						<xsl:when test="@DateQualifier = 'DeliveryDate'">
    							<LocalProcessing>
    								<DeliveryRequiredBy>
    									<xsl:value-of select="."/>
    								</DeliveryRequiredBy>
    							</LocalProcessing>
    						</xsl:when>
    					</xsl:choose>
    				</xsl:for-each>
    			</Shipment>
    		</UniversalShipment>
    	</xsl:template>
    </xsl:stylesheet>



    • Edited by Yitzhak Khabinsky Thursday, October 3, 2019 8:27 PM
    • Marked as answer by Maheshma Monday, October 7, 2019 12:27 PM
    Thursday, October 3, 2019 6:54 PM
  • Hi Yitzhak,

    Thank you very much its worked, 

    Thanks

    Monday, October 7, 2019 12:28 PM