[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: testing for position of an element and displaying

Subject: Re: testing for position of an element and displaying it accordingly
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 25 Jan 2007 19:42:41 GMT
Re:  testing for position of an element and displaying
> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.