Subject: RE: Xpath as variable, then processing it
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 31 Dec 2004 12:05:22 -0000
|
To evaluate an XPath expression held as a string, you need an extension
function such as dyn:evaluate().
Saxon 8.2 has a new form of this function, saxon:evaluate-node(), designed
for use when the XPath expression is held in a source document: it's
different from saxon:evaluate() in that it takes the namespace context from
the node in which the expression appears.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: michella@xxxxxxx [mailto:michella@xxxxxxx]
> Sent: 31 December 2004 11:39
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Xpath as variable, then processing it
>
> Hi all,
>
> I have a little question :
>
> I have a small XML Data containing in one of its field an Xpath (as
> text) which should be used in an XSL-T for querying data in
> another XML
> using this XPath. The following XSL handles it as a variable.
>
> <Classes>
> <Class>
> <Architecture name="Application" abr="AA">
> <xsl_File name="App_Apt_Apx_Applications"
>
> file="App_Apt_Apx_Applications.xsl"
>
> XPath="/Classes/Class/SADefinition[starts-with(@SAObjName,'app_') or
> starts-with(@SAObjName,'apx_') or starts-with(@SAObjName,'apt_')]"/>
> (...)
>
> Then, the XSL file looks as follow :
>
> <xsl:stylesheet version="1.1"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:variable name="mainXML_node"
> select="document('../XML/PM-EA-AA_IA_PA_TA.xml')"/> (The main XML)
> <xsl:output method="html" version="1.0" encoding="UTF-16"
> indent="yes"/>
> <xsl:template match="/">
> <xsl:result-document
> href="../TCL/Temp/TCL_Data_Config.tmp">
> <xsl:value-of disable-output-escaping="yes"
> select="'{'"/>
> <xsl:for-each-group
> select="/Classes/Class/Architecture" group-by="@name">
> <xsl:sort select="@name"/>
> <xsl:value-of
> disable-output-escaping="yes" select="concat('{',@name,' ')"/>
> <xsl:for-each-group select="xsl_File"
> group-by="@name">
> <xsl:sort select="@name"/>
> <xsl:variable name="path"
> select="@XPath"/>
> <xsl:value-of
> disable-output-escaping="yes" select="concat('{',@name,' ')"/>
> <xsl:for-each
> select="$mainXML_node"> (Here is the problem)
> <xsl:for-each-group
> select="$path" group-by="@SAObjName">
> <xsl:sort
> select="@SAObjName"/>
> (...)
>
>
>
> I hope the upon the text is correctly indented by your mail browser.
>
> Unfortunately, it won't work. Have anyone got an idea on how
> to solve my
> problem?
>
> Best regards
>
> Lawrence
|