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
"Douglas Steen" <dug@pobox.com> wrote in message
news:%23hDJqrBaEHA.2840@TK2MSFTNGP11.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:LocalName(../parent)"/>
> child: <xsl:value-of select="util:LocalName(.)"/>
> grandchild: <xsl:value-of select="util:LocalName(./grandchild)"/>
> </xsl:for-each>
> </xsl:template>
>
> Thoughts?
>
> Thanks for taking the time on this
>
>
> "Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
> news:OCtMJWBaEHA.4052@TK2MSFTNGP10.phx.gbl...
> > Douglas Steen wrote:
> > > Thanks, Oleg, but when I try that with the first example (XSLT:
> > > select="util:LocalName(.)") 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
> XPathNodeIterator
> > > 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:stylesheet version="1.0"
> > xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" > > xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:util="urn:my-scripts">
> > <msxsl:script language="C#" implements-prefix="util"><![CDATA[
> > public string LocalName(XPathNodeIterator xit)
> > {
> > return xit.MoveNext()? xit.Current.LocalName : "";
> > }
> > ]]>
> > </msxsl:script>
> > <xsl:template match="/parent">
> > parent: <xsl:value-of select="util:LocalName(.)"/>
> > child: <xsl:value-of select="util:LocalName(child)"/>
> > grandchild: <xsl:value-of select="util:LocalName(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 >
>