xsl-list
[Top] [All Lists]

Re: [xsl] multiple input document question

2008-07-17 06:48:36
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(_at_)saxonica(_dot_)com> 
wrote:

I'm wondering if there is any way to do the following:

<xsl:template match="*[(_at_)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/



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





-- 
Greg Fausak
greg(_at_)thursday(_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>
--~--

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