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

RE: about using templates

Subject: RE: about using templates
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 12 Jun 2002 10:08:05 +0100
xsl using template
> prehap it is easier to explain this with an example... 
> suppose there are 2 
> xsl stylesheet (XSL1 and XSL2)
> in XSL1 it contain the following: -
> 
> <xsl:template name="key1">fault/unit=key234HrsWft</xsl:template>
> <xsl:template name="key2">data</xsl:template>
> <xsl:template name="key3">some key</xsl:template>
> 
> in XSL2 i will call the following template to retrieve the 
> values store in 
> the three key template: -
> 
> <xsl:template name="query_str">
> 	 <p><xsl:call-template name="key1"/></ip> and
> 	 <p><xsl:call-template name="key2"/></p> and 
> 	 <p><xsl:call-template name="key3"/></p> and 
> 	 </xsl:template>
> so the output result should be: - 
> <p>key234HrsWft</p> and <p>data</p> and <p>soome key</p>

Actually the first result will be <p>fault/unit=key234HrsWft</p> with
this data.
> 
> the problem is, if key2 contain no data (ie <xsl:template 
> name="key2"></xsl:template>) the output will becoming 
> <p>key234HrsWft</p> 
> and <p></p> and <p>soome key</p>
> therefore, i was wondering, how could i selectively add the " 
> and " string 
> into the output file (e.g. only add the " and " string if key2 is not 
> empty). 

It's not clear to me where you want to add the quotation marks.

But more importantly, I don't understand why you are using named
templates to produce these values rather than variables. If you wrote

<xsl:variable name="key2">data</xsl:variable>

then the problem would be much easier.

If you can't rewrite the templates as variables, then you can achieve
the same effect by capturing the result of the template in a variable:

<xsl:variable name="key2">
	<xsl:call-template name="key2"/>
</xsl:variable>

And then you can test $key2=''.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.