472,952 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 3524
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
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
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
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
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
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
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
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
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
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
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

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.