Re: [xslt] XInclude-processing in XSL stylesheets (was:Implementation of unparsed-text() (XSLT 2.0)?)
- From: "Buchcik, Kasimier" <k buchcik 4commerce de>
- To: "The Gnome XSLT library mailing-list" <xslt gnome org>
- Subject: Re: [xslt] XInclude-processing in XSL stylesheets (was:Implementation of unparsed-text() (XSLT 2.0)?)
- Date: Wed, 23 Aug 2006 19:55:21 +0200
Hi,
Works for me with the CVS HEAD and the following scenario:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:param name="foo">
<xsl:variable name="bar">
<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
href="xinclude-inc.txt" parse="text"/>
</xsl:variable>
<xsl:message>XIncluded text: "<xsl:value-of
select="$bar"/>"</xsl:message>
<xsl:variable name="norm-bar" select="normalize-space($bar)"/>
<xsl:message>Normalized text: "<xsl:value-of
select="$norm-bar"/>"</xsl:message>
<xsl:choose>
<xsl:when test="$norm-bar = 'hello'">success</xsl:when>
<xsl:otherwise>failure</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:value-of select="$foo"/>
</xsl:template>
</xsl:stylesheet>
The file "xinclude-inc.txt" contains only the text "hello".
Result:
XIncluded text: "hello"
Normalized text: "hello"
<?xml version="1.0"?>
success
Your file seems to exist, since if it is not found, then
we'll get the following error message:
xinclude-1.xsl:8: element include: XInclude error :
could not load xinclude-inc.txt, and no fallback was found
Very vague question: does your referenced file really contain
the values you compare against? (Note that normalize-space()
does not change the case of letters)
Regards,
Kasimier
> -----Original Message-----
> From: xslt-bounces gnome org [mailto:xslt-bounces gnome org]
> On Behalf Of Daniel Leidert
> Sent: Wednesday, August 23, 2006 7:06 PM
> To: xslt gnome org
> Subject: [xslt] XInclude-processing in XSL stylesheets
> (was:Implementation of unparsed-text() (XSLT 2.0)?)
>
> Am Mittwoch, den 16.08.2006, 16:27 +0200 schrieb Daniel Leidert:
> > Am Mittwoch, den 16.08.2006, 09:54 -0400 schrieb Daniel Veillard:
> >
> > [XIncluding a text-file to a variable-content in XSLT]
> > > ah ! xinclude wasn't applied to the stylesheet itself
> only on documents.
> > > Can you test the attached patch ?
> >
> > Tested and it looks very good. The xi:include element is
> processed and I
> > observe the expected/wanted result.
> >
> > [..]
> > <xsl:variable name="system.paper.size"><xi:include
> href="file:///etc/papersize" parse="text"/></xsl:variable>
> > [..]
> > <xsl:text>Size: </xsl:text>
> > <xsl:value-of select="normalize-space($system.paper.size)"/>
> > [..]
> >
> > Result:
> >
> > [..] Size: a4 [...]
> >
> > Perfect. Many thanks!
>
> Hmm. I now tried to incorporate the things into docbook-xsl and found,
> that saxon/xerces and xalan/xerces work, but xsltproc still
> does not do,
> what I want it to do. Maybe you could check this again (I guess, the
> problem now is at a different place). What did I do: The docbook-xsl
> stylesheets define parameters with default values. I now want to
> determine a parameters default value from the content of
> /etc/papersize.
> Therefor I used the following code:
>
> > <xsl:param name="paper.type">
> > <xsl:variable name="debian.libpaper.paper.type">
> > <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
> href="/etc/papersize" parse="text"/>
> > </xsl:variable>
> > <xsl:variable name="debian.system.paper.type"
> select="normalize-space($debian.libpaper.paper.type)"/>
> > <xsl:choose>
> > <xsl:when test="$debian.system.paper.type = 'a0'">A0</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'a1'">A1</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'a2'">A2</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'a3'">A3</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'a4'">A4</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'a5'">A5</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'a6'">A6</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'a7'">A7</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'a8'">A8</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'a9'">A9</xsl:when>
> > <xsl:when test="$debian.system.paper.type =
> 'a10'">A10</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'b0'">B0</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'b1'">B1</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'b2'">B2</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'b3'">B3</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'b4'">B4</xsl:when>
> > <xsl:when test="$debian.system.paper.type = 'b5'">B5</xsl:when>
> > <xsl:when test="$debian.system.paper.type =
> 'letter'">USletter</xsl:when>
> > <xsl:otherwise>USletter</xsl:otherwise>
> > </xsl:choose>
> > </xsl:param>
>
> /etc/papersize contains
> a4
>
> So docbook-xsl should output, that it uses an A4 size for the paper
> size. But I always get USletter, because $debian.libpaper.paper.type
> seems to be empty. My fault or a limitation of xsltproc?
>
> Regards, Daniel
>
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt gnome org
> http://mail.gnome.org/mailman/listinfo/xslt
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]