[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|