473,569 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem setting node-set in XsltArgumentLis t

Sam
I am working with .Net 2.0. I found a 2002 posting with this sample
code of how to send a node-set into a XSLT transformation:

string xml = @"<foo><bar> The Test</bar></foo>";
string xsl =
@"<xsl:styleshe et xmlns:xsl=""htt p://www.w3.org/1999/XSL/Transform""
version=""1.0"" >
<xsl:param name=""param1""/>
<xsl:template match=""/"">
bar element from param1 value:
<xsl:copy-of select=""$param 1/bar""/>
</xsl:template>
</xsl:stylesheet> ";

XmlDocument doc = new XmlDocument();
doc.LoadXml(xml );
XPathNavigator nav = doc.CreateNavig ator();

XslTransform xslt = new XslTransform();
xslt.Load(new XmlTextReader(n ew StringReader(xs l)));

XPathDocument dummy = new XPathDocument(n ew
StringReader("< dummy/>"));
XsltArgumentLis t args = new XsltArgumentLis t();
//Pass element foo as parameter
args.AddParam(" param1", "", nav.Select("/foo"));
xslt.Transform( dummy, args, Console.Out);

The output I get is:

<?xml version="1.0" encoding="Windo ws-1252"?>
bar element from param1 value: <bar>The Test</bar>

If I am not mistaken, I should be getting:

<?xml version="1.0" encoding="Windo ws-1252"?>
bar element from param1 value: The Test

Does anyone know how to fix this sample to return the correct value?

Sam Carleton

Dec 15 '06 #1
1 1942
Sam wrote:
I am working with .Net 2.0.
Note that the preferred .NET 2.0 XSLT processor is XslCompiledTran sform
and not XslTransform.
string xml = @"<foo><bar> The Test</bar></foo>";
<xsl:copy-of select=""$param 1/bar""/>
<?xml version="1.0" encoding="Windo ws-1252"?>
bar element from param1 value: <bar>The Test</bar>

If I am not mistaken, I should be getting:

<?xml version="1.0" encoding="Windo ws-1252"?>
bar element from param1 value: The Test
Why, xsl:copy-of copies the selected node, in this case the bar element,
to the result tree. So you end up with a copy of the complete element in
the result tree, that is the expected behaviour.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Dec 16 '06 #2

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

Similar topics

3
6293
by: ChrisWinterscheid | last post by:
We are running DB2 8.1 on AIX 5.2. DB2level shows: DB21085I Instance "db2inst1" uses "32" bits and DB2 code release "SQL08016" with level identifier "02070106". Informational tokens are "DB2 v8.1.1.56", "s040616", "U497635", and FixPak "6". Product is installed at "/usr/opt/db2_08_01".
57
4247
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
2
5947
by: PRadyut | last post by:
in this code the delete function does not delete the last node of the double linked list the code ---------------------------------------------------------------- #include <stdio.h> #include <stdlib.h> #include <conio.h>
1
1548
by: Joel Byrd | last post by:
I am having a problem adding a node to the page. This works on other browser (Opera, Firefox, etc.), but not in IE. The following is the function to add the node: (the id "test_div" is a defined style) Now, the interesting thing is that it works if I use the function in a link using "onClick='add_div()'" or "href='javascript:...
8
1497
by: pauldepstein | last post by:
I am writing a program which looks at nodes which have coordinates which are time-dependent. So I have a class called node which contains the private member declarations int date; int month; (I want to consider the month as part of the information contained in the node, as well as the date.) The node class also contains public member...
5
23989
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any...
5
1714
by: Chad | last post by:
say my input file is $ more suck ______ < gnu? > ------ \ , , \ /( )` \ \ \___ / | /- _ `-/ '
8
1494
by: jj | last post by:
Trying to understand the manual regarding variables to solve the following. I'm working with Drupal CMS and have a loop to retrieve values that are normally fetched by using this variable: $node- incrementing that number 1 so next variable is $node- Here's what I'm trying in my loop to change that number in the variable using $i:
5
14804
by: jbenner | last post by:
I have opened a PMR for this with IBM, and am not asking for advice from the DB2 DBA community. I am posting this as an FYI that DB2 Health Monitor, even at the latest version of DB2, still can cause huge problems with slow connect times and heavy resource locking in high concurrency / high transaction volume environments. I have an OLTP with...
8
7356
by: Aftabpasha | last post by:
I have seen a simple program for handling Link List operations. The following is the part of the code that contains the problem. The code is modified but contains all necessary information regarding the problem. #include<stdio.h> #include<stdlib.h> #include<conio.h> struct llist { int val; struct llist *next; };
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7921
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.