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

Re: URGENT:Ignore Tags

Subject: Re: URGENT:Ignore Tags
From: Matt Gushee <mgushee@xxxxxxxxxxxxx>
Date: Tue, 26 Feb 2002 12:51:56 -0700
xml ignore tags
On Tue, Feb 26, 2002 at 07:43:00PM -0000, vasu   deva wrote:

> <root>
>  <child id = '1'>happy</child>
>  <child id = '2'>happy</child>
>  <child id = '3'>happy</child>
>  <child id = '1'>sad</child>
>  <child id = '2'>sad</child>
>  <child id = '3'>sad</child>
> </root>

Oh boy. First of all, this is bad XML (explanation below). If you
have control over the source documents, you should change them. If
not, you should try to persuade whoever does have control to change.
But of course, I know that sometimes us developers have to deal
with other people's bad XML, and there's not always an alternative.

It's bad XML because the value of an ID attribute (i.e., one, with a 
data type of ID) must be unique within each document. Furthermore,
the value must start with a name-start character (in English, that's
letters of the alphabet plus '_'). Now, the XML spec doesn't require
that an attribute named 'id' to have a type of ID. But for reasons
that should be obvious, it's a good idea to only use the name 'id'
for attributes that really are IDs.

With that rant out of the way, this XPath expression

   "child[@id != preceding-sibling::*/@id]"
 
should do what you want. Or if the important issue is the string
value 'happy', and you don't really care about the IDs, you could
use:

   "child[normalize-space() = 'happy']"

-- 
Matt Gushee
Englewood, Colorado, USA
mgushee@xxxxxxxxxxxxx
http://www.havenrock.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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-2013 All Rights Reserved.