Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 22nd, 2009, 06:49 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I am afraid I don't understand what exactly you want to achieve. If you pass in a node and what to check if it is the context node then in XSLT 2.0 you can use 'is' operator, with XSLT 1.0 you can use generate-id on each node and compare the result.

Some of your question however sounds as if you do not pass in a node itself but rather a node name. Dynamic evaluation of a string with an XPath expression is not covered by the XSLT language, you would need to look into an extension function provided by the XSLT processor you use. Whether you really need that I am not sure, if you only have a single node name and not a path with several steps then doing something like xsl:when test="local-name() = $node-name" might suffice.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old July 22nd, 2009, 08:48 AM
Authorized User
 
Join Date: May 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Iam trying to write a generic template which will copy all the elements from the source tree except the node i want to exclude which will be passed as an argument to this generic template.


Yes you are correct . Iam passing a node name to a named template.
if i try to execute a xpath node functions like count or any xpath expression ,iam getting the below error -

"value is not a node set" .

This error is because the node name is treated as string ,not a node set.

I read that exst:node-set() returns a node set for the argument passed.Can this function help me with this issue .

Any suggestions ....

Thanks,
Arun
 
Old July 22nd, 2009, 08:58 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Please start a new thread for a new question - the archives get quite impossible to follow otherwise.

If $name is an element name, you can select elements with this name using
Code:
*[name()=$name]
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old July 22nd, 2009, 09:01 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

exsl:node-set takes a result tree fragment as its argument, not a string with an element name.
If you want dynamic XPath evaluation then you need to use an extension function like http://www.saxonica.com/documentatio.../evaluate.html.
Whether you need that I am not sure, why can't you check xsl:when test="local-name() = $node-name" where node-name is the name of the parameter.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old July 22nd, 2009, 09:19 AM
Authorized User
 
Join Date: May 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Martin - I can match the context node using local-name() but iam not able to write an xpath expression when condition is met .

I will start a new thread with the sample xml.

Thank You.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Processing specific Nodes Krippers XSLT 3 November 6th, 2008 05:38 AM
Problem Copying Nodes tclotworthy XSLT 14 February 13th, 2007 01:13 PM
Copying Source Node attributes to output node pvsat XSLT 2 November 3rd, 2005 09:46 AM
Problem copying XML nodes francislang XSLT 9 October 21st, 2005 10:37 AM
Copying XML nodes from one document to another hughcr C# 2 May 12th, 2005 01:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.