XSLT - Sortierung nach Nodes
 juls_pro_37
 juls_pro_37
    
    
      - xml
- xsl
- 1 ThomasM
 nicht angemeldet
 nicht angemeldetHi,
wie kann ich mein xml aufgrund der "LineInformation"/"Item"/"LineNum" sortieren?
Derzeit:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<SALESINVOICE>
  <Interchange>   
    <Interchange_Control_Number>5637353077</Interchange_Control_Number>
  </Interchange>
  <HeaderInformation>
    <Currency>EUR</Currency>    
  </HeaderInformation>
  <LineInformation>
    <Item>
      <LineNum>1.001</LineNum>      
    </Item>
    <Item>
      <LineNum>1.002</LineNum>      
    </Item>
    <Item>
      <LineNum>2</LineNum>      
    </Item>
    <Item>
      <LineNum>3</LineNum>      
    </Item>
    <Item>
      <LineNum>1</LineNum>      
    </Item>
  </LineInformation> 
</SALESINVOICE>
Korrekt:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<SALESINVOICE>
  <Interchange>   
    <Interchange_Control_Number>5637353077</Interchange_Control_Number>
  </Interchange>
  <HeaderInformation>
    <Currency>EUR</Currency>    
  </HeaderInformation>
  <LineInformation>
     <Item>
      <LineNum>1</LineNum>      
    </Item>
    <Item>
      <LineNum>1.001</LineNum>      
    </Item>
    <Item>
      <LineNum>1.002</LineNum>      
    </Item>
    <Item>
      <LineNum>2</LineNum>      
    </Item>
    <Item>
      <LineNum>3</LineNum>      
    </Item>
  </LineInformation> 
</SALESINVOICE>
Danke & LG Julian
Hallo Julian,
wie kann ich mein xml aufgrund der "LineInformation"/"Item"/"LineNum" sortieren?
Dafür steht xsl:sort bereit:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="LineInformation">
    <xsl:copy>
      <xsl:apply-templates select="Item">
        <xsl:sort select="LineNum" data-type="number" order="ascending"/>
      </xsl:apply-templates>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
Grüße,
Thomas