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

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 UTC