shankar
shankar

Reputation: 1

XSLT output empty Debugging fails with no output

I read through forums and i am unable to understand why the output is empty. It might be a simple thing i am missing.

I tried debugging in VS 2017 and it does not give any output any help in this matter is appreciated. IF i input only the ns0:EFACT_D96A_ORDERS_EAN008 node as an input to XSLT the output comes with the "test" content

    <?xml version="1.0" encoding="UTF-16"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0 userCSharp" version="1.0" xmlns:ns1="http://Microsoft.LobServices.Sap/2007/03/Types/Idoc/3/ORDERS05//740" xmlns:ns0="http://Microsoft.LobServices.Sap/2007/03/Idoc/3/ORDERS05//740/Send" xmlns:ns2="http://Microsoft.LobServices.Sap/2007/03/Types/Idoc/Common/" xmlns:s0="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006" xmlns:ns3="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ins0="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006/InterchangeXML">
      <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
      <xsl:template match="/">
        <xsl:apply-templates select="/s0:EFACT_D96A_ORDERS_EAN008" />
      </xsl:template>
      <xsl:template match="/s0:EFACT_D96A_ORDERS_EAN008">

        <ns0:Send>
          <ns0:idocData>
            Test
          </ns0:idocData>
        </ns0:Send>
      </xsl:template>

    </xsl:stylesheet>

Input file-

    <ins0:EdifactInterchangeXml DelimiterSetSerializedData="39:-1:-1:43:58:63:-1:46:-1" xmlns:ins0="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006/InterchangeXML">
      <ns0:UNA xmlns:ns0="http://schemas.microsoft.com/Edi/EdifactServiceSchema">
        <UNA1>58</UNA1>

      </ns0:UNA>
      <ns0:UNB xmlns:ns0="http://schemas.microsoft.com/Edi/EdifactServiceSchema">
        <UNB1>
          <UNB1.1>ABCD</UNB1.1>
          <UNB1.2>5</UNB1.2>
        </UNB1>

      </ns0:UNB>
      <TransactionSetGroup>
        <TransactionSet DocType="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006#EFACT_D96A_ORDERS_EAN008">
          <ns0:EFACT_D96A_ORDERS_EAN008 xmlns:ns0="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006">


          </ns0:EFACT_D96A_ORDERS_EAN008>
        </TransactionSet>
      </TransactionSetGroup>
      <ns0:UNZ xmlns:ns0="http://schemas.microsoft.com/Edi/EdifactServiceSchema">
        <UNZ1>1</UNZ1>
        <UNZ2>86</UNZ2>
      </ns0:UNZ>
    </ins0:EdifactInterchangeXml>

Upvotes: 0

Views: 557

Answers (1)

Tim C
Tim C

Reputation: 70648

A forward slash / at the start of the expression matches the document node, so doing select="/s0:EFACT_D96A_ORDERS_EAN008" will only select s0:EFACT_D96A_ORDERS_EAN008 if it is a child of the document node. i.e. if it is the root element, which it isn't.

To select s0:EFACT_D96A_ORDERS_EAN008 regardless of where it is in the document do this...

<xsl:apply-templates select="//s0:EFACT_D96A_ORDERS_EAN008" />

You also need to remove the single forward slash from the match expression too (You don't need the double-slashes in the match expression, as the match will work regardless of where the element is in the document)

Try this XSLT

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0 userCSharp" version="1.0" xmlns:ns1="http://Microsoft.LobServices.Sap/2007/03/Types/Idoc/3/ORDERS05//740" xmlns:ns0="http://Microsoft.LobServices.Sap/2007/03/Idoc/3/ORDERS05//740/Send" xmlns:ns2="http://Microsoft.LobServices.Sap/2007/03/Types/Idoc/Common/" xmlns:s0="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006" xmlns:ns3="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ins0="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006/InterchangeXML">
  <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />

  <xsl:template match="/">
    <xsl:apply-templates select="//s0:EFACT_D96A_ORDERS_EAN008" />
  </xsl:template>

  <xsl:template match="s0:EFACT_D96A_ORDERS_EAN008">
    <ns0:Send>
      <ns0:idocData>
        Test
      </ns0:idocData>
    </ns0:Send>
  </xsl:template>
</xsl:stylesheet>

Upvotes: 0

Related Questions