RE: [xsl] saxon:evaluate from external to current source

Subject: RE: [xsl] saxon:evaluate from external to current source
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 8 May 2007 21:36:36 +0100
I'm guessing, but I imagine that the feedback element is the outermost
element of the source.xml document and this is the principal input document
of your stylesheet.

If I've guessed correctly, then you want a global variable

<xsl:variable name="root" select="/">

and you then want to do:

<xsl:for-each select="$formfields/field">
    <xsl:variable name="currpath" as="xs:string" select="@srcPath"/>
    <xsl:apply-templates select="$root/saxon:evaluate($currpath)"/>
</xsl:for-each>
 
Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Matt Stoeffler [mailto:mstoef@xxxxxxxxx] 
> Sent: 08 May 2007 20:37
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] saxon:evaluate from external to current source 
> 
> There was a posting in April--see http://www.biglist.com/lists/xsl-
> list/archives/200704/threads.html#0022-- in which a question 
> was posed about establishing proper context for 
> saxon:evaluate for an  
> external document. I have a problem that inverts that one somewhat.   
> I'm working on xsl that uses a reference xml file to direct 
> the order in which to process a source document.  So, when 
> processing source.xml, I reference an external map.xml, which 
> looks like this ...
> 
> <field-map form="Secondary School Participation"> <field 
> srcPath="feedback/nameInfo/title"  
> resId="courtesyTitle">Courtesy Title</field> <field 
> srcPath="feedback/nameInfo/name" 
> resId="nameHead">Name</field> <field 
> srcPath="feedback/nameInfo/email" resId="emailHead">Email</field>
> 
> ...
> </field-map>
> 
> The reference map.xml tells me what source nodes to process 
> in what order.  My problem arises when I change context in 
> the xsl file ...
> 
> where $formfields gets me the nodeset from the external 
> document I want, depending on the form I want to process.
> 
> <xsl:for-each select="$formfields/field">
>     <xsl:variable name="currpath" as="xs:string" select="@srcPath"/>
>     <xsl:apply-templates select="/saxon:evaluate($currpath)"/>
>   </xsl:for-each>
> 
> 
> ... problem is, the saxon:evaluate fails because, I suspect, 
> I'm in the wrong document context.  How can I tell my 
> apply-templates instruction to evaluate the path in the 
> source document?
> 
> thanks.
> 
> Matt.

Current Thread