EVTEK: Elektroniset dokumentit ja XML

XPath - pikaohje

XPath merkintäesimerkkejä
Xpath merkintä Lyhennemerkintä Kuvaus
child::para para para-niminen elementti
child::* * kaikki lapsielementit
attribute::name @name name-niminen attribuutti
child::text() text() kaikki tekstisolmut
child::para[position()=1] para[1] ensimmäinen para-niminen elementti
child::para[position()=last()] para[last()] viimeinen para-niminen elementti
child::chapter/descendant::para chapter//para chapter-elementin kaikki para-nimiset jälkeläiselementit
/descendant::para //para juurisolmun kaikki para-nimiset jälkeläiselementit
self::node() . kontekstisolmu itse
parent::node() .. kontekstisolmun vanhempi
parent::node()/attribute::lang ../@lang kontekstisolmun vanhemman lang-niminen attribuutti
child::para[attribute::type="warning"] para[@type="warning"] kaikki para-nimiset elementit, joiden type-attribuutilla arvo "warning"
child::chapter[child::title] chapter[title] chapter-nimiset elementit, joilla on title-nimisiä lapsielementtejä

XSLT - pikaohje

XSLT - elementit (täydellinen lista löytyy standardista)
Elementti Attribuutti ja sisältö Kuvaus
<xsl:template..> match=pattern
name = qname
priority = number
mode = qname>
<!-- Content: (xsl:param*, template) -->
Sääntö
<xsl:apply-templates..> select = node-set-expression
mode = qname
<!-- Content: (xsl:sort | xsl:with-param)* -->
Kutsuu säännön sisältä toisia sääntöjä.
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
(Mahdollisesti päällekirjoittaa nykyisiä tyylejä.)
<xsl:transform..> id = id
extension-element-prefixes = tokens
exclude-result-prefixes = tokens
version = number
Defines the root element of a style sheet
samoin kuin 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
kun ehto on tosi, toteutetaan
<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
Lajittelu
<xsl:copy..> use-attribute-sets = qnames>
<!-- Content: template -->
Creates a copy of the current node (without child nodes and attributes)

qname= qualified name, esim. elementin nimi

| KOTISIVU | KURSSIKUVAUS | OHJELMA |

 
 Created by: Jaana Holvikivi 
Muutettu: 25.11.2002