Hi all:
I have an XML in this format:
<level1>
<note><Para>Some note here</para></note>
<text><para>Text here</para></text>
<note><para>Note again</para></note>
</level1>
Now, there can be 6 levels level1...level6 and style sheet is formatted for
them to have numbered or alphabetincal levels like 1. A. etc.
My XSLT for level1 template checks if note is the first child of <level1>
and if it is, then it displayes it at the top of the level, and if not it is
supposed to diplay it wherever it is.
XSLT:
<xsl:template match="level1">
<xsl:if test="child::*[1][self::note]">
<xsl:apply-templates select="note" mode="level1"/>
</xsl:if>
<...code fo formatting...>
</xsl:template>
At the <note> level the template is:
<xsl:template match="note">
<xsl:choose>
<xsl:when
test="parent::level1|parent::level2|parent::level3|parent::level4|parent::level5|parent::level6">
</xsl:when>
<xsl:otherwise>
<fo:list-block keep-with-previous.within-page="always"
keep-together.within-page="always" space-before="6pt" start-indent="0mm"
provisional-distance-between-starts="13mm">
<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>
----------------------------------------------------------------------------------------------
<xsl:template match="note" mode="level1">
<fo:list-block keep-with-previous.within-page="always"
keep-together.within-page="always" space-before="6pt" start-indent="0mm"
provisional-distance-between-starts="13mm">
<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="level1">
<fo:inline border-left-width="0pt" border-right-width="0pt">
<xsl:apply-templates select="node()" mode="step1"/>
</fo:inline>
</xsl:template>
-----------------------------------------------------------------------------------------------------------
With these templates my desired output is:
NOTE: Some note here
1. Text here
NOTE: Note again
But, what I am getting is:
NOTE: Some note here
NOTE: Note again
1. Text here
Can anybody tell me where I am going wrong?
Thank you
_________________________________________________________________
Get the latest Windows Live Messenger 8.1 Beta version. Join now.
http://ideas.live.com