Quick XSLT Question

Mike King

Usenet Archive
Joined
May 25, 2000
Messages
69
Reaction score
0
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>
 

David Carlisle

Usenet Archive
Joined
Jan 5, 2000
Messages
609
Reaction score
0
Mike King said:
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
 

Mike King

Usenet Archive
Joined
May 25, 2000
Messages
69
Reaction score
0
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top