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

RE: not matching empty text nodes.

Subject: RE: not matching empty text nodes.
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 6 Feb 2003 13:22:20 -0000
RE:  not matching empty text nodes.
> 
> how do I provide a one-template solution to all elements 
> which have the 
> same requirements as caption?
> For instance, there are more of these...
> 
>      <xsl:template match="/album/photos/photo/description">
>          <tr valign="top">
>              <td class="label" align="right">description:</td>
>              <td class="caption"><xsl:value-of select="." /></td>
>          </tr>
>      </xsl:template>
> 
>      <xsl:template match="/album/photos/photo/location">
>          <tr valign="top">
>              <td class="label" align="right">location:</td>
>              <td class="caption"><xsl:value-of select="." /></td>
>          </tr>
>      </xsl:template>
> 

You could write

<xsl:template match="/album/photos/photo/*">
     <tr valign="top">
         <td class="label" align="right"><xsl:value-of
select="name()"/>:</td>
           <td class="caption"><xsl:value-of select="." /></td>
         </tr>
     </xsl:template>
</xsl:template>

or more specifically

<xsl:template match="/album/photos/photo/description |
/album/photos/photo/location">

Do your match patterns really need to be so detailed? Are there other
contexts where "description" and "location" can appear? Because if not,
you are just wasting cycles testing the ancestory of the elements
unnecessarily, and you are also making it harder to change your
stylesheet if the schema changes.

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.