This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: import href vaule set using Xpath


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]