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

Re: AW: Special processing for the first process of an

Subject: Re: AW: Special processing for the first process of an element
From: Peter Hickman <peter@xxxxxxxxxxxxx>
Date: Wed, 10 Nov 2004 15:51:36 +0000
xsl special
Thanks for the ideas, this is what I have got and it appears to work for the various test cases I have put together.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" />


   <xsl:template match="/">
       <xsl:apply-templates select="*|text()" />
   </xsl:template>

   <xsl:template match="p">
       <p><xsl:apply-templates select="*|text()" /></p>
   </xsl:template>

   <xsl:template match="document">
       <document><xsl:apply-templates select="*|text()" /></document>
   </xsl:template>

<xsl:template match="result">
<xsl:choose>
<xsl:when test="preceding::result">
<result class="rest"><xsl:apply-templates select="*|text()" /></result>
</xsl:when>
<xsl:otherwise>
<result class="first"><xsl:apply-templates select="*|text()" /></result>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>


For the test data:

<document>
 <p>
   <p>
     <p>
       <result>First</result>
     </p>
   </p>
   <p>
     <result>Second</result>
   </p>
 </p>
</document>

and a slightly harder document

<document>
   <p>tom
       <p>dick
           <p>harry
               <result>First</result>
           </p>
       </p>
   </p>
   <p>william
       <result>Second</result>
       <result>Third</result>
   </p>
</document>

Thanks again

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.