473,508 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XPathNodeIterator bahaviour

Hi,

please clarify this doubt about XPathNodeIterator..the following XSLT uses this..

my doubt is, by looking at the XSLT, i thought the output to be Book1..but the actual output is Book1Book2Book3Book4..

as I understand, func method is called only once and XPathNodeIterator.MoveNext() is called only once..and how is this concatenated output??

tia,
avnrao.

XSLT :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:books"
exclude-result-prefixes="msxsl">

<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

<xsl:variable name="node-fragment">
<book>Book1</book>
<book>Book2</book>
<book>Book3</book>
<book>Book4</book>
</xsl:variable>

<msxsl:script implements-prefix="user" language="c#">
-- include cdata here
string func(XPathNodeIterator it)
{
it.MoveNext();
return it.Current.Value;
//it.Current returns XPathNavigator positioned on the current node
}
</msxsl:script>
<xsl:template match="/">
<books>
<xsl:value-of select="user:func(msxsl:node-set($node-fragment))"/>
</books>
</xsl:template>

</xsl:stylesheet>

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>Hle4+hLykkifd3FHHowmXA==</Id>
Nov 12 '05 #1
2 3563
avnrao via .NET 247 wrote:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:books"
exclude-result-prefixes="msxsl">

<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

<xsl:variable name="node-fragment">
<book>Book1</book>
<book>Book2</book>
<book>Book3</book>
<book>Book4</book>
</xsl:variable>

<msxsl:script implements-prefix="user" language="c#">
-- include cdata here
string func(XPathNodeIterator it)
{
it.MoveNext();
return it.Current.Value;
//it.Current returns XPathNavigator positioned on the current node
}
</msxsl:script>
<xsl:template match="/">
<books>
<xsl:value-of select="user:func(msxsl:node-set($node-fragment))"/>


Result tree fragment ($node-fragment) is treated as a tree with
artificial root node and fragment nodes as its children.
msxsl:node-set() function always returns that root node.

Use <xsl:value-of select="user:func(msxsl:node-set($node-fragment)/*)"/>

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
avnrao via .NET 247 wrote:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:books"
exclude-result-prefixes="msxsl">

<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

<xsl:variable name="node-fragment">
<book>Book1</book>
<book>Book2</book>
<book>Book3</book>
<book>Book4</book>
</xsl:variable>

<msxsl:script implements-prefix="user" language="c#">
-- include cdata here
string func(XPathNodeIterator it)
{
it.MoveNext();
return it.Current.Value;
//it.Current returns XPathNavigator positioned on the current node
}
</msxsl:script>
<xsl:template match="/">
<books>
<xsl:value-of select="user:func(msxsl:node-set($node-fragment))"/>


Result tree fragment ($node-fragment) is treated as a tree with
artificial root node and fragment nodes as its children.
msxsl:node-set() function always returns that root node.

Use <xsl:value-of select="user:func(msxsl:node-set($node-fragment)/*)"/>

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #3

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

Similar topics

1
8384
by: panik | last post by:
Hi, say I have an xml file with an X number of nodes I want to loop through (to, for example, display each node as a HyperLink in an asp.net webpage). Which of both is best practice: 1. Loop...
0
1382
by: Ilian Nilsson | last post by:
Hi Al If I try to use the following code lines in an recursive (recurse down in Xml tree) manner the XPathNodeIterator gets reset in it's parent method call, which will end up in that all nodes...
0
381
by: avnrao via .NET 247 | last post by:
Hi, please clarify this doubt about XPathNodeIterator..the following XSLT uses this.. my doubt is, by looking at the XSLT, i thought the output to be Book1..but the actual output is...
2
4531
by: Emmanuel | last post by:
Hi, I am writing an ASP.NET web applications which uses an xml file to display html content on the web pages. My problem is that using the Value property of the current object of the...
4
1709
by: Jamie da Silva | last post by:
I couldn't find a better resource for reporting a possible .NET Framework 1.1 (SP0 & 1) bug, so if this is not the proper forum, please let me know. The problem appears to occur when using...
3
5303
by: KJ | last post by:
It is true that there is no way to get the outerXml of XPathNodeIterator.Current? Please say it isn't so.
0
942
by: David | last post by:
I'm using an XPathNodeIterator to select an element in an XML document that contains text I am going to put in a label on an aspx page. I want to be able to include HTML tags in the text read from...
2
3785
by: Volkan | last post by:
Hi, I'm trying to compare two XML documents and i'm using XPath queries to select nodes. XPathNavigator's Select method runs fast enough and returns an XPathNodeIterator object. When i try to...
6
7672
by: Kindler Chase | last post by:
I'm trying to iterate through a set of nodes and then edit/delete specific attributes using XPathNodeIterator. Adding attributes is no problem. My first question is how do I delete an attribute...
0
7323
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,...
1
7038
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...
0
7493
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...
0
5625
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,...
1
5049
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...
0
4706
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...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
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 ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.