This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Convert String to (node-set)
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: [xsl] Convert String to (node-set)
- From: mxmodi at duke-energy dot com
- Date: Tue, 6 Feb 2001 12:21:04 -0600
- Reply-To: xsl-list at lists dot mulberrytech dot com
Thank you so much, it works! (of course it does...). Now I am moving to the
next step. I am trying to integrate my XSL (with a Saxon extension
function) in my Java program which uses a the XALAN processor. I know I
should just switch everything to Saxon, unfortunately, I do not have
complete access now to do it.
So, the obvious Q is, how do I integrate a SAXON extension fn. when I want
to use XALAN (LAtest release, 2.0) from my JAVA program. This is what I
have tried so far:
XSL code snippets:
1. Eg.1
<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://icl.com/saxon"
exclude-result-prefixes="saxon">
<xsl:template match ="/">
<xsl:value-of select="saxon:evaluate(some str)" />
</xsl:template>
</xsl:stylesheet>
This works perfectly fine with the SAXON 6.1 processor from command line.
However, I get an error when I try to run it from XALAN.
2. Eg. 2
<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://icl.com/saxon"
exclude-result-prefixes="saxon">
<xsl:template match ="/">
<xsl:value-of select="saxon:functions.Extensions.evaluate(some str)" />
</xsl:template>
</xsl:stylesheet>
Same error as in 1.
3. Eg. 3
<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform" xmlns:saxon
="http://icl.com/saxon.functions.Extensions" exclude-result-prefixes
="saxon">
<xsl:template match ="/">
<xsl:value-of select="saxon:evaluate(some str)" />
</xsl:template>
</xsl:stylesheet>
same error as in 1 and 2.
4. Eg. 4
<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform" xmlns:saxon
="xmlns:saxon=http://icl.com/saxon" exclude-result-prefixes="saxon">
<xsl:template match ="/">
<xsl:value-of select="saxon:evaluate(some str)" />
</xsl:template>
</xsl:stylesheet>
same error as in 1,2,3 above.
Any suggestions? I know I need to make the proper reference to the
extension fn. from Xalan, but how?
Thanks for all the help.
Maulik
"Michael Kay"
<mhkay@iclway.co.uk> To: <xsl-list@lists.mulberrytech.com>
Sent by: cc:
owner-xsl-list@lists.mulber Subject: RE: [xsl] Convert String to (node-set)
rytech.com
02/06/2001 04:53 AM
Please respond to xsl-list
I think you want something like:
> <xsl:for-each select="$node/Node_path">
<xsl:variable name="xpath" select="."/>
<xsl:for-each select="$chandoc">
> <xsl:text>The Value retrieved from doc 2 is:
> </xsl:text><xsl:value-of
> select="saxon:evaluate($xpath)" />
</xsl:for-each>
> </xsl:for-each>
The inner for-each is just to change the context node to the $chandoc
document, so that the evaluate() applies the path expression to this
document.
Mike Kay
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of
> mxmodi@duke-energy.com
> Sent: 05 February 2001 20:21
> To: xsl-list@lists.mulberrytech.com
> Subject: RE: [xsl] Convert String to (node-set)
>
>
>
> Hi,
>
> All I am trying to do is parse a XML doc1, extract a
> particular node value
> from XML doc 1and then pass this string as an XPATH expression to be
> evaluatedin a separate XML doc 2. Any help is appreciated.
>
> My XML doc1 (called BER.xml in the stylesheet) is:
>
> <CHANNEL>
> <EVENT name="steve14nov">
> <NODE>
>
> <Node_path>//DATA/PARAMETERS/PARAMETER/TimeSheet/EmpUserID</Node_path>
> <Node_value>txtester</Node_value>
>
> <Node_path>//DATA/PARAMETERS/PARAMETER/TimeSheet/BeginWeek</Node_path>
> <Node_value>11/14/01</Node_value>
> <URL>http://sdangel04/tms?template=</URL>
> </NODE>
> <NODE>
>
> <Node_path>//DATA/PARAMETERS/PARAMETER/TimeSheet2/EmpUserID2</
> Node_path>
> <Node_value>txtester2</Node_value>
>
> <Node_path>//DATA/PARAMETERS/PARAMETER/TimeSheet/BeginWeek</Node_path>
> <Node_value>11/14/02</Node_value>
> <URL>http://sdangel04/tms?template=2</URL>
> </NODE>
> </EVENT>
> </CHANNEL>
>
> A snippet of my XSL used to parse this doc1 is:
>
>
> <xsl:stylesheet version="1.0" xmlns:xsl="
> http://www.w3.org/1999/XSL/Transform"
> xmlns:saxon="http://icl.com/saxon">
> <xsl:variable name="node"
> select="document('BER.xml')/CHANNEL/EVENT/NODE"
> />
> <xsl:variable name="chandoc" select="document('TSInsertBER.xml')" />
>
> <xsl:template match="/">
> <xsl:for-each select="$node//Node_path">
> <xsl:text>The Value retrieved from doc 2 is:
> </xsl:text><xsl:value-of
> select="saxon:evaluate($chandoc/.)" />
> </xsl:for-each>
> </xsl:template>
> <xsl:stylesheet>
>
> My XML doc 2 (TSInsertBER.xml in the stylesheet) is as follows:
> <MESSAGE>
> <DATA>
> <PARAMETERS>
> <PARAMETER>
> <TimeSheet>
> <EmpUserID>txtester2</EmpUserID>
> <BeginWeek>01/08/01</BeginWeek>
> <EndWeek>01/14/01</EndWeek>
> <Sun>1</Sun>
> <Mon>2</Mon>
> <Tue>3</Tue>
> <Wed>4</Wed>
> <Thu>5</Thu>
> <Fri>6</Fri>
> <Sat>7</Sat>
> <LastDate>01/01/01</LastDate>
> <UpdateUserId>admin</UpdateUserId>
> </TimeSheet>
> </PARAMETER>
> </PARAMETERS>
> </DATA>
> </MESSAGE>
>
>
>
>
>
>
> "Michael Kay"
>
> <mhkay@iclway.co.uk> To:
> <xsl-list@lists.mulberrytech.com>
> Sent by: cc:
>
> owner-xsl-list@lists.mulber
> Subject: RE: [xsl] Convert String to (node-set)
>
> rytech.com
>
>
>
>
>
> 02/05/2001 11:15 AM
>
> Please respond to xsl-list
>
>
>
>
>
>
>
>
> > I tried using the saxon"evaluate function. However, I got
> an error in
> > expression when I processed the XSL using Saxon 5.4. What am
> > I missing?
> >
> > Snippet of XSL code:
> >
> > <xsl:variable name="chandoc"
> select="document('TSInsertBER.xml')" />
> >
> > <xsl:template match="/">
> > <xsl:for-each select="$node//Node_path">
> > <xsl:text>The Value retrieved from doc 2 is:
> > </xsl:text><xsl:value-of
> > select="saxon:evaluate($chandoc/.)" />
> > </xsl:for-each>
> > </xsl:template>
>
> Several points:
> 1) $chandoc/. means exactly the same as $chandoc
> 2) The expression you are trying to evaluate is the text contents of
> document TSInsertBER.xml, which you haven't shown us
> 3) Whatever the result of the saxon:evaluate(), it will be
> exactly the same
> each time round the <xsl:for-each> loop, because there's
> nothing inside the
> loop that depends on the current node.
>
> Mike Kay
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
>
>
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list