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

RE: <xsl:output method="xml"> and an if sentence to o

Subject: RE: <xsl:output method="xml"> and an if sentence to output XML
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Mon, 09 May 2005 16:16:59 +0000
xsl output method xml attribute
Jacob, since you're generating HTML, just use output="html", or even output="xml". Also, tag-writing <xsl:text>&lt;</... is usually not a good idea, and is not needed when generating well-formed elements. Thus the following:


<xsl:template name="outline"> <xsl:param name="title" /> <xsl:text>&lt;dl&gt;</xsl:text> <xsl:text>&lt;dt&gt;</xsl:text> <xsl:value-of select="$title" /> <xsl:text>&lt;/dt&gt;</xsl:text> <xsl:for-each select="outline"> <xsl:choose> <xsl:when test="@this">&lt;dd class="active"&gt;</xsl:when> <xsl:otherwise>&lt;dd&gt;</xsl:otherwise> </xsl:choose> <xsl:text>&lt;a href="</xsl:text> <xsl:value-of select="@url" /> <xsl:text>"&gt;</xsl:text> <xsl:value-of select="@title" /> <xsl:text>&lt;/a&gt;</xsl:text> <xsl:text>&lt;/dd&gt;</xsl:text> </xsl:for-each> <xsl:text>&lt;dl&gt;</xsl:text> </xsl:template>

may be written more simply, and in more XSL-esque fashion as:


<xsl:template name="outline">
	<xsl:param name="title" />

	<dl>
       <xsl:value-of select="$title" />

<xsl:for-each select="outline">
<dd>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="@this">active</xsl:when>
</xsl:choose>
</xsl:attribute>
<a>
<xsl:attribute name="href"><xsl:value-of select="@url" /></xsl:attribute>
<xsl:value-of select="@title" />
</a>
</dd>
</xsl:for-each>
</dl>
</xsl:template>


Note containment of elements, and the use of <xsl:attribute/>

regards,

--A

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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.