This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: Re: DOCBOOK: Conditional xsl:output ? Help
- To: jkj at kosek dot cz, sbline at apsydev dot com
- Subject: Re: DOCBOOK-APPS: Re: DOCBOOK: Conditional xsl:output ? Help
- From: Bob Stayton <bobs at sco dot COM>
- Date: Mon, 09 Oct 2000 09:14:45 -0700 (PDT)
- Cc: docbook-apps at lists dot oasis-open dot org
> From: Jirka Kosek <jkj@kosek.cz>
>
> On Mon, 9 Oct 2000, [iso-8859-1] St=E9phane Bline wrote:
>
> > <xsl:variable name=3D"lang-attr"
> > select=3D"($target/ancestor-or-self::*/@lang
> >=20
> > |$target/ancestor-or-self::*/@xml:lang)[last()]"/>
> > <xsl:choose>
> > <xsl:when test=3D"string($lang-attr) =3D 'pl'">
> > <xsl:output encoding=3D"ISO-8859-2"/>
> > </xsl:when>
> > <xsl:otherwise>
> > <xsl:output encoding=3D"ISO-8859-1"/>
> > </xsl:otherwise>
> > </xsl:choose>
> >=20
> > Unfrotunately, this does not work. Is this something that XSL can't=
> do or am
> > I doing it the wrong way ?
>
> <xsl:output/> must be nested directly in the root element, you can no=
> t use
> it in templates.
>
> I know two solutions to your problem, but none of them is standard an=
> d
> crossplatform.
>
> 1. Use extension of XSLT processor which are able to produce multiple
> output documents (this supports XT, Saxon, Xalan and probably other
> engines). Then use something like this
>
> <xsl:template match=3D"/">
> <xsl:param name=3D"firstTime">1</xsl:param>
> <xsl:if test=3D"$firstTime =3D '1'">
> ... there comes switches between encodings ...
> <xt:output method=3D"..." encoding=3D"...">
> <xsl:apply-templates select=3D"/">
> <xsl:with-param name=3D"firtsTime">0</xsl:with-param>
> </xsl:apply-templates>
> </xt:output>
> ....
> </xsl:if>
> <xsl:if test=3D"$firstTime =3D '0'">
> ... there goes normal processing of root
> </xsl:if>
> </xsl:template>
>
> I did not test it, but I hope it works.
>
> 2. Some XSLT processor can use expressions in encoding atribute of
> <xsl:output>. I know this is supported by Saxon. To enable this futur=
> e,
> you must provide some Saxon specific attribute to <xsl:output>. I do =
> not
> remember details, but it is described in Saxon docs.
The XSLT specification says that the <xsl:output> element
is a top-level element, so it can only appear as a child of
<xsl:stylesheet>. That means it probably won't work inside
of a template. Your best bet is some sort of extension
function as mentioned in option 2.
Is outputting utf-8 not an option?
If this is HTML, recent versions of browsers can
supposedly handle utf-8.
bobs