473,698 Members | 2,616 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 1968
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
6313
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
4275
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
2
5955
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
1555
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: add_div();", but
8
1503
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 function void set_month(int) which sets the month according to the date given.
5
24005
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 one tell me how to set TCP\IP
5
1720
by: Chad | last post by:
say my input file is $ more suck ______ < gnu? > ------ \ , , \ /( )` \ \ \___ / | /- _ `-/ '
8
1501
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
14813
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 30-90 transactions per second activity, and start of Health Monitor every 2 hours was crashing our...
8
7365
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
8683
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8902
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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.