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]

Re: xsl:include, paramterizable?


Joel,

>I would like to dynamically specify attribute sets (defined
>in different xsl files) to include.
>
>So I thought I'd do something like:
>
><xsl:variable name"styles">defaultstyles.xsl</xsl:variable>
>
><xsl:include href="<xsl:value-of select={$styles}>"/>
>
>But, that didn't work (not terribly surprising).
>
>Nor did:
><xsl:include href=<xsl:value-of select="{$style}"/>/>

There are about three gaps in your understanding to tackle before looking
at how to dynamically specify attribute sets.

The first is to understand what a well-formed XML document looks like.
XSLT stylesheets have to be well-formed XML documents.  You cannot have
elements as attribute values; the thing that is giving you the error with
your statements is the XML parser, not the XSLT processor.

The second minor thing is to point out that you don't have to rely on
double quotes (") all the time: you can use single ones (') as well -
alternate between them when you want to quote something within quotes.
Attribute values always have to be quoted.

The third is to understand that the 'select' attribute on the xsl:value-of
element takes an XPath expression as a value.  That means that you
shouldn't place the XPath within {...}.  The {...} syntax indicates the use
of an attribute value template - this is used when the XSLT processor is
expecting a literal value for an attribute on a literal result element, but
you want it to compute it instead.

However, to answer your question: I'm afraid you cannot dynamically include
a stylesheet in another stylesheet.  To work within this, perhaps you could
try specifying multiple attribute sets and dynamically choosing which
attribute set to use on a particular element.  Alternatively, since the
names and values of the attributes in an attribute set are interpreted as
attribute value templates (i.e. you can put an XPath in {...} to give
dynamic names and values), you could try that approach.

If you would like a more concrete suggestion, then I recommend posting more
details of the transformation you want to make.

I hope this helps anyway,

Jeni

Dr Jeni Tennison
Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE
tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@epistemics.co.uk


 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]