Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Quick XSLT Question

Reply
Thread Tools

Quick XSLT Question

 
 
Mike King
Guest
Posts: n/a
 
      07-29-2004
Does the following code have any defined behavior in XSLT or XPath? I have
tried this before and it didn't do what I thought it should do. Instead, I
had to use the local-name() function and compare it with a string
representing the element of interest.

<xsl:if test=". = SomeElement">
</xsl:if>


 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      07-29-2004
"Mike King" <> writes:

> Does the following code have any defined behavior in XSLT or XPath? I have
> tried this before and it didn't do what I thought it should do. Instead, I
> had to use the local-name() function and compare it with a string
> representing the element of interest.
>
> <xsl:if test=". = SomeElement">
> </xsl:if>



it tests if the string value of the current node is equal to the string
value of its SomeElement child so if the current element is x it would
be true on

<x><a/><b/><SomeElement>aaa</SomeElement></x>

as they both have string value aaa.

You probably wanted

test="self::SomeElement"

which tests if the current node is a SomeElement element.

david
 
Reply With Quote
 
 
 
 
Mike King
Guest
Posts: n/a
 
      07-29-2004
> it tests if the string value of the current node is equal to the string
> value of its SomeElement child so if the current element is x it would
> be true on
>
> <x><a/><b/><SomeElement>aaa</SomeElement></x>
>
> as they both have string value aaa.
>
> You probably wanted
>
> test="self::SomeElement"
>
> which tests if the current node is a SomeElement element.
>
> david



Thank you very much!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT question: How to lookup another tag's children in XSLT yinglcs@gmail.com XML 18 10-03-2006 11:22 PM
Quick question, hopefully quick answer. ~misfit~ NZ Computing 114 01-06-2005 01:36 PM
Quick question, hopefully quick answer. ~misfit~ NZ Computing 0 12-28-2004 11:55 PM
Quick Question Quick Answer JKop C++ 11 05-24-2004 09:46 PM
Quick Restore for a Compaq not so quick! Croos Bustamunky Computer Support 2 05-15-2004 04:17 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57