This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: cutting it short!




> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]
> Sent: 11 July 2001 23:50
> To: xsl-list
> Subject: [xsl] cutting it short!
> 
> 
> Reply-To: <skohli@mobilehelix.com>
> From: "sumev" <skohli@mobilehelix.com>
> To: <XSL-List@lists.mulberrytech.com>
> Subject: Help for cutting it short!
> Date: Wed, 3 Jan 2001 17:58:07 -0500
> Message-ID: <GAEMJDODNEBPDDAADPLPAEPPCBAA.skohli@mobilehelix.com>
> 
> 
> Hi Folks!,
>         I am workin on simple xslt and want to make it look 
> good (I want to
> make it short! lot of xsl:when statements)
> 
> xsl -->
> 
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version="1.0">
>   <xsl:output method="xml"/>
> 	<xsl:template match="request">
> 		<xsl:copy>
> 		<xsl:attribute name="id">
> 			<xsl:value-of select="id"/>
> 		</xsl:attribute>
> 		<xsl:attribute name="eventName">
> 			<xsl:value-of select="eventName"/>
> 		</xsl:attribute>

You can replace most of this with 
<request id="{id}" eventName="{eventname}" etc.

> 		</xsl:attribute>
> 			 <xsl:for-each select="@*|*[not(* or @*)]">
> 			    <xsl:choose>
> 				 <xsl:when test="name()='id'"/>
> 			         <xsl:when test="name()='eventName'"/>
> 			         <xsl:when 
> test="name()='applicationName'"/>
> 			         <xsl:when test="name()='originator'"/>
> 			         <xsl:when test="name()='variable'"/>
> 			         <xsl:when test="name()='timestamp'"/>
> 			         <xsl:when test="name()='typeid'"/>
> 				 <xsl:otherwise>

This bit looks like a real candidate for a template rule

<xsl:apply-templates select="@* | *[not(* or @*)]" mode="x"/>

<xsl:template match="eventName|originator|variable ..." mode="x"/>

etc.
> 

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]