xsl-list
[Top] [All Lists]

[xsl] How to handle dynamic XPath

2009-04-12 15:08:00
Hi,

I am using XSLT to walk through an XML Schema to construct an Xforms (output) instance. In parallel I am scanning an (input) instance (of a document defined by the schema) to
include default values in the form.

Scanning of the input instance is done by means of a variable that keeps track of the path. The variable is updated (renewed) each time a template is (recursively) called with
the variable as parameter:

<xsl:with-param name="instance.path"
select="concat($instance.path,'/',$element.prefix,':',@name)" />

The template calls another template that writes the output instance. In that template I
try to look up the default value in the input instance (an external document).

BUT:

<xsl:value-of select="document('file:/C:/dir/order.xml')/$instance.path" />
writes a path string to the output instance instead of the value of the element, such as:
/rsm:PurchaseOrder/rsm:Identifier, so does copy-of select.

<xsl:value-of select="document('file:/C:/dir/order.xml')//rsm:DeliveryDate" />
writes correctly the content of the delivery date, but
<xsl:value-of select="document('file:/C:/dir/order.xml')//$deldate" />
(where $deldate contains the string "rsm:DeliveryDate") writes nothing.

Concluding the problem is node-format vs text format, I tried the saxon evaluate
function, but:
<xsl:copy-of select="saxon:evaluate(document('file:/C:/dir/order.xml')/$instance.path)" />
writes nothing, neither does value-of.

I am desperate. Does anyone have a clue how to solve this?

Thanks in advance,

Fred van Blommestein

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>