[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Xpath 1.0 Question : Excluding Attributes?

Subject: RE: Xpath 1.0 Question : Excluding Attributes?
From: "Simon Shutter" <simon@xxxxxxxxxxx>
Date: Thu, 29 Mar 2007 06:56:38 -0700
RE:  Xpath 1.0 Question : Excluding Attributes?
Abel,

Thank you the excellent explanation - it helps me a lot.

Simon

-----Original Message-----
From: Abel Braaksma [mailto:abel.online@xxxxxxxxx] 
Sent: March 29, 2007 1:49 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Xpath 1.0 Question : Excluding Attributes?

Simon Shutter wrote:
> Hi Abel,
>
> Sorry for the confusion.  I meant only attribute nodes so I assume from
your
> examples that I have to put the entire path before each attribute of
> interest.
>
> Ie // tier1 / tier2 / @attrb1 | // tier1 / tier2 / @attrb2
>
>
> Is there a way to exclude specific attributes in Xpath 1.0?

Well, like I said, usually the easiest way to do that is by using an 
identity transform (see my examples), but I haven't seen your code so I 
can't tell it's the right approach.

With any of your XPaths, however, this works for excluding attributes:

//tier1/tier2/@*[not(local-name() = 'exclude-me')]

and this with QNames:

//tier1/tier2/@*[not(name() = 'ns:exclude-me')]

Finally, you may have hoped this would work, like it does for normal axis:

//tier1/tier2/@*[not(self::exclude-me)]

but then you try to test for the self::node() being an 'exclude-me' 
element node, but self::node() is not an element, it is an attribute 
(the reason is, technically speaking, that the principal node kind of 
self:: is the element node, and you can't switch that). Unfortunately, 
XPath does not have a way to express a self::node() axis when the axis 
is the attribute axis. I.e., this won't work (illegal):

//tier1/tier2/@*[not(self::@exclude-me)]

XPath 2.0 has a workaround for this (also note the way of using 
parenthesis, which is not legal for XPath 1.0, but in this case saves a 
lot of re-typing the parent path):

//tier1/tier2/(@* except @exclude-me)


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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.