XSLT: Difference between revisions
Jump to navigation
Jump to search
(→Links) |
|||
Line 4: | Line 4: | ||
* https://www.w3.org/TR/xslt |
* https://www.w3.org/TR/xslt |
||
* http://www.w3schools.com/xsl/ |
* http://www.w3schools.com/xsl/ |
||
== Extensions == |
|||
From w3.org [https://www.w3.org/TR/xslt#element-stylesheet]: |
|||
* ''The element extension mechanism allows namespaces to be designated as extension namespaces. When a namespace is designated as an extension namespace and an element with a name from that namespace occurs in a template, then the element is treated as an instruction rather than as a literal result element.'' |
|||
=== Extensions available in the XSLT processor === |
|||
Using '''xsltproc''' (package {{deb|xsltproc}} [http://xmlsoft.org/XSLT/xslt.html], we can get the list of built-in extensions with: |
|||
<source lang=bash> |
|||
xsltproc --dumpextensions |
|||
# Registered XSLT Extensions |
|||
# -------------------------- |
|||
# Registered Extension Functions: |
|||
# {http://exslt.org/math}atan2 |
|||
# {http://exslt.org/strings}align |
|||
# ... |
|||
</source> |
|||
;exslt.org/crypto |
|||
* "Hidden" extensions that provides basic crypto functions (apparently from patch [https://mail.gnome.org/archives/xslt/2004-May/msg00057.html], introduced in July 5 2004 [http://xmlsoft.org/XSLT/xslt.html]): |
|||
<source lang=bash> |
|||
xsltproc --dumpextensions|grep crypto |
|||
# {http://exslt.org/crypto}rc4_decrypt |
|||
# {http://exslt.org/crypto}md4 |
|||
# {http://exslt.org/crypto}sha1 |
|||
# {http://exslt.org/crypto}md5 |
|||
# {http://exslt.org/crypto}rc4_encrypt |
|||
</source> |
|||
== Quick reference == |
== Quick reference == |
Revision as of 12:45, 5 October 2016
XSLT stands for Extensible Stylesheet Language Transformations.
Links
Extensions
From w3.org [1]:
- The element extension mechanism allows namespaces to be designated as extension namespaces. When a namespace is designated as an extension namespace and an element with a name from that namespace occurs in a template, then the element is treated as an instruction rather than as a literal result element.
Extensions available in the XSLT processor
Using xsltproc (package xsltproc [2], we can get the list of built-in extensions with:
xsltproc --dumpextensions
# Registered XSLT Extensions
# --------------------------
# Registered Extension Functions:
# {http://exslt.org/math}atan2
# {http://exslt.org/strings}align
# ...
- exslt.org/crypto
- "Hidden" extensions that provides basic crypto functions (apparently from patch [3], introduced in July 5 2004 [4]):
xsltproc --dumpextensions|grep crypto
# {http://exslt.org/crypto}rc4_decrypt
# {http://exslt.org/crypto}md4
# {http://exslt.org/crypto}sha1
# {http://exslt.org/crypto}md5
# {http://exslt.org/crypto}rc4_encrypt
Quick reference
xsl:attribute
Input | Output |
---|---|
<link site="www.stackoverflow.com"/>
|
<a href="http://www.stackoverflow.com">Click here</a>
|
Use
<xsl:template match="link">
<a>
<xsl:attribute name="href">
<xsl:text>http://</xsl:text><xsl:value-of select="@site"/>
</xsl:attribute>
<xsl:text>Link</xsl:text>
</a>
</xsl:template>
Or shorter using curly braces {...}
[5]:
<xsl:template match="link">
<a href="http://{@site}">Click here</a>
</xsl:template>
Also for:
- Using variables (like in
<a href="http://{$varName}">Click here</a>
)