xsl-list
[Top] [All Lists]

Re: [xsl] Xpath 1.0 Question : Excluding Attributes?

2007-03-28 16:56:29
Simon Shutter wrote:
Could someone tell me what the Xpath expression is that includes all element nodes

//*

and only specific attribute children?

//* | //@specific1 | //@specific2

or do you mean:

//* | //specelem/@specific1 | | //specelem/@specific2


But I get the feeling that you want an identity transform of XML, where you want to leave all elements in place, get rid of all attributes except for a few. This can be done like:

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

<!-- throw away all attributes -->
<xsl:template match="@*" />

<!-- except these -->
<xsl:template match="@specific1 | @specific2">
  <xsl:copy />
</xsl:template>

<!-- and these with specific parents -->
<xsl:template match="someparent/@specific1">
  <xsl:copy />
</xsl:template>


HTH,

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--