0

I want to change the order of line cac:InvoiceLine depending on this node:

cac:AdditionalItemProperty/cbc:Value

All InvoiceLines that have Item type=RC must be gruop at the end of lines, and all that have CU must be on the top.

  • 2
    Please edit your question to include an example of your input XML, and an example of what you want your result XML to look like. – Conal Tuohy Jun 20 '22 at 07:54

1 Answers1

0

If the mentioned values are the only ones you are concerned about, then it seems like you could just sort alphabetically by that value; see xsl:sort. You could just put this inside the xsl:for-each or xsl:apply-templates where you process your invoice lines:

<xsl:sort select="cac:AdditionalItemProperty/cbc:Value" />

On the other hand, if you only want to output only the line items with the mentioned values, you could select them separately. For example, assuming you have a template which matches your invoice lines, you'd first apply it to the 'CU' ones and then to the 'RC' ones:

<xsl:apply-templates select="cac:InvoiceLine[cac:AdditionalItemProperty/cbc:Value='CU']" />
<xsl:apply-templates select="cac:InvoiceLine[cac:AdditionalItemProperty/cbc:Value='RC']" />
Jukka Matilainen
  • 9,608
  • 1
  • 25
  • 19