Re: XSLT Tip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2006-01-02 at 15:27 -0600, Tommy Reynolds wrote:
> Paul,
> 
> +      <xsl:for-each select="/rpm-info/copyright">
> +	<xsl:element name="copyright">
> +	  <xsl:for-each select="/rpm-info/copyright/year"><xsl:element name="year">
> +	      <xsl:value-of select="node()"/>
> +	    </xsl:element></xsl:for-each>
> +	  <xsl:for-each select="/rpm-info/copyright/holder">
> +	    <xsl:element name="holder">
> +	      <xsl:value-of select="node()"/>
> +	    </xsl:element>
> +	  </xsl:for-each>
> +	</xsl:element>
> +      </xsl:for-each>
> 
> This is a bit verbose.  Embedding so much of each element's path here
> can be detrimental to maintainability. The <xsl:for-each> cycles
> through the available /rpm-info/copyright/ elements, setting the
> symbol "." or node() to the element currently getting the "focus", so
> you could write this as:
> 
> <xsl:for-each select="/rpm-info/copyright">
>   <xsl:element name="copyright">
>     <xsl:for-each select="year">
>       <xsl:value-of select="."/>
>     </xsl:for-each>
>   </xsl:element>
> </xsl:for-each>
> 
> HTH.

Actually, I thought the same thing before my commit, WRT the absolute
element path, then promptly forgot to go back and change it.  Thanks for
catching this.  The node() thing I didn't realize was an issue.  Are
there any usage differences between "node()" and "."?

-- 
Paul W. Frields, RHCE                          http://paul.frields.org/
  gpg fingerprint: 3DA6 A0AC 6D58 FEC4 0233  5906 ACDB C937 BD11 3717
 Fedora Documentation Project: http://fedora.redhat.com/projects/docs/

Attachment: signature.asc
Description: This is a digitally signed message part

-- 

fedora-docs-list@xxxxxxxxxx
To unsubscribe: 
https://www.redhat.com/mailman/listinfo/fedora-docs-list

[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Red Hat 9]     [Yosemite News]     [KDE Users]

  Powered by Linux