Re: [xsl] multiple input document question

Subject: Re: [xsl] multiple input document question
From: "Greg Fausak" <lgfausak@xxxxxxxxx>
Date: Thu, 17 Jul 2008 08:48:07 -0500
Michael,

You must be psychic, because that's what I was asking!

For my purposes it would have been more elegant to put
the xpath information in one xml document which points
into another. It's easy enough if you put all of the logic in the
.xsl sheet, which is what I ended up doing.

Thank you,
-g


On Thu, Jul 17, 2008 at 2:45 AM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>>
>> I'm wondering if there is any way to do the following:
>>
>> <xsl:template match="*[@menu]">
>>         <xsl:variable name="id" select="@id"/>
>>         <xsl:for-each select="document('f1.xml')/$id"> ...
>
> You're asking us to work out what you want to do by showing us code that
> doesn't do it?
>
> Well, we're not psychic, but fortunately we've seen the same mistakes quite
> often, and I guess that what you had in mind is that the value of $id is an
> element name which you then want to substitute into the path expression.
> XSLT doesn't use variables to do textual substitution in the way that a
> shell-script language does - variables represent values, not fragments of
> expression text. What you want is probably
>
> document('f1.xml')/*[name()=$id]
>
> On the other hand it's possible that $id is not just an element name, but an
> entire XPath expression. In that case you either need to use the technique
> of generating a stylesheet, or you need an extension such as
> saxon:evaluate() - many XSLT processors have an equivalent but it's not in
> the standard.
>
> Either way, be careful about namespaces.
>
> Michael Kay
> http://www.saxonica.com/
>
>



-- 
Greg Fausak
greg@xxxxxxxxxxxx

Current Thread