Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 1st, 2008, 11:43 AM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default Xpath - Selecting attributes

Hi,

Take the following example:

Code:
<root>
    <foo att1="1" att2="2" att3="3">Data</foo>
</root>
Say I want to select all attributes of foo except @att2, how can I do this.

When I try:

Code:
<xsl:for-each select="@*[not(@att2)]">
The processor complains (saxon 9.1.0.1):

Code:
The attribute axis starting at an attribute node will never select anything
 
Old October 1st, 2008, 11:48 AM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

As you are using XSLT 2.0 you can translate your English description directly into code:
Code:
<xsl:for-each select="@* except @att2">

--
  Martin Honnen
  Microsoft MVP - XML
 
Old October 1st, 2008, 12:02 PM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Thanks Martin,

Yes I am using 2.0 - I need to stop leaning on 1.0 and start to using all the improvements in 2.0.

I picked up XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition, when it was released. I need to crack it open again.

Thanks!


 
Old October 1st, 2008, 12:27 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>to select all attributes of foo except @att2

In XSLT2, use

select="@* except @att2"



Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference




Similar Threads
Thread Thread Starter Forum Replies Last Post
Get NodesList by Xpath with Attributes Filters AbrarNazeer XML 5 March 26th, 2008 01:02 AM
Xpath expressions with attributes rbooth XSLT 3 November 11th, 2007 04:51 AM
selecting nodes that lack certain attributes rmers XSLT 3 October 4th, 2006 03:44 PM
XPath - Selecting nodes based on attribute values billy_bob_the_3rd XML 4 December 1st, 2004 06:12 PM
How to get certain ADSI Attributes grassi3000 C# 0 August 31st, 2004 12:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.