xsl-list
[Top] [All Lists]

Re: [xsl] testing for position of an element and displaying it accordingly

2007-01-25 12:44:24

Please tell me how this can be resolved.


So it is really not going in order in the style sheet,
and repeats the <a> content two ties 0once before the
<r1> and once aftr <r1>.

It only repeats if you apply templates twice. If you don't do that
it will only be processed once.

Did you try any of the code posted earlier?
clearly not on your sample input 

<a><para>Some other test</a></para>
                        ^^^^^^^^^^
which isn't well formed.




one last try...


<r1>
<a><para>Some test</para></a>
<a><para>Some other test</para></a>
<text><para>This is level1</para></text>
<!--I can have any element here text, table -->
<a><para>Some test 3</para></a>
</r1>



<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:fo="fo">
  

<xsl:template match="r1">
  <fo:block>
  <xsl:apply-templates/>
  </fo:block>
</xsl:template>

<xsl:template match="a">
  <fo:block><xsl:apply-templates/></fo:block>
</xsl:template>


<xsl:template match="table">
  whatever you need for tables
</xsl:template>

<xsl:template match="r1/text[1]" priority="2">
  <fo:block>1: <xsl:apply-templates/></fo:block>
</xsl:template>


</xsl:stylesheet>

$ saxon m.xml m.xsl
<?xml version="1.0" encoding="utf-8"?><fo:block xmlns:fo="fo">
<fo:block>Some test</fo:block>
<fo:block>Some other test</fo:block>
<fo:block>1: This is level1</fo:block>

<fo:block>Some test 3</fo:block>
</fo:block>



which appears to be the result you wanted, although it's hard to be sure
given your expected output had no markup.

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>
--~--