Skip to Content
1
Former Member
Sep 12, 2011 at 03:39 PM

XSL

23 Views

Hi

I am trying to use an xslt stylesheet to sort my idoc segments but cannot get it to work. I am not getting any errors and I am getting an output but the sorting is not happening.

Here is my code

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="/ANYIDOC/IDOC">
      <ns1:ANYIDOC xmlns:ns1="urn:sap-com:document:sap:idoc:messages">
        
            <ns1:IDOC>
	<xsl:for-each select=".">
	<xsl:sort select="SEG1/FIELD1"/>
               	<xsl:copy-of select="SEG1"/>
	</xsl:for-each>
            </ns1:IDOC>
        

      </ns1:ANYIDOC>
   </xsl:template>
</xsl:stylesheet>

As you can see I am trying to sort the SEG1 segments using the FIELD1 field within the SEG1 segment.

I hope you can help.