This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Variable names *as* variables
- To: xsl-list at mulberrytech dot com, "XSL List" <xsl-list at mulberrytech dot com>
- Subject: Re: Variable names *as* variables
- From: "John E. Simpson" <simpson at polaris dot net>
- Date: Thu, 12 Oct 2000 19:26:35 -0400
- References: <4.3.2.7.2.20001012115117.00b29620@nexus.polaris.net>
- Reply-To: xsl-list at mulberrytech dot com
At 01:44 AM 10/13/2000 +0400, Nikolai Grigoriev wrote:
> > I have a feeling that what I'm trying to do can't be done without
> > extensions, like Saxon's eval. Unfortunately I can't use an extension
> > function for this case, and thought I'd fly it past the list to see if any
> > of you have a brainstorm.
>
>Yet it can be done without any extensions. Try to apply the following
>stylesheet
>to your <someroot> sample. The key idea is that document('') returns the
>root of
>the stylesheet itself; in this way, you can address pieces of the
>stylesheet as
>if they were elements in the source document.
Oooh, this solution is very clever. I don't think I'm going to use it in
this case, but will definitely add it to the arsenal for further exploration!
>However, I think it isn't a good idea to intersperse style with data. IMO, you
>should better put your location data into a separate XML file, marking
>them with
>normal markup instead of xsl:variables. Then you can access them using
>document() function, in the same way that I used to extract these data
>from the
>stylesheet.
I too thought of using such a "driver file." And as a general solution, I
like it quite a bit. In this case, though, I was attempting to demonstrate
(possibly to newbies) just the use of variables, and didn't want to cloud
the waters further by invoking the document() function. Although obviously
I wasn't above trying to cloud them with a bit of string hacking. :)
Just out of curiosity, in what sense do you consider your proposed solution
to be "interspersing style with data"? Granted it's something of a hack --
providing data in the stylesheet that's not in the source document -- but
only in the sense that *any* literal result element does so, no?
Thanks very much, Nikolai. (And thanks also to Ken Meltsner, whose solution
was even sneakier!)
===============================================================
John E. Simpson | "He asked me if I knew what
http://www.flixml.org | time it was. I said, 'Yes, but
XML Q&A: http://www.xml.com | not right now.'" (Steven Wright)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list