[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Convert String to (node-set)

Subject: RE: Convert String to (node-set)
From: mxmodi@xxxxxxxxxxxxxxx
Date: Mon, 5 Feb 2001 14:20:41 -0600
convert string to node
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@xxxxxxxxxxxx>               To:     <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>                                 
                    Sent by:                           cc:                                                                       
                    owner-xsl-list@xxxxxxxxxxxx        Subject:     RE:  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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.