match uncaught though declared in XSL

Here should go questions about transforming XML with XSLT and FOP.
sunnykeerthi
Posts: 3
Joined: Wed Oct 23, 2013 9:07 am

match uncaught though declared in XSL

Post by sunnykeerthi »

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: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: match uncaught though declared in XSL

Post by Patrik »

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
Post Reply