Answer the question
In order to leave comments, you need to log in
How to remove an attribute in XSL?
Hi all!
Is it possible to remove an attribute in XSL, if so, how?
I did not find it on the Internet.
Answer the question
In order to leave comments, you need to log in
It would be better not to add it.
You can remove its value, for example:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="utf-8" version="1.0"/>
<xsl:template match="/">
<div data-attr="data-value">
<xsl:attribute name="data-attr"/>
<p>test</p>
</div>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="utf-8" version="1.0"/>
<xsl:template match="/">
<div>
<xsl:if test="true()">
<xsl:attribute name="data-attr">value</xsl:attribute>
</xsl:if>
<p>test</p>
</div>
<div>
<xsl:if test="false()">
<xsl:attribute name="data-attr">value</xsl:attribute>
</xsl:if>
<p>test</p>
</div>
</xsl:template>
</xsl:stylesheet>
<div data-attr="value"><p>test</p></div>
<div><p>test</p></div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question