Subject: [xsl] What is wrong with this XSLT? From: xslt.new <xslt.new@xxxxxxxxx> Date: Mon, 15 Jan 2007 15:36:34 -0600 |
Hi:
I have written an xslt and am having issues with axis specifiers. I will preent the sample input and xslt and explain the problem. Please let me know where I am going wrong.
Sample XML:
<list> <note><para>This is the first note.</para></note> <note><para>This is the second note. </para></note> <text><para>This is some text. </para></text> </list>
XSLT: <xsl:template match="note"> <xsl:choose> <xsl:when test="parent::list and position()=1"> </xsl:when> <xsl:otherwise> <fo:list-block> <fo:list-item> <fo:list-item-label> <fo:block font-weight="bold">NOTE: </fo:block> </fo:list-item-label> <fo:list-item-body start-indent="body-start()" end-indent="0pt"> <fo:block> <xsl:value-of select="."/> </fo:block> </fo:list-item-body> </fo:list-item> </fo:list-block> </xsl:otherwise> </xsl:choose> </xsl:template>
<xsl:template match="note/para"> <fo:inline border-left-width="0pt" border-right-width="0pt"> <xsl:apply-templates select="node()"/> </fo:inline> </xsl:template>
<!-- This is the template for list-->
<xsl:template match="list"> <xsl:if test="child::note"> <xsl:apply-templates select="note" mode="list"/> </xsl:if> </xsl:template>
<xsl:template match="note" mode="list"> <fo:list-block> <fo:list-item> <fo:list-item-label> <fo:block font-weight="bold">NOTE: </fo:block> </fo:list-item-label> <fo:list-item-body start-indent="body-start()" end-indent="0pt"> <fo:block> <xsl:value-of select="."/> </fo:block> </fo:list-item-body> </fo:list-item> </fo:list-block> </xsl:template> <xsl:template match="note/para" mode="list"> <fo:inline> <xsl:apply-templates select="node()" mode="list"/> </fo:inline> </xsl:template>
My desired output is:
NOTE: This is the first note. NOTE: This is the second note. 1. This is some text.
However, what happens is after the processor checks for the first position of note, it just dumps the second note element on to the number '1' - that is number '1' and NOTE overlap and the styling gets messy.
Can anyone help me resolve this issue? How can I tell the processor that after the first position of "note" check if there is another "note" element and if it is, then that should also be displayed above the text element on the output, following the first note element? So irrespective of the number of "note" elements inside the <list> element, they shoudl always be displayed above the <text> element as shown in the desired output. Please give me any ideas and suggestions.
Thanks in advance for your help.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Axis specifers, Michael Kay | Thread | Re: [xsl] What is wrong with this X, Abel Braaksma |
[xsl] Axis specifers, xslt . new | Date | Re: [xsl] What is wrong with this X, Abel Braaksma |
Month |