Subject: Re: [xsl] 2 problems with variables(include & frame) From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 30 Apr 2002 11:20:58 +0100 |
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 &. XSLT stylesheets must be well-formed XML documents. So you need to use: <frame ..... src="/dir/myfile.jsp?lang={$lang}&grp={$grp}"/> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] 2 problems with variables(inc, longjohn | Thread | RE: [xsl] 2 problems with variables, Michael Kay |
RE: [xsl] 2 problems with variables, Jarno . Elovirta | Date | [xsl] How do i check null values in, Suman . Sathyanaraya |
Month |