I need to sort elements BillOfMaterialIem based on value of attribute billOfMaterialItemID Example :
<?xml version="1.0" encoding="UTF-8"?>
<PackageData documentCreateDate="2019-10-03" documentModificationDate="2019-10-03">
<Items>
<Item itemID="416664">
<BillOfMaterial>
<BillOfMaterialItem billOfMaterialItemID="417230" />
<BillOfMaterialItem billOfMaterialItemID="417231" />
<BillOfMaterialItem billOfMaterialItemID="416664-01"/>
<BillOfMaterialItem billOfMaterialItemID="110424" />
</BillOfMaterial>
</Item>
</Items>
</PackageData>
This is ok to copy everything and filter empty atttributes :
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()">
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<xsl:if test="string-length(.)!=0">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>
Here is the template specific to element BillOfMaterial :
<xsl:template match="BillOfMaterial">
<xsl:copy>
<xsl:apply-templates select="BillOfMaterialItem" >
<xsl:sort select="@billOfMaterialItemID"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
Elements are sorted as expected but identation is killed in the output - despite indent="yes". I don't get the reason for this side-effect.
What do I miss ?
<xsl:strip-space elements="*"/> makes it work
Thank you, michael.hor257k