Subject: RE: msxsl:script and selectSingleNode problem
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 3 Oct 2003 23:22:39 +0100
|
The parameter you have passed to your function is the root node, which
is the parent of the Items element. The root node does not have a child
called "book".
Michael Kay
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Murali Korrapati
> Sent: 03 October 2003 21:08
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: msxsl:script and selectSingleNode problem
>
>
> Hi,
> I am getting this strange problem. Let me give my xml and
> script function before I explain my problem.
>
> my xml:
>
> <Items>
> <book>My book Title</book>
> <pencil>My pencil length</pencil>
> <pen>My pen color</pen>
> </items>
>
>
> my xslt:
> <xsl:stylesheet version="1.0" xmlns=""
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:msxsl="urn:schemas-microsoft-com:xslt"
> xmlns:scrdt="urn:reval-com:scripts:datatypes">
> <xsl:template match="/">
> <xsl:call-template name="callInit">
> <xsl:with-param name="itemNode"
> select="."/>
> </xsl:call-template>
> </xsl:template>
> <xsl:template name="callInit">
> <xsl:param name="itemNode"/>
> <xsl:value-of select="scrdt:init($itemNode)"/>
>
> </xsl:template>
> <msxsl:script language="JScript"
> implements-prefix="scrdt"><![CDATA[
> function init(itemNode)
> {
> if( !itemNode.length) return "";
>
> var val = itemNode.item(0).selectSingleNode('book');
>
> //var val = itemNode.item(0).firstChild;
>
> if(val!=null)
> return val.text;
>
> return "Error";
> }
> ]]></msxsl:script>
>
> </xsl:stylesheet>
>
>
> So my problem is, when ever I transform my xml with this
> template, it is printing "Error". It seems like it is not
> able to get to "book" node when I use
> selectSingleNode("book"). But variety is when ever I access
> it as .firstChild, it is recognizing the node and printing
> the correct value.
>
> I have no idea what is going on there. Any leads will be
> appreciated.
>
>
> ~Mur
>
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|