Subject: RE: [xsl] not matching empty text nodes. From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Thu, 6 Feb 2003 13:22:20 -0000 |
> > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] not matching empty text nodes, Terence | Thread | RE: [xsl] not matching empty text n, Ross Ken |
RE: [xsl] Xsl problem with output o, Michael Kay | Date | SV: [xsl] a quick question re: &nbs, "Nordström, Jonas" |
Month |