Chapter 9. Duplication, Iteration, and Conditional XSLT Elements

  • <xsl:copy-of>

  • <xsl:copy>

  • <xsl:if>

  • <xsl:for-each>

  • <xsl:choose>

  • <xsl:when>

  • <xsl:otherwise>

  • <xsl:sort>

  • <xsl:number>

  • <xsl:fallback>

There are three very important concepts in XSLT, as in any programming language, that encompass the ability to duplicate objects, conditionally process objects, and iterate through a list of objects sequentially. This chapter will discuss these three concepts and their applicable XSLT elements.

The duplication elements in XSLT that provide the ability to copy an entire XML structure, or just a tag name, are <xsl:copy-of> and <xsl:copy>. Conditional elements, those that involve a condition or test to select objects, are <xsl:if>, <xsl:choose>, and <xsl:fallback>. The elements that are in some way iterative are <xsl:for-each>, <xsl:sort>, and <xsl:number>. The <xsl:sort> element, while not necessarily iterative, works on node-sets to reorder them prior to an iteration. The two children of <xsl:choose>, <xsl:when> and <xsl:otherwise>, are also covered in this chapter.

The <xsl:fallback> instruction element, while not technically a conditional element, is used to provide an alternative process when an XSLT instruction fails. It is covered in the last section of this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset