User501
User501

Reputation: 347

Need to remove attributes for particular instance

Actually I need to convert the xml file into DITA with attributes remove for certain instance. Even I used " exclude-result-prefixes="#all" " in a XSL,

My Input xml file is:

    <LearningStandardItem xml:lang="en" RefID="CA9EE2E34F384E95A5FA26769C5864B8">
        <RefURI>http://corestandards.org/Math/Content/K/CC/A/1/</RefURI>
</LearningStandardItem>

XSL Which i used:

<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="#all" >

<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>

<xsl:template match="LearningStandardItem">
        <bodydiv outputclass="LearningStandardItem">
            <xsl:apply-templates select="@*|node()"/>
        </bodydiv>
    </xsl:template>

</xsl:stylesheet>

Output which I'm getting as:

<bodydiv outputclass="LearningStandardItem"
               **xml:lang="en"**
               id="CA9EE2E34F384E95A5FA26769C5864B8">
<p outputclass="RefURI">http://corestandards.org/Math/Content/K/CC/A/1/</p>
</bodydiv>

But i need to remove xml:lang="en" in the output as like below:

<bodydiv outputclass="LearningStandardItem"
               id="CA9EE2E34F384E95A5FA26769C5864B8">
<p outputclass="RefURI">http://corestandards.org/Math/Content/K/CC/A/1/</p>
</bodydiv>

Please provide the suggestions regarding to this. Thank you in advance.

Upvotes: 0

Views: 28

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167516

Add an empty template <xsl:template match="LearningStandardItem/@xml:lang"/> as that way that attribute will not be copied.

Upvotes: 3

Related Questions