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

XSLT Tip



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.

Attachment: pgpSpGoaP8onG.pgp
Description: PGP signature


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