EDN Admin
Well-known member
Hi all,
I have XSLT templates which remove empty XML elements, and what I thought, would be empty attribute values too, but removing the empty attributes doesnt seem to work, I still manage to get empty attribute values in my output. My removal templates are below...
<pre class="prettyprint" style=" <!-- Remove empty nodes starting at the root. -->
<xsl:template match="@* | node()" mode="RemovalPass
<xsl:copy>
<xsl:apply-templates select="@* | node()" mode="RemovalPass" />
</xsl:copy>
</xsl:template>
<!-- Copy all nodes that have text. -->
<xsl:template match="*[not(descendant::text()[normalize-space()]) and not(descendant-or-self::*/@*)]" mode="RemovalPass" />
<!-- Include fixed XML Elements. -->
<xsl:template match="Summary | Identification" mode="RemovalPass" priority="3
<xsl:copy>
<xsl:apply-templates select="@* | node()" mode="RemovalPass" />
</xsl:copy>
</xsl:template>[/code]
what changes need to be applied (I am guessing to my middle template) so that it can remove attributes with empty values?
Thanks
<
Tryst
<br/>
View the full article
I have XSLT templates which remove empty XML elements, and what I thought, would be empty attribute values too, but removing the empty attributes doesnt seem to work, I still manage to get empty attribute values in my output. My removal templates are below...
<pre class="prettyprint" style=" <!-- Remove empty nodes starting at the root. -->
<xsl:template match="@* | node()" mode="RemovalPass
<xsl:copy>
<xsl:apply-templates select="@* | node()" mode="RemovalPass" />
</xsl:copy>
</xsl:template>
<!-- Copy all nodes that have text. -->
<xsl:template match="*[not(descendant::text()[normalize-space()]) and not(descendant-or-self::*/@*)]" mode="RemovalPass" />
<!-- Include fixed XML Elements. -->
<xsl:template match="Summary | Identification" mode="RemovalPass" priority="3
<xsl:copy>
<xsl:apply-templates select="@* | node()" mode="RemovalPass" />
</xsl:copy>
</xsl:template>[/code]
what changes need to be applied (I am guessing to my middle template) so that it can remove attributes with empty values?
Thanks
<
Tryst
<br/>
View the full article