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

Re: Non Existent attribute, and other things.

Subject: Re: Non Existent attribute, and other things.
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 12 Mar 2001 13:27:10 GMT
xsl test nonexistent node
> Well I would have thought that a possibly non-existent
> attribute is 0 or not would be

why 0 of all things? How would you distinguish it from a value of 0?

> So I end up doing...
> count(@value) = 0 or not(number(@value))

count(@value) = 0 
is just a long (and slow) way of doing

@value

in either case the expression is true just if the node set is non empty.

I'm not sure why you are coercing @value to a number and then to a
boolean in the second part of th etest, what exactly are you testing
for?

test="@value"

tests if the value attribute is used. Is that all you need?

> key('Ps', $name)[count(.|$Ps) = count($Ps)]
> ...as I really don't understand it.

 key('Ps', $name)

returns a node set of all nodes which have the value $name for the key
Ps

[count(.|$Ps) = count($Ps)]

removes all of those nodes that are not in the node set $Ps.
as if the node (.) is in the set $Ps then the set (. | $Ps) will be 
equal to $Ps and so have the same count. If the node . is not in the set
then the union (. | $Ps) will have one extra element, so a different
count.

> There must be a more succinct method.
In general no. If you cared about succinctnes, you shouldn't be using
XML but in that particular example:


		<xsl:variable name="shorter">
			<xsl:choose>
				<xsl:when test="@short">
					<xsl:value-of select="@short"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="@name"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<menu name="{$name}">

is

<menu name="{@short|@name[not(@short)]}">

David

 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.