Hi all:
Thank you for all your input. I tried to implement all
the suggestions and concepts.
Here is waht I came up with:
My sample xml:
<r1>
<a><para>Some test</a></para>
<a><para>Some other test</a></para>
<text><para>This is level1</para></text>
<!--I can have any element here text, table -->
<a><para>Some test 3</a></para>
<r1>
My desired output:
Some test
Some other test
1. This is level1
Some test 3
Like I said before I was numbering r1..r10. So now fo
r1 template:
<xsl:template match="r1">
<xsl:call-template name="test">
<xsl:with-param name="format">1</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="test">
<xsl:param name="format"/>
<xsl:if test="a">
<xsl:apply-templates select="a"/>
</xsl:if>
<fo:list-block space-before="6pt"
space-before.conditionality="retain">
<fo:list-item space-before="6pt">
<fo:list-item-label end-indent="label-end()">
<xsl:choose>
<xsl:when test="$format = '1'">
<fo:block>
<fo:inline>
<xsl:number
format="1"/>.</fo:inline>
</fo:block>
</xsl:when>
</xsl:choose>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()"
end-indent="0pt">
<fo:block>
<xsl:apply-templates
select="*[not(self::a)]"/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</xsl:template>
What happens here is, I check for 'a" before the
formatting, so if there is an <a> element it applies
templates. But since int he end I have said
<xsl:apply-templates select="*[not(self::a)]"/>, it
does not match templates after the text, or table
elements. text and table are just examples and there
can be any element here.
So now I get
Some test
Some other test
Some test 3
1. This is level1
My question now is how do I match template if the <a>
element appears after a text element or any other
element. If I say, <xsl:apply-templates/> instead of
<xsl:apply-templates select="*[not(self::a)]"/>, then
I get:
Some test
Some other test
Some test 3
1. Some test
Some other test
Some test 3
This is level1
since it matches all templates then. This is tricky.
Can you please tell me how to resolve this issue?
--- David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
you don't appear to have changed the code at all in
response to teh
previous comments.
you have (as before)
<xsl:template match="r1">
<xsl:if test="child::a">
<xsl:apply-templates select="a" mode="t"/>
</xsl:if>
The xsl:if here soes nothing at all this is
equivalent to
<xsl:template match="r1">
<xsl:apply-templates select="a" mode="t"/>
and by specifying select="a" you are selecting all
the a elements
to be processed first, before any other elements.
You do not want that,
so select all children, not just a ones, then they
will be processed in
the natural order.
<xsl:template match="r1">
<xsl:apply-templates/>
</xsl:template>
then have templates for a and test that do the right
thing
<xsl:template match="a">
<fo:block><xsl:number/>:
<xsl:apply-templates/></fo:block>
</xsl:template>
<xsl:template match="text">
<fo:block><xsl:apply-templates/></fo:block>
</xsl:template>
which is exactly Michael's suggestion in the message
that you quoted.
David
--~------------------------------------------------------------------
XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
____________________________________________________________________________________
Get your own web address.
Have a HUGE year through Yahoo! Small Business.
http://smallbusiness.yahoo.com/domains/?p=BESTDEAL
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--