[Home] [By Thread] [By Date] [Recent Entries]
Greetings,
I have an application in which I want to pass only elements in a document that are members of a particular namespace. I want the elements, the attributes and text nodes, but no child elements or attributes from other namespaces. Naively I though that I could just do something like this:
> <xsl:output method='xml' version='1.0' encoding='UTF-8' indent='yes'/> <xsl:template match="/dap:Dataset">
<xsl:copy >
<xsl:apply-templates />
</xsl:copy>
</xsl:template> <xsl:template match="dap:*">
<xsl:copy >
<xsl:copy-of select="dap:*" />
</xsl:copy>
</xsl:template> <xsl:template match="*">
<xsl:apply-templates />
</xsl:template> <xsl:template match="text()|@*">
<xsl:copy-of select="." />
</xsl:template></xsl:stylesheet> But all of the text content of the elements from other namespaces leaks through. I realize that this guy: <xsl:template match="text()|@*">
<xsl:copy-of select="." />
</xsl:template>Is the culprit. After many futile attempts at trying write an XPATH to match only text and attributes whose parent element is in the dap namespace I am here, looking for some advice. Any ideas? I have this feeling that the solution to this should be really simple, and that my transform is already twice as long as it should be. Nathan
|

Cart



