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: 2 problems with variables(include & frame)


Hi,

> (I'm using XALAN-XERCES)
> FIRST:
> ...
> <xsl:param name="lang"/>
> <xsl:include href="/dir/myfile{@lang}.xsl"/>   <!-- myfileen.xsl , 
> myfilefr.xsl , myfileit.xsl , etc -->
>
> --> {@lang} (and {$lang} too) doesn't work , '{' not allowed if I
> try <xsl:if test=....> , it appears not allowed in this position of
> the style-sheet

Attribute value templates -- expressions held in {}s -- are only
allowed in certain places within an XSLT stylesheet. Those places are
the attributes on literal result elements (such as in your second
example) and *some* attributes on XSLT elements, but only those that
hold literal values, such as the 'data-type' attribute on xsl:sort.

You can't use attribute value templates in any attribute that holds an
expression (such as the test attribute of xsl:if), or a name, or in
the href attribute of xsl:include or xsl:import.

You cannot conditionally include or import another stylesheet module
in XSLT. Instead, what you should do is have a two stage process where
the first stage creates, through some mechanism, the stylesheet that
you want to use for the actual transformation.

You can create the stylesheet in several ways. One is to use another
stylesheet -- create some XSLT to create the XSLT that you want.
Another is to write code that reads in the basic XSLT stylesheet, and
alters the value of the href attribute of the xsl:include during that
read (if you're using SAX) or after the stylesheet has been read in
(using DOM), then pass that revised stylesheet on to the
transformation.

> SECOND:
> ....
> <frame .....   src="/dir/myfile.jsp?lang={$lang}&grp={$grp}"/>
>
> --> 'lang={$lang}'  works , but '&' not allowed (escape character?)

According to the basic XML well-formedness rules, an ampersand
character must always be escaped with &amp;. XSLT stylesheets must be
well-formed XML documents. So you need to use:

<frame .....   src="/dir/myfile.jsp?lang={$lang}&amp;grp={$grp}"/>

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]