xsl-list
[Top] [All Lists]

Re: [xsl] Need help for XSL beautifaction

2006-05-16 15:14:07
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

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