match uncaught though declared in XSL

Here should go questions about transforming XML with XSLT and FOP.
sunnykeerthi
Posts: 2

match uncaught though declared in XSL

Thu Dec 04, 2014 4:44 pm

I've the below XML.

Code: Select all

<para indent="no">
   <star.page>18</star.page> Further to same.
</para>

and when i run the below XSLT.

Code: Select all

<xsl:template match="para">

    <xsl:value-of select="./node()[1][self::star.page]|./label/node()[1][self::star.page]"/>
    <div>
        <xsl:choose>
            <xsl:when test="./@align">
                <xsl:attribute name="class"><xsl:text>para align-</xsl:text><xsl:value-of select="./@align"/></xsl:attribute>
            </xsl:when>
            <xsl:otherwise>
                <xsl:attribute name="class"><xsl:text>para</xsl:text></xsl:attribute>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:apply-templates/>
    </div>
</xsl:template>

When i run this, instead of printing <div class="para">18</div>, it is printing <div class="para"></div>

please let me know where am i going wrong and how can i fix this.

Thanks :( :(
Patrik
Posts: 228
Location: Hamburg/Germany

Re: match uncaught though declared in XSL

Tue Feb 10, 2015 9:21 am

Hi,

the code you posted only calls <xsl:apply-templates/> to deal with the content of the para element. So without any other templates the output would be

Code: Select all

<div class="para">
   18 Further to same.
</div>

This is due to the default-templates that only output all the text content.

Since your output is different I can only assume that your script contains additional templates (for instance for star.page) which you didn't post!?

To get the ourput you described you could replace the <xsl:apply-templates/> with <xsl:value-of select="star.page"/>.

regards

Patrik

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest