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

RE: 2 columns with special conditions

Subject: RE: 2 columns with special conditions
From: "Bjorndahl, Brad" <brad.bjorndahl@xxxxxxxxxxxxxxxx>
Date: Fri, 4 May 2007 10:02:23 -0400
RE:  2 columns with special conditions
Hi,
I expected my solution could be made shorter like this.

I think this is another example of a characteristic of XSLT. You can put
the complexity into the logic (e.g. nested choose instructions) or in
the template structure or in XPATH, or in combinations of these.

As you gain experience with XSLT, you go through problem solving stages:
1. Frustration - cannot find any solution
2. Happy - found a solution
3. Happier - found 3 solutions and coded the easiest
4. Happiest - found 3 solutions and coded the cleverest/shortest/coolest
5. Frustration - found a 4th solution and spent a weekend re-coding

Brad


-----Original Message-----
From: George Cristian Bina [mailto:george@xxxxxxxxxxxxx]
Sent: May 4, 2007 6:57 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  2 columns with special conditions

Hi Sven,

Looking more into this it seems that there is a quite simple solution:

<?xml version='1.0'?>
<xsl:transform version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="steps">
     <table border="1">
       <xsl:apply-templates/>
     </table>
   </xsl:template>
   <xsl:template match="mc[@type='F']">
     <tr>
       <td><xsl:value-of select="@name"/></td>
       <td><xsl:value-of
select="following-sibling::*[1][@type='C']/@name"/></td>
     </tr>
   </xsl:template>
   <xsl:template
match="mc[@type='C'][not(preceding-sibling::*[1][@type='F'])]">
     <tr>
       <td></td>
       <td><xsl:value-of select="@name"/></td>
     </tr>
   </xsl:template>
</xsl:transform>

Regards,
George
---------------------------------------------------------------------
George Cristian Bina - http://aboutxml.blogspot.com/ <oXygen/> XML
Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com

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.