Here's what I have (in snippets)
** XML **
<parent>
<child>
<grandchild/>
</child>
</parent>
** XSLT **
<xsl:template match="/parent">
parent: <xsl:value-of select="util:Lo calName(.)"/>
child: <xsl:value-of select="util:Lo calName(child)"/>
grandchild: <xsl:value-of select="util:Lo calName(child/grandchild)"/>
</xsl:template>
** C# (util object) **
public string LocalName(XmlPa thNodeIterator xit)
{
return xit.Current.Loc alName;
}
but for some reason, each call to LocalName returns "parent". A little
sleuthing, and I've discovered that the XmlPathNodeIter ators _are_
different: they seem to have different FilterQuery and ChildrenQuery
internal settings, but how do I translate that into something I can have
access to?
Thanks,
Douglas R. Steen
Boulder, CO 5 2871
Douglas Steen wrote: public string LocalName(XmlPa thNodeIterator xit) { return xit.Current.Loc alName; }
You have to call MoveNext() on XPathNodeIterat or each time you want next
node:
public string LocalName(XPath NodeIterator xit)
{
if (xit.MoveNext() )
return xit.Current.Loc alName;
else
return "";
}
--
Oleg Tkachenko [XML MVP] http://blog.tkachenko.com
Thanks, Oleg, but when I try that with the first example (XSLT:
select="util:Lo calName(.)") it returns false and .Current becomes null.
It's as if, in the first example, the iterator has already been "moved". Is
it that calling the extension object with (.) sends the XPathNodeIterat or
with a single node, whereas calling it with (child) sends a nodeset? If so,
is there a way of telling that MoveNext is going to move me off the end of
the set, before I move? (Or, even better, changing my XSLT so that I can be
sure that a single node is sent? I've tried /child[0] and /child/node() to
no avail.)
Thanks alot for the help.
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!P LEASEtkachenko. com> wrote in message
news:un******** ********@TK2MSF TNGP11.phx.gbl. .. Douglas Steen wrote:
public string LocalName(XmlPa thNodeIterator xit) { return xit.Current.Loc alName; }
You have to call MoveNext() on XPathNodeIterat or each time you want next node:
public string LocalName(XPath NodeIterator xit) { if (xit.MoveNext() ) return xit.Current.Loc alName; else return ""; }
-- Oleg Tkachenko [XML MVP] http://blog.tkachenko.com
Douglas Steen wrote: Thanks, Oleg, but when I try that with the first example (XSLT: select="util:Lo calName(.)") it returns false and .Current becomes null. It's as if, in the first example, the iterator has already been "moved". Is it that calling the extension object with (.) sends the XPathNodeIterat or with a single node, whereas calling it with (child) sends a nodeset? If so, is there a way of telling that MoveNext is going to move me off the end of the set, before I move? (Or, even better, changing my XSLT so that I can be sure that a single node is sent? I've tried /child[0] and /child/node() to no avail.)
Sorry, I can't reproduce the problem. Here is the stylesheet:
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="ur n:schemas-microsoft-com:xslt" xmlns:util="urn :my-scripts">
<msxsl:script language="C#" implements-prefix="util">< ![CDATA[
public string LocalName(XPath NodeIterator xit)
{
return xit.MoveNext()? xit.Current.Loc alName : "";
}
]]>
</msxsl:script>
<xsl:template match="/parent">
parent: <xsl:value-of select="util:Lo calName(.)"/>
child: <xsl:value-of select="util:Lo calName(child)"/>
grandchild: <xsl:value-of select="util:Lo calName(child/grandchild)"/>
</xsl:template>
</xsl:stylesheet>
When applied to your XML it outputs:
parent: parent
child: child
grandchild: grandchild
--
Oleg Tkachenko [XML MVP] http://blog.tkachenko.com
I'm using a rather complicated extension object (rather than doing it
inline), and in simplifying for this post, I may have gone too far. I used
your example and got the same results, but when I tried to add some of the
initial complexity, I ran into the problem again. While the example below
works, this one doesn't:
<xsl:template match="/parent">
<xsl:for-each select="child">
parent: <xsl:value-of select="util:Lo calName(../parent)"/>
child: <xsl:value-of select="util:Lo calName(.)"/>
grandchild: <xsl:value-of select="util:Lo calName(./grandchild)"/>
</xsl:for-each>
</xsl:template>
Thoughts?
Thanks for taking the time on this
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!P LEASEtkachenko. com> wrote in message
news:OC******** ******@TK2MSFTN GP10.phx.gbl... Douglas Steen wrote: Thanks, Oleg, but when I try that with the first example (XSLT: select="util:Lo calName(.)") it returns false and .Current becomes null. It's as if, in the first example, the iterator has already been "moved".
Is it that calling the extension object with (.) sends the
XPathNodeIterat or with a single node, whereas calling it with (child) sends a nodeset? If
so, is there a way of telling that MoveNext is going to move me off the end
of the set, before I move? (Or, even better, changing my XSLT so that I
can be sure that a single node is sent? I've tried /child[0] and /child/node()
to no avail.)
Sorry, I can't reproduce the problem. Here is the stylesheet:
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" xmlns:msxsl="ur n:schemas-microsoft-com:xslt" xmlns:util="urn :my-scripts"> <msxsl:script language="C#" implements-prefix="util">< ![CDATA[ public string LocalName(XPath NodeIterator xit) { return xit.MoveNext()? xit.Current.Loc alName : ""; } ]]> </msxsl:script> <xsl:template match="/parent"> parent: <xsl:value-of select="util:Lo calName(.)"/> child: <xsl:value-of select="util:Lo calName(child)"/> grandchild: <xsl:value-of select="util:Lo calName(child/grandchild)"/> </xsl:template> </xsl:stylesheet>
When applied to your XML it outputs:
parent: parent child: child grandchild: grandchild
-- Oleg Tkachenko [XML MVP] http://blog.tkachenko.com
On a hunch, I tried this:
<xsl:template match="/parent">
<xsl:variable name="parentNod e" select="."/>
<xsl:for-each select="child">
parent: <xsl:value-of select="util:Lo calName($parent Node)"/>
child: <xsl:value-of select="util:Lo calName(.)"/>
grandchild: <xsl:value-of select="util:Lo calName(./grandchild)"/>
</xsl:for-each>
</xsl:template>
and it _does_ work. Whereas calling the parent directly (..) doesn't?
Alright, now I've got something I can use; thanks for all your help. If you
(or anyone else) wants to clear up what's going on here, I'd love to
understand this better, but I can move forward now & I thank you.
"Douglas Steen" <du*@pobox.co m> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. I'm using a rather complicated extension object (rather than doing it inline), and in simplifying for this post, I may have gone too far. I
used your example and got the same results, but when I tried to add some of the initial complexity, I ran into the problem again. While the example below works, this one doesn't:
<xsl:template match="/parent"> <xsl:for-each select="child"> parent: <xsl:value-of select="util:Lo calName(../parent)"/> child: <xsl:value-of select="util:Lo calName(.)"/> grandchild: <xsl:value-of select="util:Lo calName(./grandchild)"/> </xsl:for-each> </xsl:template>
Thoughts?
Thanks for taking the time on this
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!P LEASEtkachenko. com> wrote in message news:OC******** ******@TK2MSFTN GP10.phx.gbl... Douglas Steen wrote: Thanks, Oleg, but when I try that with the first example (XSLT: select="util:Lo calName(.)") it returns false and .Current becomes
null. It's as if, in the first example, the iterator has already been
"moved". Is it that calling the extension object with (.) sends the XPathNodeIterat or with a single node, whereas calling it with (child) sends a nodeset?
If so, is there a way of telling that MoveNext is going to move me off the
end of the set, before I move? (Or, even better, changing my XSLT so that I can be sure that a single node is sent? I've tried /child[0] and
/child/node() to no avail.)
Sorry, I can't reproduce the problem. Here is the stylesheet:
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" xmlns:msxsl="ur n:schemas-microsoft-com:xslt"
xmlns:util="urn :my-scripts"> <msxsl:script language="C#" implements-prefix="util">< ![CDATA[ public string LocalName(XPath NodeIterator xit) { return xit.MoveNext()? xit.Current.Loc alName : ""; } ]]> </msxsl:script> <xsl:template match="/parent"> parent: <xsl:value-of select="util:Lo calName(.)"/> child: <xsl:value-of select="util:Lo calName(child)"/> grandchild: <xsl:value-of select="util:Lo calName(child/grandchild)"/> </xsl:template> </xsl:stylesheet>
When applied to your XML it outputs:
parent: parent child: child grandchild: grandchild
-- Oleg Tkachenko [XML MVP] http://blog.tkachenko.com
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: J Peterman |
last post by:
Im having a nightmare trying to understand these nodes and linked lists.
I've posted my code for my node.h, node.cpp, linkedlist.h and linkedlist.cpp
files in separates replies.
Can someone explain to me how I create a list and traverse it?
In particular, how do I make use of the node.h method GetNext()? I don;t
know what to do with it.
|
by: Chuck |
last post by:
What's the difference between using "catalog node" and catalog admin node"?
--
Chuck
Remove "_nospam" to reply by email
|
by: stabbert |
last post by:
We are running DB2 UDB 8.1.6 in a partitioned environment where we have
8 physical nodes. We have a process that remotely connects to each
individual node and loads some data. By setting the DB2NODE variable
to a different value then the coordinator node is the only way I am
aware for a remote application to do this so I am making the assumption
that is how this application connects. What I am more interested in is
that after logging...
|
by: Francois Grieu |
last post by:
Given that next is the first field in struct node,
and head is a pointer to node,
does assigning ((node*)&head)->next safely assign head ?
Illustration (this code works on many platforms)
#include <stdlib.h>
#include <stdio.h>
|
by: Jeroen Ceuppens |
last post by:
I need to put a new node at the end of the tree, that end is not te lowest
in de list but the deepest
(the one with the most + before it)
Node A
Node 1
Node 2
Node 3
Node 4: Deepest
Node B: not this one
| |
by: Saradhi |
last post by:
Hi All,
Here I am facing a performance problem with the TreeView Node renaming.
I am displaying a hierarchy Data in a treeview in my Windows C# Application.
My tree view represents an hierarchical view of Parent Nodes and projects where in a projectnode can be added to any ParentNode and hence we may have a project node added to 100 Parent nodes.
In this one, I have an operation of Renaming a Project Node. So whenever I am doing the...
|
by: poldoj |
last post by:
Hi all, I have a treenode control and I would like to add a node in a
certain level as child. For example I know that with this code I can add a
level one node plus a level two node:
-------------------
Dim node As TreeNode
node = TreeView1.Nodes.Add("Level one node")
node.Nodes.Add("Level two node")
-------------------
|
by: Moses |
last post by:
Hi All,
How to check weather a node has sibling? Is there any function
like " hasChildNodes() "
Thanks in Advance
Moses
|
by: Kane |
last post by:
When you create node 1 you allocate memory and link it Again when you
create node 2 you would allocate memory for that node in a different
section of the code. Is there more efficient way where I can allocate
memory once and use it to create new node in list.
-Thanks
-Kane
|
by: matth |
last post by:
I've been working on something that deals with handling a user's
selection within the DOM and I'm tripping up on one last, but crucial,
detail.
Forgive me for the length of the code, but my question is pretty
straightforward and my brain hasn't been working.
Problem: The way I'm iterating through the nodes doesn't allow me to
preserve the node hierarchy.
Instead of:
|
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...
| |
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,...
|
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,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |