EVITech: XML

XPath location paths

XPath location paths: examples
Xpath expression Abbreviated Description
child::para para element called para
child::* * all children
attribute::name @name attribute celled name
child::text() text() all text nodes
child::para[position()=1] para[1] first element called para
child::para[position()=last()] para[last()] last element called para
child::chapter/descendant::para chapter//para all descendants of element chapter which are called para
/descendant::para //para all descendants of root element which are called para
self::node() . context node
parent::node() .. parent of context node
parent::node()/attribute::lang ../@lang attribute lang which belongs to the parent of context node
child::para[attribute::type="warning"] para[@type="warning"] all para elements which have value "warning" in "type" attribute
child::chapter[child::title] chapter[title] elements called chapter which have child elements called title

XSLT

XSLT - elements (consult the standard for full list)
Element Attributes and content Description
<xsl:template..> match=pattern
name = qname
priority = number
mode = qname>
<!-- Content: (xsl:param*, template) -->
Template rule
<xsl:apply-templates..> select = node-set-expression
mode = qname
<!-- Content: (xsl:sort | xsl:with-param)* -->
Applies a template rule to the current element or to the current element's child nodes
<xsl:call-template..> name = qname Calls a named template
<xsl:stylesheet..> id = id
extension-element-prefixes = tokens
exclude-result-prefixes = tokens
version = number
Defines the root element of a style sheet
<xsl:include..> href = uri-reference Includes the contents of one style sheet into another. Note: An included style sheet has the same precedence as the including style sheet
<xsl:import..> href = uri-reference Imports the contents of one style sheet into another. Note: An imported style sheet has lower precedence than the importing style sheet
(Overwriting possible.)
<xsl:transform..> id = id
extension-element-prefixes = tokens
exclude-result-prefixes = tokens
version = number
Defines the root element of a style sheet
same as xsl:stylesheet
<xsl:value-of..> select = string-expression Extracts the value of a selected node
<xsl:variable..> name = qname
select = expression
Declares a local or global variable
<xsl:param ..> name = qname
select = expression
<!-- Content: template -->
Declares a local or global parameter
<xsl:output ..> method = "xml" | "html" | "text" | qname-but-not-ncname
version = nmtoken
encoding = string
omit-xml-declaration = "yes" | "no"
standalone = "yes" | "no"
doctype-public = string
doctype-system = string
cdata-section-elements = qnames
indent = "yes" | "no"
media-type = string
 
<xsl:element..> name = { qname }
namespace = { uri-reference }
use-attribute-sets = qnames
Creates an element node in the output document
<xsl:comment> <!-- Content: template --> Creates a comment node in the result tree
<xsl:attribute..> name = { qname }
namespace = { uri-reference }
Adds an attribute
<xsl:processing-instruction..> name = { ncname }
<!-- Content: template -->
Writes a processing instruction to the output
<xsl:text..> disable-output-escaping = "yes" | "no">
<!-- Content: #PCDATA -->
Writes literal text to the output
<xsl:if..> test = boolean-expression>
<!-- Content: template -->
Contains a template that will be applied only if a specified condition is true
<xsl:for-each ..> select = node-set-expression Loops through each node in a specified node set
<xsl:choose> <!-- Content: (xsl:when+, xsl:otherwise?) --> Used to express multiple conditional tests
<xsl:when..> test = boolean-expression Specifies an action for the <xsl:choose> element
when the condition is true
<xsl:otherwise> <!--Content: template --> Specifies a default action for the <xsl:choose> element
<xsl:sort ..> select = string-expression
lang = { nmtoken }
data-type = { "text" | "number" | qname-but-not-ncname }
order = { "ascending" | "descending" }
case-order = { "upper-first" | "lower-first" }
Sorts the output
<xsl:copy..> use-attribute-sets = qnames>
<!-- Content: template -->
Creates a copy of the current node (without child nodes and attributes)

qname= qualified name, ie. element name

 

  | HOME SYLLABUS | CALENDAR |

 
 Created by: Jaana Holvikivi 
Updated: 28.01.2003