473,395 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Node selection in XSLT

Can someone explain why of the following two alternative ways to select
as specific node the first one doesn't work while the second one does?

Variant I:

<recordToken>
<xsl:value-of select="/Root/Case[Id=./Id]/RecordToken" />
</recordToken>
Variant II:

<xsl:variable name="Id">
<xsl:value-of select="./Id" />
</xsl:variable>

<recordToken>
<xsl:value-of select="/Root/Case[Id=$Id]/RecordToken" />
</recordToken>

In Variant I we always get the value of RecordToken of the first Case
node in the XML document. In Variant II we get the RecordToken of the
Case that has the same Id as the current node.

Thank you

Daniel

Sep 23 '05 #1
2 1325
Tempore 18:05:24, die Friday 23 September 2005 AD, hinc in foro {comp.text.xml} scripsit <Fa******@rki.de>:
Can someone explain why of the following two alternative ways to select
as specific node the first one doesn't work while the second one does?

Variant I:

<recordToken>
<xsl:value-of select="/Root/Case[Id=./Id]/RecordToken" />
</recordToken>


"./foo" is the same as "foo"

Your select is then basically: "/Root/Case[Id=Id]/RecordToken" Doesn't make much sense;-)

Inside a [predicate], the context node changes. But, lukily, you can recall the original context node via the XSLT function 'current()':

"/Root/Case[Id=current()/Id]/RecordToken"

In most situations, '.' and 'current()' are the same, but not inside a predicate.

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Deserta faciunt et innovationem appelant
Sep 23 '05 #2


Fa******@rki.de wrote:
Can someone explain why of the following two alternative ways to select
as specific node the first one doesn't work while the second one does?

Variant I:

<recordToken>
<xsl:value-of select="/Root/Case[Id=./Id]/RecordToken" />
</recordToken>


Well this works as defined but probably does not do what you want. I
guess you are looking for
<xsl:value-of select="/Root/Case[Id=current()/Id]/RecordToken" />

See <http://www.w3.org/TR/xslt#function-current>.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ralf Wahner | last post by:
Dear Masters of XSLT Could I ask you for a clue on the following question? I'd like to use XSLT to transform an XML source file to LaTeX. In the following small example the <para> Element...
0
by: Keith Davies | last post by:
Hi All, In my web page generation, I want to be able to automatically split (create a new page) on nodes that meet certain criteria. One is if the 'out:split' attribute is set to 'yes' (dead...
1
by: Eric | last post by:
I am trying to figure out a good way to implement a XSLT transformation. Basically my goal is that I want to be able to ouput the following XML in a document: <chart type="pie" width="100"...
4
by: Rolf Kemper | last post by:
Hi All, ned help on the example below. It works fine for msxml3/4 but has problems with saxon. Saxon complains "can not find matching function ..... " My target is to write style sheets...
1
by: Alex | last post by:
Hello, I don't have sufficient experience with XSLT, and would really appreciate somebody's help in me giving ideas on solving a problem I have. Let's consider the following XML file: ...
5
by: John Sever | last post by:
My transform in cludes a variable that holds a node set from the node-set() extension function. It the transformation works fine when using MSXML2 or msxsl.exe but not in VB.Net. My code looks...
2
by: Rick | last post by:
I have an XML document that is generated from Infopath, I need to change the value of a namespace that is defined in a node in the form: <xsf:xDocumentClass "xmlns:my=valuehere">. when i navigate...
4
by: elsigh | last post by:
I'm wondering if anyone has any ideas about a way to quickly convert an HTML DOM Node into an XML Document. The goal is that I want to perform XSLT on the Node, which is coded correctly as XHTML....
4
by: Stan | last post by:
Forgive a newbie, please: I've got XML like this: <body> <block> <p>content of p1</p> <p>content of p2</p> <p>content of p3</p> ... <p>content of pN</p>
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.