W3C home > Mailing lists > Public > www-xpath-comments@w3.org > October to December 2003

RE: [Q] Possible to select all attributes except some?

From: Kay, Michael <Michael.Kay@softwareag.com>
Date: Sat, 22 Nov 2003 23:22:04 +0100
Message-ID: <DFF2AC9E3583D511A21F0008C7E62106073DD2D1@daemsg02.software-ag.de>
To: Steinar Bang <sb@dod.no>, www-xpath-comments@w3.org
This is easy in XPath 2.0:

  select="@* except @background"

In XPath 1.0, you have to write something like

  select="@*[local-name() != 'background']"

Michael Kay



> -----Original Message-----
> From: Steinar Bang [mailto:sb@dod.no] 
> Sent: 22 November 2003 14:55
> To: www-xpath-comments@w3.org
> Subject: [Q] Possible to select all attributes except some?
> 
> 
> 
> Is it possible to write an XPath expression to select all 
> attributes, except some.
> 
> The context is that the new Web interface of the Gmane 
> mail<->NNTP gateway[1] will use an XSLT style sheet to 
> transform HTML emails to harmless HTML, by stripping 
> everything in HTML that may be exploited[2]. 
> 
> The style sheet use the following construct to copy elements 
> that should be preserved:
> 
> <xsl:template match="h1|h2|h3|h4|h5|h6|p|a|td">
>   <xsl:element name="{name(.)}">
>     <xsl:copy-of select="@*"/>
>     <xsl:apply-templates/>
>   </xsl:element>
> </xsl:template>
> 
> Is it possible to replace "@*" with an expression that would 
> select all attributes except the attribute named "background"[3][4]?
> 
> Thanx!
> 
> 
> - Steinar
> 
> [1] <http://gmane.org/>
> [2] <http://article.gmane.org/gmane.discuss/4353>
> [3] <http://article.gmane.org/gmane.discuss/4525>
> [4] <http://article.gmane.org/gmane.discuss/4526>
> 
Received on Saturday, 22 November 2003 17:23:40 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:05:55 GMT