RE: [Q] Possible to select all attributes except some?
"Kay, Michael" <[email protected]> Sat, 22 Nov 2003 23:22:04 +0100
| Newsgroups | gmane.text.xml.xpath.general |
|---|---|
| Message-ID | <[email protected]> |
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C3B147.0ECA9E20 Content-Type: text/plain 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:[email protected]] > Sent: 22 November 2003 14:55 > To: [email protected] > 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> > ------_=_NextPart_001_01C3B147.0ECA9E20 Content-Type: text/html Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dus-ascii"> <META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 5.5.2653.12"> <TITLE>RE: [Q] Possible to select all attributes except some?</TITLE> </HEAD> <BODY> <P><FONT SIZE=3D2>This is easy in XPath 2.0:</FONT> </P> <P><FONT SIZE=3D2> select=3D"@* except = @background"</FONT> </P> <P><FONT SIZE=3D2>In XPath 1.0, you have to write something like</FONT> </P> <P><FONT SIZE=3D2> select=3D"@*[local-name() !=3D = 'background']"</FONT> </P> <P><FONT SIZE=3D2>Michael Kay</FONT> </P> <BR> <BR> <P><FONT SIZE=3D2>> -----Original Message-----</FONT> <BR><FONT SIZE=3D2>> From: Steinar Bang [<A = HREF=3D"mailto:[email protected]">mailto:[email protected]</A>] </FONT> <BR><FONT SIZE=3D2>> Sent: 22 November 2003 14:55</FONT> <BR><FONT SIZE=3D2>> To: [email protected]</FONT> <BR><FONT SIZE=3D2>> Subject: [Q] Possible to select all attributes = except some?</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> Is it possible to write an XPath expression to = select all </FONT> <BR><FONT SIZE=3D2>> attributes, except some.</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> The context is that the new Web interface of = the Gmane </FONT> <BR><FONT SIZE=3D2>> mail<->NNTP gateway[1] will use an XSLT = style sheet to </FONT> <BR><FONT SIZE=3D2>> transform HTML emails to harmless HTML, by = stripping </FONT> <BR><FONT SIZE=3D2>> everything in HTML that may be exploited[2]. = </FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> The style sheet use the following construct to = copy elements </FONT> <BR><FONT SIZE=3D2>> that should be preserved:</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> <xsl:template = match=3D"h1|h2|h3|h4|h5|h6|p|a|td"></FONT> <BR><FONT SIZE=3D2>> <xsl:element = name=3D"{name(.)}"></FONT> <BR><FONT SIZE=3D2>> <xsl:copy-of = select=3D"@*"/></FONT> <BR><FONT SIZE=3D2>> = <xsl:apply-templates/></FONT> <BR><FONT SIZE=3D2>> </xsl:element></FONT> <BR><FONT SIZE=3D2>> </xsl:template></FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> Is it possible to replace "@*" with = an expression that would </FONT> <BR><FONT SIZE=3D2>> select all attributes except the attribute = named "background"[3][4]?</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> Thanx!</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> - Steinar</FONT> <BR><FONT SIZE=3D2>> </FONT> <BR><FONT SIZE=3D2>> [1] <<A HREF=3D"http://gmane.org/" = TARGET=3D"_blank">http://gmane.org/</A>></FONT> <BR><FONT SIZE=3D2>> [2] <<A = HREF=3D"http://article.gmane.org/gmane.discuss/4353" = TARGET=3D"_blank">http://article.gmane.org/gmane.discuss/4353</A>></F= ONT> <BR><FONT SIZE=3D2>> [3] <<A = HREF=3D"http://article.gmane.org/gmane.discuss/4525" = TARGET=3D"_blank">http://article.gmane.org/gmane.discuss/4525</A>></F= ONT> <BR><FONT SIZE=3D2>> [4] <<A = HREF=3D"http://article.gmane.org/gmane.discuss/4526" = TARGET=3D"_blank">http://article.gmane.org/gmane.discuss/4526</A>></F= ONT> <BR><FONT SIZE=3D2>> </FONT> </P> </BODY> </HTML> ------_=_NextPart_001_01C3B147.0ECA9E20--