This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: import href vaule set using Xpath
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Aedemar Cooke" <Aedemar dot Cooke at kadius dot com>
- Cc: XSL-List at lists dot mulberrytech dot com
- Date: Mon, 25 Feb 2002 15:55:54 +0000
- Subject: Re: [xsl] import href vaule set using Xpath
- Organization: Jeni Tennison Consulting Ltd
- References: <3B7D547A6325404B8617DCFC427B13C92CC91D@kadiusexch1.kadius.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Aedemar,
>> can the value of the href attributes of the xsl:import command be set
>> using XPath notation?
>>
>> I would like to retrieve the value of the stylesheet to import from
>> the Xml document.
>>
>> I tried <xsl:import href="{//stylesheetname}"/> and got the error that
>> it couldn't find {//stylesheetname}.
As Ken has said, you can't do this within a single stylesheet.
However, you can turn the process into a two-stage process where the
first stage generates the stylesheet you need for the second stage:
generator -> stylesheet
^ |
| v
XML document -> process -> result
The "generator" in the above diagram can be anything from a piece of
code that manipulates the stylesheet that you have as a DOM, to
create the stylesheet that you want, to a full XSLT stylesheet that
generates the stylesheet that you're after.
Another design that you might consider is to embed the xsl:import
within the XML document itself, using an embedded stylesheet as
follows:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="#style"?>
<!DOCTYPE doc [
<!ATTLIST xsl:stylesheet id ID #REQUIRED>
]>
<doc>
...
<xsl:stylesheet id="style" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="doc-specific-stylesheet.xsl" />
<xsl:import href="general-stylesheet.xsl" />
<xsl:template match="xsl:stylesheet" />
</xsl:stylesheet>
...
</doc>
This pattern doesn't work with all processors (specifically, it
doesn't work with MSXML).
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list