xsl-list
[Top] [All Lists]

RE: [xsl] saxon:evaluate and external documents

2007-04-13 19:58:23
I managed to get the saxon:evaluate to work with the external doc with
the following:

 
<xsl:for-each select="$compare_file">
      <xsl:value-of select="saxon:evaluate($value_xpath)" />
</xsl:for-each>

This retrieves the value from the compare_file, but seems a bit of a
hack to me. 

Any cleaner solution possible?

thanks,
Scott


-----Original Message-----
From: Lynch, Scott (NCRTP:3798) 
Sent: Friday, April 13, 2007 6:24 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] saxon:evaluate and external documents

 
All,

I'm having problems with saxon:evaluate (Saxon 8.8) when using a
document reference. In a nutshell, I want to display the data in the
document being transformed along side the same type of data from an
external document. Both documents use the same structure, therefore I
want to use the same xpath to query the various data, but when I attempt
to use saxon:evaluate with the document variable in the string to
evaluate, it doesn't seem to process the document path properly (seems
to ignore the document portion of the path string altogether). Here's
the xslt:

The "new_and_old" template is called from the main template. Here's the
code snippet from the main template:

  <xsl:call-template name="new_and_old">
    <xsl:with-param name="value_xpath">foo/bar/@version</xsl:with-param>

  </xsl:call-template>


Here's the template I'm attempting to use to build output using data
from both sources.

  <xsl:template name="new_and_old">
    <xsl:param name="value_xpath"/>
    <xsl:variable name="compare_file" select="document('doc_2.xml')"/>
    <DataVersions>
      <xsl:value-of select="saxon:evaluate($value_xpath)"/>
      <xsl:text/>
      <!-- <xsl:value-of
select="saxon:evaluate(concat($compare_file,'/',$value_xpath))"/> -->
      <!-- <xsl:value-of select="saxon:evaluate($delta_xpath)"/> -->
      <!-- <xsl:value-of select="saxon:evaluate(concat('$contentDoc',
$p1), $path)"/> -->
      <!-- <xsl:value-of
select="saxon:evaluate(concat('$compare_file',$p1),$value_xpath)"/> -->
      <!-- <xsl:value-of select="saxon:evaluate(concat('$p1',
$value_xpath), $compare_file)"/> -->
      <!-- <xsl:value-of
select="$compare_file/saxon:evaluate($value_xpath)"/> -->
    </DataVersions>
  </xsl:template>


Both XML files (the one being transformed explicitly and the
compare_file) have the same structure. A simple example:

Source doc:
<foo>
  <bar version="1"/>
</foo>

Compare doc (doc_2.xml):
<foo>
  <bar version="2"/>
</foo>

The first saxon:evaluate function (uncommented) works fine. I've been
googling like mad and have tried lots of different saxon:evaluate calls
which include the $compare_file document variable, but none of them
work. The first commented example is the closest to working, but returns
the version value in the source document rather than the compare_file
document. I know there are restrictions for saxon:evaluate regarding
variables, but I can't seem to find the right web page which lays out
the restrictions (and any workarounds) in any detail.

Any help would be appreciated.

Scott Lynch


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--