XSLT Tip

Tommy Reynolds Tommy.Reynolds at MegaCoder.com
Mon Jan 2 21:27:06 UTC 2006


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-docs-list/attachments/20060102/b8a3bfbb/attachment.sig>


More information about the fedora-docs-list mailing list