[http://creativecommons.org/licenses/by/3.0/]
This work is licensed under a CC
Attribution 3.0 Unported License [http://creativecommons.org/licenses/by/3.0/]
Character Markup
While XML Transformations (XSLT) 1.0 has become a successful programming language widely used for transforming XML documents, its limitations sometimes make it difficult to use XSLT in a good way. An important reason for many of the limitations is the fact that XSLT 1.0 has been designed as a client-side language. Building on XSLT 1.0 and XPath 2.0, XML Transformations (XSLT) 2.0 improves the language in a variety of ways.
typedlanguage (strings, IDs, IDREFs)
<xsl:for-each select="//reference"> <xsl:result-document method="xhtml" href="reference/{@name}.html"> <html> <head> <title><xsl:value-of select="title"/></title> <link rel="stylesheet" type="text/css" href="../reference.css"/> </head> <body> <div class="navigation"> <a href="{ if ( position() ne 1 ) then preceding-sibling::reference[1]/@name else following-sibling::reference[last()]/@name }.html">Previous</a> | <a href="../reference-list.html">Index</a> | <a href="{ if ( position() ne last() ) then following-sibling::reference[1]/@name else preceding-sibling::reference[last()]/@name }.html">Next</a> </div> <h2><xsl:value-of select="title"/></h2> <xsl:apply-templates select="names[@type='author']/*"/> <h4><a href="../reference-list.html#year{substring(date/@value, 1, 4)}"><xsl:value-of select="myns:format-date(date/@value)"/></a></h4> <xsl:if test="abstract"> <div class="abstract"><xsl:copy-of select="abstract/richtext/*"/></div> </xsl:if> </body> </html> </xsl:result-document> </xsl:for-each>
speakingidentifiers are required
2007/10/25
main property
<xsl:result-document method="xhtml" href="reference-list.html"> <html> <head> <title>Reference List</title> <link rel="stylesheet" type="text/css" href="reference.css"/> </head> <body> <h2>Reference List</h2> <xsl:for-each-group select="//reference" group-by="substring(date/@value, 1, 4)"> <xsl:sort select="current-grouping-key()"/> <h5 id="year{current-grouping-key()}"><xsl:value-of select="current-grouping-key()"/></h5> <ul> <xsl:for-each select="current-group()"> <xsl:sort select="title"/> <li><a href="reference/{@name}.html"><xsl:value-of select="title"/></a></li> </xsl:for-each> </ul> </xsl:for-each-group> </body> </html> </xsl:result-document>
structured documents
markup
spreadsheet data
matches("abracadabra", "bra") ≡ true()
matches("abracadabra", "^a.*a$") ≡ true()
matches("abracadabra", "^bra") ≡ false()
replace("abracadabra", "bra", "*") ≡ "a*cada*"
replace("abracadabra", "a.*a", "*") ≡ "*"
replace("abracadabra", "a.*?a", "*") ≡ "*c*bra"
replace("abracadabra", "a(.)", "a$1$1") ≡ "abbraccaddabbra"
replace("abracadabra", "^(.*?)b(.*)$", "$1c$2") ≡ "acracadabra"
tokenize("just plain text", "\s+") ≡ ( "just", "plain", "text" )
tokenize("1,15,,24,50,", ",") ≡ ( "1", "15", "", "24", "50", "" )
tokenize("HTML <BR> tag<br />soup", "\s*<br\s*/?>\s*", "i") ≡ ("HTML", "tag", "soup")
<xsl:analyze-string select="abstract" regex="\n"> <xsl:matching-substring> <br/> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string>
Character Markup
[…]for the citation identification
<xsl:analyze-string select="body" regex="\[(.*?)\]"> <xsl:matching-substring> <cite><xsl:value-of select="regex-group(1)"/></cite> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string>