Re: [xslt] text() problem




jawalsh@indiana.edu wrote:

>Hi all,
>
>I am having difficulty with a template that uses "text()".  I am using
>the most recent stable versions of libXML and libXSLT (as of
>2001-01-18) via the XML::LibXML and XML::LibXSLT Perl modules.
>
>With xml:
>
><?xml version="1.0"?>
><title rend="fs-italic">
>Romeo and <pb n="70" header="Shakespeare"/>Juliet
></title>
>
>And stylesheet:
>
><?xml version="1.0"?>
>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>
><xsl:template match="/">
><xsl:apply-templates/>
></xsl:template>
>
><xsl:template match="pb">
><hr class="page"/>
><p class="page">
><xsl:value-of select="./@n"/>
><br/>
><xsl:value-of select="./@header"/>
></p>
>
<xsl:apply-templates select="title" />

>
></xsl:template>
>
><xsl:template match="title">
><xsl:apply-templates/>
></xsl:template>
>
><xsl:template match="title/text()">
><strong><xsl:value-of select="."/></strong>
></xsl:template>
>
></xsl:stylesheet>
>
>I get output of:
>
><?xml version="1.0"?>
>Romeo and <hr class="page"/><p class="page">70<br/>Shakespeare</p>Juliet
>
>I believe I should get the following (which is what I get from Xalan):
>
><?xml version="1.0"?>
><strong>Romeo and </strong><hr class="page"/><p class="page">70<br/>Shakespeare</p><strong>Juliet</strong>
>
>I've searched around the archives and libxslt docs but can't find any
>indication that this shouldn't work as expected.  Thanks for
>listening.
>
>John
>| John A. Walsh, Manager, Electronic Text Technologies
>| Digital Library Program / University Information Technology Services (UITS)
>| Indiana University, 1320 East Tenth Street, Bloomington, IN 47405
>| Voice:812-855-8758 Fax:812-856-2062 <mailto:jawalsh@indiana.edu>
>
>_______________________________________________
>xslt mailing list, project page http://xmlsoft.org/XSLT/
>xslt@gnome.org
>http://mail.gnome.org/mailman/listinfo/xslt
>
i try this stuff and then drop it for a month, then try to get back into it,
then leave it, then come back ----  there is a lot of detail !!!

i thougth the apply-templates tag should be called apply-template 
because it doesnt trickle down the way you have it coded, you have to 
keep calling it after you match, so, you may end up doing:


<xsl:template match="/">
<xsl:apply-templates select="pb"/>
<xsl:apply-templates select="title"/>
</xsl:template>

of course i could be out to lunch - i am just learning too!

darrell








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]