Another total Nuby collection.

I have an xml file from which I wish to eliminate all elements that have any attributes at all. All I really need to do is eliminate the contents of the attribute. How do I do this?

My plan is to start with

<xsl:template match="Contains an attribute">
<bfbfb />
</xsl:template>

Of course the XPATH equivalent to "Contains an attribute" is unknown to me.

All help appreciated

Achava

Recommended Answers

All 3 Replies

It's an Identity Template with a match on ANY element that has an attribute. ' match="*[@*]" '

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

	<xsl:template match="*[@*]" />
</xsl:stylesheet>

Thank you for your answer.

You might want to also remove all the resulting whitespace by adding

<xsl:strip-space elements="*"/>

to the stylesheet provided by iceandrews.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.