XML Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.00

XSLT Elements as Programming Statements

This chapter provides tutorial notes and example codes on XSLT programming statements. Topics include introduction of XSLT elements: 'value-of', 'variable', 'for-each', 'if', and 'choose'; example XSLT templates with programming techniques of declaring variables, evaluating expressions, running loops, generating conditional outputs.

"value-of" - Evaluating XPath String Expressions

Examples of Using "value-of" Elements

"{expression}" - Shorthand of "value-of" Elements

"variable" - Declaring Variables

"for-each" - Looping through a Node Set

Examples of Using "for-each" Elements

"if" - The Conditional Element

"choose" - The If...Else Element

Conclusion:

  • A "value-of" element can be used to evaluate an XPath expression to produce a string value.
  • "{expression}" is a shorthand version of the "value-of" element.
  • A "variable" element can be used to declare a variable to store a value to be used later.
  • A "for-each" element can be used to repeat a block of contents over a node set returned by an XPath expression.
  • An "if" element can be used to put a block of contents under a condition.
  • A "choose" element can be used to put different blocks of contents under different conditions.

Table of Contents

 About This Book

 Introduction of XML (eXtensible Markup Language)

 XML File Syntax

 XML File Browsers

 DOM (Document Object Model) Programming Interface

 SAX (Simple API for XML) Programming Interface

 DTD (Document Type Definition) Introduction

 Syntaxes of DTD Statements

 Validating an XML Document against the Specified DTD Document Type

 XSD (XML Schema Definition) Introduction

 Syntaxes of XSD Statements

 Validating an XML Document against the Specified XML Schema

 XSL (Extensible Stylesheet Language) Introduction

 XSLT (XSL Transformations) Introduction

 Java Implementation of XSLT

 XPath (XML Path) Language

XSLT Elements as Programming Statements

 Control and Generate XML Element in the Result

 References

 Printable Copy - PDF Version

Dr. Herong Yang, updated in 2009
XSLT Elements as Programming Statements