Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 June 13th, 2007, 01:24 AM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Use xPath to test for an absent/missing attribute

Use xPath to test for an absent/missing attribute

Lets say you have this for input

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <object good="foo" >aoeu</object>
    <object >bar</object>
</root>


Is there a way to get the object without the good attribute?

In other words the opposite of this:

root/object[@good]



 
Old June 13th, 2007, 02:07 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

root/object[not(@good)]

--

Joe (Microsoft MVP - XML)
 
Old June 13th, 2007, 04:09 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Sure:

root/object[not(@good)]


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 13th, 2007, 09:00 AM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I should have seen that, it’s painfully obvious after seeing it once. Thanks for the help!






Similar Threads
Thread Thread Starter Forum Replies Last Post
extract attribute value xPath chetrity XML 2 April 4th, 2011 07:09 PM
Absent Report zrtv VB Databases Basics 2 February 27th, 2008 04:08 AM
missing attribute RazoRmedia XSLT 3 January 27th, 2006 08:18 AM
missing attribute RazoRmedia XSLT 8 January 4th, 2006 02:12 PM
XPath - Selecting nodes based on attribute values billy_bob_the_3rd XML 4 December 1st, 2004 06:12 PM





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