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

Re: Need help for XSL beautifaction

Subject: Re: Need help for XSL beautifaction
From: "Jon Gorman" <jonathan.gorman@xxxxxxxxx>
Date: Tue, 16 May 2006 17:13:52 -0500
Re:  Need help for XSL beautifaction
Do you have any ideas how I can code this XSL more beautiful:

<xsl:if test="textNo = 'text-1'" >
       <xsl:copy-of select="$text-1"/>
 </xsl:if>

In other words: Is there a chance to use the <copy-of> directly with the
value of "textNo", without the <xsl:if> ?

Errr. I'm a little confused here. In this short example you've managed to create a short snippet that doesn't quite do what your short description says.

<xsl:if test="textNo = 'text-1'" >
       <xsl:copy-of select="$text-1"/>
 </xsl:if>


In other words, you're testing to see if the text value of textNo is
text-1.  If it is, you copy the node-set in the $text-1 variable or
parameter.

Let's say before that you have:

<xsl:variable name="text-1" select="foobar" />

You'll copy those foobar nodes out into your result doc.

In other words: Is there a chance to use the <copy-of> directly with the
value of "textNo", without the <xsl:if> ?

Well, according to your sippet, you already know textNo is 'textNo' in the if. If you don't care the about the value, why test it? Of course, you're not using the value of textNo anyhow. The literal answer to your question is: text-1

would replace
<xsl:if test="textNo = 'text-1'" >
       <xsl:copy-of select="$text-1"/>
 </xsl:if>

I'm assuming you've made a mistake somewhere along the line.  Or you
have already simplified as much as you can.

Jon Gorman


I'm not entirely sure what your focus on "beautification" is here since it's pretty condensed already. Of course, in many cases a test for existance is unnecessary if what you are doing is copying the element itself or just checking for a certain value. But with your example we can't be sure of what's happening.

Jon Gorman

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.