mirror of
https://github.com/moparisthebest/xeps
synced 2024-11-21 00:35:02 -05:00
Import the texml-related XSL files into this repository
This helps against build failures due to sourceforge being unavailable.
This commit is contained in:
parent
fba129b508
commit
b9a410551e
@ -10,6 +10,7 @@ COPY *.xml xep.* *.css *.xsl *.js *.xsl Makefile /src/
|
||||
COPY resources/*.pdf /src/resources/
|
||||
COPY tools/*.py /src/tools/
|
||||
COPY inbox/*.xml inbox/*.ent inbox/*.dtd /src/inbox/
|
||||
COPY texml-xsl/*.xsl /src/texml-xsl/
|
||||
|
||||
WORKDIR /src
|
||||
RUN OUTDIR=/var/www/html/extensions/ make -j$NCORES $TARGETS
|
||||
|
318
texml-xsl/cmp.xsl
Normal file
318
texml-xsl/cmp.xsl
Normal file
@ -0,0 +1,318 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<xsl:stylesheet
|
||||
version="1.0"
|
||||
extension-element-prefixes="doc"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
|
||||
xmlns:str="http://xsltsl.org/string"
|
||||
xmlns:cmp="http://xsltsl.org/cmp"
|
||||
exclude-result-prefixes="cmp str doc"
|
||||
>
|
||||
|
||||
<doc:reference xmlns="">
|
||||
<referenceinfo>
|
||||
<releaseinfo role="meta">
|
||||
$Id$
|
||||
</releaseinfo>
|
||||
<author>
|
||||
<surname>Hummel</surname>
|
||||
<firstname>Mark</firstname>
|
||||
</author>
|
||||
<copyright>
|
||||
<year>2003</year>
|
||||
<holder>Mark Hummel</holder>
|
||||
</copyright>
|
||||
</referenceinfo>
|
||||
|
||||
<title>XML Compare</title>
|
||||
|
||||
<partintro>
|
||||
<section>
|
||||
<title>Introduction</title>
|
||||
|
||||
<para>This module provides a template for comparing two xml documents. </para>
|
||||
|
||||
</section>
|
||||
</partintro>
|
||||
|
||||
</doc:reference>
|
||||
|
||||
|
||||
<doc:template name="cmp:diff">
|
||||
<refpurpose>Compare</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>Compare two xml documents and display differences. Two xml documents are defined to be the same if: They have the matching elements and attributes, and that the data in the elements also match. The comparison is order sensitive. </para>
|
||||
|
||||
<para>The element names from the documents at the current depth are compared, followed by their values, then any attribute names and values are compared. The process is applied then to the subtrees of the documents.</para>
|
||||
|
||||
<para>Notes: If there are leaf nodes in one nodeset which don't exist in the other, the value of those 'extra' elements won't appear as a difference.
|
||||
</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>ns1</term>
|
||||
<term>ns2</term>
|
||||
<listitem>
|
||||
<para>The two nodesets which are to be compared. </para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns the difference between the documents. </para>
|
||||
|
||||
<para>The format of the output is an xml document. A node is added to the result tree for every difference. The node contains the type of difference (e.g element name difference, attribute value difference, etc), the value in the first nodeset and the value in the second nodeset, and the parent node. The indentation level is the depth at which the difference was found relative to the first document. </para>
|
||||
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<!-- pass in a nodeset and compare. Is order sensitive. Output attribute, element and textual differences. -->
|
||||
|
||||
<xsl:template name="cmp:diff">
|
||||
<xsl:param name="ns1"/>
|
||||
<xsl:param name="ns2"/>
|
||||
|
||||
<!-- attribute compare -->
|
||||
<!-- Optimisation attempt
|
||||
|
||||
Can probaby change this into one loop ie -
|
||||
<xsl:for-each
|
||||
i = position
|
||||
if node1[i] = node2[i]...
|
||||
|
||||
-->
|
||||
|
||||
<!-- Need to check if there are two sets of attributes -->
|
||||
<xsl:choose>
|
||||
<xsl:when test='count($ns1/attribute::*) = count($ns2/attribute::*)'>
|
||||
<xsl:for-each select="$ns1/attribute::*">
|
||||
<xsl:variable name="name1" select="name()"/>
|
||||
<xsl:variable name="value1" select="."/>
|
||||
<xsl:variable name="i" select="position()"/>
|
||||
|
||||
<xsl:for-each select="$ns2/attribute::*">
|
||||
|
||||
<xsl:variable name="j" select="position()"/>
|
||||
<xsl:variable name="name2" select="name()"/>
|
||||
<xsl:variable name="value2" select="."/>
|
||||
|
||||
<xsl:if test="$i = $j">
|
||||
<xsl:if test="$name1 != $name2">
|
||||
<attributeNameDifference>
|
||||
<parentElement><xsl:value-of select="name(..)"/></parentElement>
|
||||
<before><xsl:value-of select="$name1"/></before>
|
||||
<after><xsl:value-of select="$name2"/></after>
|
||||
</attributeNameDifference>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="$name1 = $name2 and $value1 != $value2">
|
||||
<attributeValueDifference>
|
||||
<parentElement><xsl:value-of select="name(..)"/></parentElement>
|
||||
<before><xsl:value-of select="$value1"/></before>
|
||||
<after><xsl:value-of select="$value2"/></after>
|
||||
</attributeValueDifference>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<attributeNameDifference>
|
||||
<parentElement>
|
||||
<xsl:value-of select="name(..)"/>
|
||||
</parentElement>
|
||||
<before><xsl:value-of select='$ns1/attribute::*'/></before>
|
||||
<after><xsl:value-of select='$ns2/attribute::*'/></after>
|
||||
</attributeNameDifference>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
|
||||
<!-- Find element differences by comparing the element names from the same position in both documents. Iterate over all the nodes in the nodeset with the largest number of elements, so the extra elements will appear as differences. -->
|
||||
|
||||
<xsl:choose>
|
||||
<!-- Define loop direction based on which tree has more nodes
|
||||
FIXME: Replacing this with one for-each and a test for the case
|
||||
of the second tree having more nodes would be more elegant
|
||||
|
||||
Solution: Add variable for direction and assign the 'larger' nodeset to that
|
||||
variable. Then do one for-each.
|
||||
|
||||
FIXME: The solution is a bit too iterative. Make it more functional
|
||||
|
||||
-->
|
||||
<xsl:when test="count($ns1) > count($ns2)">
|
||||
<xsl:for-each select="$ns1">
|
||||
<xsl:variable name="i" select="position()"/>
|
||||
|
||||
<xsl:message>node[<xsl:value-of select='$i'/>]:
|
||||
<xsl:value-of select='$ns1[$i]'/>
|
||||
</xsl:message>
|
||||
|
||||
<!-- Element name compare -->
|
||||
<xsl:if test="name($ns1[$i]) != name($ns2[$i])">
|
||||
<elementNameDifference>
|
||||
<parentElement><xsl:value-of select="name(..)"/></parentElement>
|
||||
<before><xsl:value-of select="name($ns1[$i])"/></before>
|
||||
<after><xsl:value-of select="name($ns2[$i])"/></after>
|
||||
</elementNameDifference>
|
||||
</xsl:if>
|
||||
|
||||
<!-- Element Value compare -->
|
||||
|
||||
<xsl:if test="count($ns1/*) = 0">
|
||||
<xsl:if test="$ns1[$i] != $ns2[$i]">
|
||||
<elementValueDifference>
|
||||
<parentElement><xsl:value-of select="name(..)"/></parentElement>
|
||||
<before><xsl:value-of select="$ns1[$i]"/></before>
|
||||
<after><xsl:value-of select="$ns2[$i]"/></after>
|
||||
</elementValueDifference>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:for-each>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:for-each select="$ns2">
|
||||
<xsl:variable name="i" select="position()"/>
|
||||
|
||||
<!-- Element Name compare -->
|
||||
|
||||
<xsl:if test="name($ns1[$i]) != name($ns2[$i])">
|
||||
<elementNameDifference>
|
||||
<parentElement><xsl:value-of select="name(..)"/></parentElement>
|
||||
<before><xsl:value-of select="name($ns1[$i])"/></before>
|
||||
<after><xsl:value-of select="name($ns2[$i])"/></after>
|
||||
</elementNameDifference>
|
||||
|
||||
</xsl:if>
|
||||
|
||||
<!-- value compare -->
|
||||
|
||||
<xsl:if test="count($ns2/*) = 0">
|
||||
<xsl:if test="$ns2[$i] != $ns1[$i]">
|
||||
<elementValueDifference>
|
||||
<parentElement><xsl:value-of select="name(..)"/></parentElement>
|
||||
<after><xsl:value-of select="$ns2[$i]"/></after>
|
||||
<before><xsl:value-of select="$ns1[$i]"/></before>
|
||||
</elementValueDifference>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:for-each>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<!-- stop processing when leaf node is reached. -->
|
||||
|
||||
<xsl:if test="count($ns1/*) > 0 and count($ns2/*) > 0">
|
||||
<xsl:call-template name="cmp:diff">
|
||||
<xsl:with-param name="ns1" select="$ns1/*"/>
|
||||
<xsl:with-param name="ns2" select="$ns2/*"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<!-- Return false if the two nodesets are not identical
|
||||
-->
|
||||
|
||||
<xsl:template name="cmp:cmp">
|
||||
<xsl:param name="ns1"/>
|
||||
<xsl:param name="ns2"/>
|
||||
<xsl:param name="depth"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test='count($ns1) != count($ns2)'>
|
||||
<xsl:value-of select='"countDiff"'/>
|
||||
</xsl:when>
|
||||
<xsl:when test='count($ns1/attribute::*) != count($ns2/attribute::*)'>
|
||||
<xsl:value-of select='"countDiff"'/>
|
||||
</xsl:when>
|
||||
<xsl:when test='$ns1 and $ns2'>
|
||||
|
||||
<xsl:variable name='result'>
|
||||
<xsl:call-template name='cmp:cmp'>
|
||||
<xsl:with-param name='ns1' select='$ns1/*'/>
|
||||
<xsl:with-param name='ns2' select='$ns2/*'/>
|
||||
<xsl:with-param name='depth' select='$depth+1'/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test='$result = "countDiff"'>
|
||||
<xsl:value-of select='$result'/>
|
||||
</xsl:when>
|
||||
<xsl:when test='$result = "textDiff"'>
|
||||
<xsl:value-of select='$result'/>
|
||||
</xsl:when>
|
||||
<xsl:when test='$result = ""'>
|
||||
|
||||
<xsl:variable name='keyText1' select='name($ns1)'/>
|
||||
<xsl:variable name='keyText2' select='name($ns2)'/>
|
||||
|
||||
<xsl:choose>
|
||||
<!-- Check if the text of the nodesets are the same and the attributes-->
|
||||
<xsl:when test='$ns1 = $ns2 and $keyText1 = $keyText2'>
|
||||
|
||||
<!-- Check the attribute names are the same -->
|
||||
<!-- Number of attributes being different is caught higher up -->
|
||||
<xsl:if test='count($ns1/attribute::*)'>
|
||||
<xsl:for-each select='$ns1/attribute::*'>
|
||||
<xsl:variable name='i' select='position()'/>
|
||||
<xsl:variable name='name1' select='name(.)'/>
|
||||
<xsl:variable name='value1' select='.'/>
|
||||
|
||||
<xsl:for-each select='$ns2/attribute::*'>
|
||||
<xsl:variable name='j' select='position()'/>
|
||||
<xsl:variable name='name2' select='name(.)'/>
|
||||
<xsl:variable name='value2' select='.'/>
|
||||
|
||||
<xsl:if test='$i = $j and ($name1 != $name2 or
|
||||
$value1 != $value2)'>
|
||||
<xsl:value-of select='"textDiff"'/>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
</xsl:if>
|
||||
<!--
|
||||
<xsl:variable name='diffResult'>
|
||||
<xsl:call-template name='cmp:diff'>
|
||||
<xsl:with-param name='ns1' select='$ns1'/>
|
||||
<xsl:with-param name='ns2' select='$ns2'/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:if test='not($diffResult = "")'>
|
||||
<xsl:value-of select='"textDiff"'/>
|
||||
</xsl:if>
|
||||
-->
|
||||
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select='"textDiff"'/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:when>
|
||||
<xsl:when test='$ns1 and not($ns2)'>
|
||||
<xsl:value-of select='"structDiff"'/>
|
||||
</xsl:when>
|
||||
<xsl:when test='$ns2 and not($ns1)'>
|
||||
<xsl:value-of select='"structDiff"'/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
1447
texml-xsl/date-time.xsl
Normal file
1447
texml-xsl/date-time.xsl
Normal file
File diff suppressed because it is too large
Load Diff
90
texml-xsl/example.xsl
Normal file
90
texml-xsl/example.xsl
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<xsl:stylesheet
|
||||
version="1.0"
|
||||
extension-element-prefixes="doc"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
|
||||
xmlns:eg="http://xsltsl.org/example"
|
||||
>
|
||||
|
||||
<doc:reference xmlns="">
|
||||
<referenceinfo>
|
||||
<releaseinfo role="meta">
|
||||
$Id$
|
||||
</releaseinfo>
|
||||
<author>
|
||||
<surname>Ball</surname>
|
||||
<firstname>Steve</firstname>
|
||||
</author>
|
||||
<copyright>
|
||||
<year>2001</year>
|
||||
<holder>Steve Ball</holder>
|
||||
</copyright>
|
||||
</referenceinfo>
|
||||
|
||||
<title>Example Stylesheet</title>
|
||||
|
||||
<partintro>
|
||||
<section>
|
||||
<title>Introduction</title>
|
||||
|
||||
<para>This module provides a template for adding stylesheet modules to the XSLT Standard Library.</para>
|
||||
<para>To add a new module to the library, follow these easy steps:</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Copy this file and replace its contents with the new module templates and documentation.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Copy the corresponding test file in the <filename>test</filename> directory. Replace its contents with tests for the new module.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Add an include element in the <filename>stdlib.xsl</filename> stylesheet.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Add an entry in the <filename>test/test.xml</filename> file.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Add entries in the <filename>test/test.xsl</filename> stylesheet.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Add an entry in the <filename>doc/build.xml</filename> file.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
<para>The <filename>example.xsl</filename> stylesheet provides a more extensive example.</para>
|
||||
|
||||
</section>
|
||||
</partintro>
|
||||
|
||||
</doc:reference>
|
||||
|
||||
<doc:template name="eg:example" xmlns="">
|
||||
<refpurpose>Template Example</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>Provides a template for writing templates. Replace this paragraph with a description of your template</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>text</term>
|
||||
<listitem>
|
||||
<para>The example string</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns nothing.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="eg:example">
|
||||
<xsl:param name="text"/>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
789
texml-xsl/markup.xsl
Normal file
789
texml-xsl/markup.xsl
Normal file
@ -0,0 +1,789 @@
|
||||
<xsl:stylesheet version='1.0'
|
||||
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
|
||||
xmlns:doc='http://xsltsl.org/xsl/documentation/1.0'
|
||||
xmlns:markup='http://xsltsl.org/markup'
|
||||
xmlns:str='http://xsltsl.org/string'
|
||||
extension-element-prefixes='doc markup str'>
|
||||
|
||||
<doc:reference xmlns=''>
|
||||
<referenceinfo>
|
||||
<releaseinfo role="meta">
|
||||
$Id$
|
||||
</releaseinfo>
|
||||
<author>
|
||||
<surname>Ball</surname>
|
||||
<firstname>Steve</firstname>
|
||||
</author>
|
||||
<copyright>
|
||||
<year>2003</year>
|
||||
<year>2001</year>
|
||||
<holder>Steve Ball</holder>
|
||||
</copyright>
|
||||
</referenceinfo>
|
||||
|
||||
<title>XML Markup Templates</title>
|
||||
|
||||
<partintro>
|
||||
<section>
|
||||
<title>Introduction</title>
|
||||
|
||||
<para>This stylesheet module provides functions for generating literal XML markup.</para>
|
||||
|
||||
</section>
|
||||
</partintro>
|
||||
|
||||
</doc:reference>
|
||||
|
||||
<doc:template name="markup:xml-declaration" xmlns="">
|
||||
<refpurpose>Create an XML Declaration</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns an XML Declaration. Although the XSLT standard provides control over the generation of the XML Declaration, this template may be useful in circumstances where the values must be computed at runtime.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>version</term>
|
||||
<listitem>
|
||||
<para>Version number.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>standalone</term>
|
||||
<listitem>
|
||||
<para>Standalone indication. Must be value "yes" or "no".</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>encoding</term>
|
||||
<listitem>
|
||||
<para>Character encoding.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns an XML Declaration as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:xml-declaration'>
|
||||
<xsl:param name='version' select="'1.0'"/>
|
||||
<xsl:param name='standalone'/>
|
||||
<xsl:param name='encoding'/>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'><?xml version="</xsl:text>
|
||||
<xsl:copy-of select="$version"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($standalone) = 0"/>
|
||||
<xsl:when test='$standalone = "yes" or $standalone = "no"'>
|
||||
<xsl:text> standalone="</xsl:text>
|
||||
<xsl:copy-of select="$standalone"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">invalid value "<xsl:value-of select="$standalone"/>" for standalone attribute</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:if test='string-length($encoding) > 0'>
|
||||
<xsl:text> encoding="</xsl:text>
|
||||
<xsl:copy-of select='$encoding'/>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'>?>
|
||||
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="markup:doctype-declaration" xmlns="">
|
||||
<refpurpose>Create a Document Type Declaration</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns a Document Type Declaration. Although the XSLT standard provides control over the generation of a Document Type Declaration, this template may be useful in circumstances where the values for the identifiers or the internal subset must be computed at runtime.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>docel</term>
|
||||
<listitem>
|
||||
<para>The name of the document element.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>publicid</term>
|
||||
<listitem>
|
||||
<para>The public identifier for the external DTD subset.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>systemid</term>
|
||||
<listitem>
|
||||
<para>The system identifier for the external DTD subset.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>internaldtd</term>
|
||||
<listitem>
|
||||
<para>The internal DTD subset.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns a Document Type Declaration as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:doctype-declaration'>
|
||||
<xsl:param name='docel'/>
|
||||
<xsl:param name='publicid'/>
|
||||
<xsl:param name='systemid'/>
|
||||
<xsl:param name='internaldtd'/>
|
||||
|
||||
<xsl:if test='string-length($docel) = 0'>
|
||||
<xsl:message terminate='yes'>No document element specified</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'><!DOCTYPE </xsl:text>
|
||||
<xsl:copy-of select="$docel"/>
|
||||
|
||||
<xsl:call-template name='markup:external-identifier'>
|
||||
<xsl:with-param name='publicid' select='$publicid'/>
|
||||
<xsl:with-param name='systemid' select='$systemid'/>
|
||||
<xsl:with-param name='leading-space' select='true()'/>
|
||||
</xsl:call-template>
|
||||
|
||||
<xsl:if test='string-length($internaldtd) > 0'>
|
||||
<xsl:text> [</xsl:text>
|
||||
<xsl:copy-of select='$internaldtd'/>
|
||||
<xsl:text>]</xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'>>
|
||||
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="markup:element-declaration" xmlns="">
|
||||
<refpurpose>Create an Element Declaration</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns an element declaration..</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>type</term>
|
||||
<listitem>
|
||||
<para>The element type.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>content-spec</term>
|
||||
<listitem>
|
||||
<para>The content specification.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns an element declaration as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:element-declaration'>
|
||||
<xsl:param name='type'/>
|
||||
<xsl:param name='content-spec' select="'ANY'"/>
|
||||
|
||||
<xsl:if test='string-length($type) = 0'>
|
||||
<xsl:message terminate='yes'>element type must be specified</xsl:message>
|
||||
</xsl:if>
|
||||
<xsl:if test='string-length($content-spec) = 0'>
|
||||
<xsl:message terminate='yes'>content specification must be specified</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'><!ELEMENT </xsl:text>
|
||||
<xsl:copy-of select='$type'/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:copy-of select='$content-spec'/>
|
||||
<xsl:text disable-output-escaping='yes'>></xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="markup:attlist-declaration" xmlns="">
|
||||
<refpurpose>Create an Attribute List Declaration</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns an attribute list declaration.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>type</term>
|
||||
<listitem>
|
||||
<para>The element type.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>attr-defns</term>
|
||||
<listitem>
|
||||
<para>Attribute definitions.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns an attribute list declaration as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:attlist-declaration'>
|
||||
<xsl:param name='type'/>
|
||||
<xsl:param name='attr-defns'/>
|
||||
|
||||
<xsl:if test='string-length($type) = 0'>
|
||||
<xsl:message terminate='yes'>element type must be specified</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'><!ATTLIST </xsl:text>
|
||||
<xsl:copy-of select='$type'/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:copy-of select='$attr-defns'/>
|
||||
<xsl:text disable-output-escaping='yes'>></xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="markup:attribute-definition" xmlns="">
|
||||
<refpurpose>Create an Attribute Definition</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns an attribute definition.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>name</term>
|
||||
<listitem>
|
||||
<para>The attribute name.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>type</term>
|
||||
<listitem>
|
||||
<para>The attribute type.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>default</term>
|
||||
<listitem>
|
||||
<para>The attribute default.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns an attribute definition as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:attribute-definition'>
|
||||
<xsl:param name='name'/>
|
||||
<xsl:param name='type'/>
|
||||
<xsl:param name='default'/>
|
||||
|
||||
<xsl:if test='string-length($name) = 0'>
|
||||
<xsl:message terminate='yes'>attribute name must be specified</xsl:message>
|
||||
</xsl:if>
|
||||
<xsl:if test='string-length($type) = 0'>
|
||||
<xsl:message terminate='yes'>attribute type must be specified</xsl:message>
|
||||
</xsl:if>
|
||||
<xsl:if test='string-length($default) = 0'>
|
||||
<xsl:message terminate='yes'>attribute default must be specified</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:copy-of select='$name'/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:copy-of select='$type'/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:copy-of select='$default'/>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="markup:entity-declaration" xmlns="">
|
||||
<refpurpose>Create an Entity Declaration</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns an entity declaration.</para>
|
||||
<para>If the 'text' parameter is given a value, then an internal entity is created. If either the 'publicid' or 'systemid' parameters are given a value then an external entity is created. It is an error for the 'text' parameter to have value as well as the 'publicid', 'systemid' or 'notation' parameters.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>name</term>
|
||||
<listitem>
|
||||
<para>The entity name.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>parameter</term>
|
||||
<listitem>
|
||||
<para>Boolean value to determine whether a parameter entity is created. Default is 'false()'.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>text</term>
|
||||
<listitem>
|
||||
<para>The replacement text. Must be a string.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>nodes</term>
|
||||
<listitem>
|
||||
<para>The replacement text as a nodeset. The nodeset is formatted as XML using the as-xml template. If both text and nodes are specified then nodes takes precedence.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>publicid</term>
|
||||
<listitem>
|
||||
<para>The public identifier for an external entity.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>systemid</term>
|
||||
<listitem>
|
||||
<para>The system identifier for an external entity.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>notation</term>
|
||||
<listitem>
|
||||
<para>The notation for an external entity.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns an entity declaration as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:entity-declaration'>
|
||||
<xsl:param name='name'/>
|
||||
<xsl:param name='parameter' select='false()'/>
|
||||
<xsl:param name='text'/>
|
||||
<xsl:param name='nodes'/>
|
||||
<xsl:param name='publicid'/>
|
||||
<xsl:param name='systemid'/>
|
||||
<xsl:param name='notation'/>
|
||||
|
||||
<xsl:if test='string-length($name) = 0'>
|
||||
<xsl:message terminate='yes'>entity name must be specified</xsl:message>
|
||||
</xsl:if>
|
||||
<xsl:if test='string-length($text) > 0 and
|
||||
(string-length($publicid) > 0 or
|
||||
string-length($systemid) > 0 or
|
||||
string-length($notation) > 0)'>
|
||||
<xsl:message terminate='yes'>both replacement text and external identifier specified</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'><!ENTITY </xsl:text>
|
||||
<xsl:copy-of select='$name'/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="$parameter">
|
||||
<xsl:text>% </xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$nodes">
|
||||
<xsl:call-template name='markup:quote-value'>
|
||||
<xsl:with-param name='value'>
|
||||
<xsl:call-template name="markup:as-xml">
|
||||
<xsl:with-param name="nodes" select="$nodes"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test='$text'>
|
||||
<xsl:call-template name='markup:quote-value'>
|
||||
<xsl:with-param name='value' select='$text'/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name='markup:external-identifier'>
|
||||
<xsl:with-param name='publicid' select='$publicid'/>
|
||||
<xsl:with-param name='systemid' select='$systemid'/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:if test='$notation'>
|
||||
<xsl:text> NDATA "</xsl:text>
|
||||
<xsl:copy-of select='$notation'/>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'>></xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="markup:quote-value" xmlns="">
|
||||
<refpurpose>Quote an Attribute Value</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns a quoted value.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>value</term>
|
||||
<listitem>
|
||||
<para>The value to quote.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns a quote value as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:quote-value'>
|
||||
<xsl:param name='value'/>
|
||||
|
||||
<xsl:variable name="quoted">
|
||||
<xsl:call-template name='markup:quote-value-aux'>
|
||||
<xsl:with-param name='value' select='$value'/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($value, '<')">
|
||||
<xsl:call-template name='str:subst'>
|
||||
<xsl:with-param name='text' select='$quoted'/>
|
||||
<xsl:with-param name='replace'><</xsl:with-param>
|
||||
<xsl:with-param name='with'>
|
||||
<xsl:text disable-output-escaping='yes'>&lt;</xsl:text>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:copy-of select='$quoted'/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name='markup:quote-value-aux'>
|
||||
<xsl:param name='value'/>
|
||||
|
||||
<!-- Quoting hell! -->
|
||||
<xsl:variable name="quot">"</xsl:variable>
|
||||
<xsl:variable name="apos">'</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test='contains($value, $quot) and contains($value, $apos)'>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name='str:subst'>
|
||||
<xsl:with-param name='text' select='$value'/>
|
||||
<xsl:with-param name='replace'>"</xsl:with-param>
|
||||
<xsl:with-param name='with'>
|
||||
<xsl:text disable-output-escaping='yes'>&quot;</xsl:text>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='contains($value, $quot)'>
|
||||
<xsl:text>'</xsl:text>
|
||||
<xsl:value-of select='$value'/>
|
||||
<xsl:text>'</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select='$value'/>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="markup:external-identifier" xmlns="">
|
||||
<refpurpose>Create an External Identifier</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns an external identifier.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>publicid</term>
|
||||
<listitem>
|
||||
<para>The public identifier.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>systemid</term>
|
||||
<listitem>
|
||||
<para>The system identifier.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns an external identifier as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:external-identifier'>
|
||||
<xsl:param name='publicid'/>
|
||||
<xsl:param name='systemid'/>
|
||||
<xsl:param name='leading-space' select='false()'/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test='string-length($publicid) > 0'>
|
||||
<xsl:if test='$leading-space'>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text disable-output-escaping='yes'>PUBLIC "</xsl:text>
|
||||
<xsl:value-of select='$publicid' disable-output-escaping='yes'/>
|
||||
<xsl:text disable-output-escaping='yes'>"</xsl:text>
|
||||
<xsl:if test='string-length($systemid) > 0'>
|
||||
<xsl:text disable-output-escaping='yes'> "</xsl:text>
|
||||
<xsl:value-of select='$systemid' disable-output-escaping='yes'/>
|
||||
<xsl:text disable-output-escaping='yes'>"</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:when test="string-length($systemid) > 0">
|
||||
<xsl:if test='$leading-space'>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text disable-output-escaping='yes'>SYSTEM "</xsl:text>
|
||||
<xsl:value-of select='$systemid' disable-output-escaping='yes'/>
|
||||
<xsl:text disable-output-escaping='yes'>"</xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="markup:entity-reference" xmlns="">
|
||||
<refpurpose>Create an Entity Reference</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns an entity reference.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>name</term>
|
||||
<listitem>
|
||||
<para>The name of the entity.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns an entity reference as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:entity-reference'>
|
||||
<xsl:param name='name'/>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'>&</xsl:text>
|
||||
<xsl:value-of select='$name'/>
|
||||
<xsl:text>;</xsl:text>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="markup:notation-declaration" xmlns="">
|
||||
<refpurpose>Create a Notation Declaration</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns a notation declaration.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>name</term>
|
||||
<listitem>
|
||||
<para>The notation name.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>publicid</term>
|
||||
<listitem>
|
||||
<para>The public identifier for the notation.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>systemid</term>
|
||||
<listitem>
|
||||
<para>The system identifier for the notation.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns a notation declaration as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:notation-declaration'>
|
||||
<xsl:param name='name'/>
|
||||
<xsl:param name='publicid'/>
|
||||
<xsl:param name='systemid'/>
|
||||
|
||||
<xsl:if test='string-length($name) = 0'>
|
||||
<xsl:message terminate='yes'>notation name must be specified</xsl:message>
|
||||
</xsl:if>
|
||||
<xsl:if test='string-length($publicid) = 0 and string-length($systemid) = 0'>
|
||||
<xsl:message terminate='yes'>external identifier must be specified</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'><!NOTATION </xsl:text>
|
||||
<xsl:copy-of select='$name'/>
|
||||
|
||||
<xsl:call-template name='markup:external-identifier'>
|
||||
<xsl:with-param name='publicid' select='$publicid'/>
|
||||
<xsl:with-param name='systemid' select='$systemid'/>
|
||||
<xsl:with-param name='leading-space' select='true()'/>
|
||||
</xsl:call-template>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'>></xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="markup:cdata-section" xmlns="">
|
||||
<refpurpose>Create a CDATA Section</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns a CDATA Section. The XSLT specification provides a mechanism for instructing the XSL processor to output character data in a CDATA section for certain elements, but this template may be useful in those circumstances where not all instances of an element are to have their content placed in a CDATA section.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>text</term>
|
||||
<listitem>
|
||||
<para>The content of the CDATA section.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns a CDATA section as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:cdata-section'>
|
||||
<xsl:param name='text'/>
|
||||
|
||||
<xsl:if test="contains($text, ']]>')">
|
||||
<xsl:message terminate="yes">CDATA section contains "]]>"</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text disable-output-escaping='yes'><![CDATA[</xsl:text>
|
||||
<xsl:copy-of select='$text'/>
|
||||
<xsl:text disable-output-escaping='yes'>]]></xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="markup:as-xml" xmlns="">
|
||||
<refpurpose>Format Nodeset As XML Markup</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns XML markup. Each node in the given nodeset is converted to its equivalent XML markup.</para>
|
||||
|
||||
<para>BUG: This version may not adequately handle XML Namespaces.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>nodes</term>
|
||||
<listitem>
|
||||
<para>Nodeset to format as XML.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns XML markup.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='markup:as-xml'>
|
||||
<xsl:param name='nodes'/>
|
||||
|
||||
<xsl:if test="$nodes">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$nodes[1]/self::*">
|
||||
<xsl:text disable-output-escaping='yes'><</xsl:text>
|
||||
<xsl:value-of select="name($nodes[1])"/>
|
||||
<xsl:for-each select="$nodes[1]/@*">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="name()"/>
|
||||
<xsl:text>=</xsl:text>
|
||||
<xsl:call-template name='markup:quote-value'>
|
||||
<xsl:with-param name='value' select='.'/>
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test='$nodes[1]/node()'>
|
||||
<xsl:text disable-output-escaping='yes'>></xsl:text>
|
||||
<xsl:call-template name='markup:as-xml'>
|
||||
<xsl:with-param name='nodes' select='$nodes[1]/node()'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text disable-output-escaping='yes'></</xsl:text>
|
||||
<xsl:value-of select="name($nodes[1])"/>
|
||||
<xsl:text disable-output-escaping='yes'>></xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text disable-output-escaping='yes'>/></xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="$nodes[1]/self::text()">
|
||||
<xsl:value-of select="$nodes[1]"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$nodes[1]/self::comment()">
|
||||
<xsl:text disable-output-escaping='yes'><!--</xsl:text>
|
||||
<xsl:value-of select="$nodes[1]"/>
|
||||
<xsl:text disable-output-escaping='yes'>--></xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$nodes[1]/self::processing-instruction()">
|
||||
<xsl:text disable-output-escaping='yes'><?</xsl:text>
|
||||
<xsl:value-of select="name($nodes[1])"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="$nodes[1]"/>
|
||||
<xsl:text disable-output-escaping='yes'>?></xsl:text>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="not($nodes[1]/parent::*)"/> <!-- root node -->
|
||||
<xsl:when test="count($nodes[1] | $nodes[1]/../namespace::*) = count($nodes[1]/../namespace::*)"/> <!-- namespace node -->
|
||||
<xsl:when test="count($nodes[1] | $nodes[1]/../@*) = count($nodes[1]/../@*)"/> <!-- attribute node -->
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:call-template name="markup:as-xml">
|
||||
<xsl:with-param name="nodes" select="$nodes[position() > 1]"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
618
texml-xsl/math.xsl
Normal file
618
texml-xsl/math.xsl
Normal file
@ -0,0 +1,618 @@
|
||||
<?xml version="1.0"?>
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
|
||||
xmlns:math="http://xsltsl.org/math"
|
||||
exclude-result-prefixes="doc math">
|
||||
|
||||
<doc:reference xmlns="">
|
||||
<referenceinfo>
|
||||
<releaseinfo role="meta">
|
||||
$Id$
|
||||
</releaseinfo>
|
||||
<author>
|
||||
<surname>Ball</surname>
|
||||
<firstname>Steve</firstname>
|
||||
</author>
|
||||
<copyright>
|
||||
<year>2004</year>
|
||||
<year>2002</year>
|
||||
<holder>Steve Ball</holder>
|
||||
</copyright>
|
||||
</referenceinfo>
|
||||
|
||||
<title>Math Module</title>
|
||||
|
||||
<partintro>
|
||||
<section>
|
||||
<title>Introduction</title>
|
||||
|
||||
<para>This module provides mathematical functions.</para>
|
||||
</section>
|
||||
</partintro>
|
||||
|
||||
</doc:reference>
|
||||
|
||||
<doc:template name="math:power" xmlns="">
|
||||
<refpurpose>Power</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>Raises a number to a power.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>base</term>
|
||||
<listitem>
|
||||
<para>The base number. Must be a number.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>power</term>
|
||||
<listitem>
|
||||
<para>The power to raise the number to. Must be an integer.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns base multiplied by itself power times. If the base or power are not numbers or if the power is fractional then an empty string is returned.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="math:power">
|
||||
<xsl:param name="base"/>
|
||||
<xsl:param name="power"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test='$power = "0" and $base = "0"'>
|
||||
<xsl:text>1</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$power = "0" and number($base)'>
|
||||
<xsl:text>1</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$power = "0" and not(number($base))'/>
|
||||
<xsl:when test='$base = "0" and number($power)'>
|
||||
<xsl:text>0</xsl:text>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test='not(number($base)) or not(number($power))'/>
|
||||
|
||||
<xsl:when test='floor(number($power)) != number($power)'/>
|
||||
|
||||
<xsl:when test='number($power) < 0'>
|
||||
<xsl:variable name='x'>
|
||||
<xsl:call-template name='math:power'>
|
||||
<xsl:with-param name='base' select='$base'/>
|
||||
<xsl:with-param name='power' select='-1 * $power'/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select='1 div $x'/>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test='number($power) = 1'>
|
||||
<xsl:value-of select='$base'/>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test='number($power) > 0'>
|
||||
<xsl:variable name='x'>
|
||||
<xsl:call-template name='math:power'>
|
||||
<xsl:with-param name='base' select='$base'/>
|
||||
<xsl:with-param name='power' select='$power - 1'/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select='$base * $x'/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise/>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="math:cvt-hex-decimal" xmlns="">
|
||||
<refpurpose>Conversion</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>Converts a hexidecimal value to a decimal value.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>value</term>
|
||||
<listitem>
|
||||
<para>The hexidecimal number. Must be a number in hexidecimal format.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns the value as a decimal string. If the value is not a number then a NaN value is returned.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="math:cvt-hex-decimal">
|
||||
<xsl:param name="value"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test='$value = ""'/>
|
||||
|
||||
<xsl:when test='string-length($value) = 1'>
|
||||
<xsl:call-template name='math:cvt-hex-decimal-digit'>
|
||||
<xsl:with-param name='digit' select='$value'/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name='first-digit'>
|
||||
<xsl:call-template name='math:cvt-hex-decimal-digit'>
|
||||
<xsl:with-param name='digit' select='substring($value, 1, 1)'/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name='remainder'>
|
||||
<xsl:call-template name='math:cvt-hex-decimal'>
|
||||
<xsl:with-param name='value' select='substring($value, 2)'/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:value-of select='$first-digit * 16 + $remainder'/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name='math:cvt-hex-decimal-digit'>
|
||||
<xsl:param name='digit' select='0'/>
|
||||
<xsl:choose>
|
||||
<xsl:when test='$digit <= 9'>
|
||||
<xsl:value-of select='$digit'/>
|
||||
</xsl:when>
|
||||
<xsl:when test='$digit = "a" or $digit = "A"'>10</xsl:when>
|
||||
<xsl:when test='$digit = "b" or $digit = "B"'>11</xsl:when>
|
||||
<xsl:when test='$digit = "c" or $digit = "C"'>12</xsl:when>
|
||||
<xsl:when test='$digit = "d" or $digit = "D"'>13</xsl:when>
|
||||
<xsl:when test='$digit = "e" or $digit = "E"'>14</xsl:when>
|
||||
<xsl:when test='$digit = "f" or $digit = "F"'>15</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="math:ordinal" xmlns="">
|
||||
<refpurpose>Ordinal number</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>Gives the ordinal number of a given counting number. For example, 1 becomes "1st".</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>number</term>
|
||||
<listitem>
|
||||
<para>An integer number.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns the number with an ordinal suffix.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="math:ordinal">
|
||||
<xsl:param name="number"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test='$number < 0'/>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select='$number'/>
|
||||
<xsl:choose>
|
||||
<xsl:when test='$number = 11 or $number = 12 or $number = 13'>th</xsl:when>
|
||||
<xsl:when test='$number mod 10 = 1'>st</xsl:when>
|
||||
<xsl:when test='$number mod 10 = 2'>nd</xsl:when>
|
||||
<xsl:when test='$number mod 10 = 3'>rd</xsl:when>
|
||||
<xsl:otherwise>th</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<doc:template name="math:ordinal-as-word" xmlns="">
|
||||
<refpurpose>Returns an ordinal number</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns the ordinal number for a given counting number as a word. For example "first" for 1.</para>
|
||||
<para>Only handles numbers less than 10000000 (ten million).</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>number</term>
|
||||
<listitem>
|
||||
<para>The counting number.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>conjunctive</term>
|
||||
<listitem>
|
||||
<para>Whether to add the word "and" to the result, for example "one hundred and first" rather than "one hundred first". Default is "yes".</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns the ordinal number as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="math:ordinal-as-word">
|
||||
<xsl:param name="number" select="0"/>
|
||||
<xsl:param name='conjunctive' select='"yes"'/>
|
||||
<xsl:param name='preceding' select='0'/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test='$preceding = 1 and $number = 0'/>
|
||||
<xsl:when test='$number = 0'>zeroth</xsl:when>
|
||||
|
||||
<xsl:when test="$number < 1 or $number != floor($number)"/>
|
||||
|
||||
<xsl:when test='$number = 1'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>first</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 2'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>second</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 3'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>third</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 4'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>fourth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 5'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>fifth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 6'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>sixth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 7'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>seventh</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 8'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>eighth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 9'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>ninth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 10'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>tenth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 11'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>eleventh</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 12'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>twelveth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 13'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>thirteenth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 14'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>fourteenth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 15'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>fifteenth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 16'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>sixteenth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 17'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>seventeenth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 18'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>eighteenth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 19'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>nineteenth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 20'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>twentieth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 30'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>thirtieth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 40'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>fortieth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 50'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>fiftieth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 60'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>sixtieth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 70'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>seventieth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 80'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>eightieth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number = 90'>
|
||||
<xsl:if test='$preceding = 1'> and </xsl:if>
|
||||
<xsl:text>ninetieth</xsl:text>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test='$number mod 1000000 = 0'>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 1000000)'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> millionth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number < 1000000 and $number mod 1000 = 0'>
|
||||
<xsl:if test='$preceding = 1 and $conjunctive'> and </xsl:if>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 1000)'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> thousandth</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number < 1000 and $number mod 100 = 0'>
|
||||
<xsl:if test='$preceding = 1 and $conjunctive'> and </xsl:if>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 100)'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> hundredth</xsl:text>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test='$number > 1000000'>
|
||||
<xsl:if test='$preceding = 1'>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test='$conjunctive'>and </xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 1000000) * 1000000'/>
|
||||
</xsl:call-template>
|
||||
<xsl:choose>
|
||||
<xsl:when
|
||||
test='(floor(floor(($number mod 1000000) + 0.1) div 100000) > 0 and $number mod 100000 > 0) or
|
||||
(floor(floor(($number mod 100000) + 0.1) div 10000) > 0 and $number mod 10000 > 0) or
|
||||
(floor(floor(($number mod 10000) + 0.1) div 1000) > 0 and $number mod 1000 > 0) or
|
||||
(floor(floor(($number mod 1000) + 0.1) div 100) > 0 and $number mod 100 > 0) or
|
||||
(floor(floor(($number mod 100) + 0.1) div 10) > 0 and $number mod 10 > 0 and $number mod 100 > 20)'>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name='math:ordinal-as-word'>
|
||||
<xsl:with-param name='number' select='floor(($number mod 1000000) + 0.1)'/>
|
||||
<xsl:with-param name='conjunctive' select='$conjunctive'/>
|
||||
<xsl:with-param name='preceding' select='0'/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name='math:ordinal-as-word'>
|
||||
<xsl:with-param name='number' select='floor(($number mod 1000000) + 0.1)'/>
|
||||
<xsl:with-param name='conjunctive' select='$conjunctive'/>
|
||||
<xsl:with-param name='preceding' select='1'/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number > 1000'>
|
||||
<xsl:if test='$preceding = 1'>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test='$conjunctive'>and </xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 1000) * 1000'/>
|
||||
<xsl:with-param name='conjunctive' select='$conjunctive'/>
|
||||
</xsl:call-template>
|
||||
<xsl:choose>
|
||||
<xsl:when test='floor(floor(($number mod 1000) + 0.1) div 100) > 0'>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name='math:ordinal-as-word'>
|
||||
<xsl:with-param name='number' select='floor(($number mod 1000) + 0.1)'/>
|
||||
<xsl:with-param name='conjunctive' select='$conjunctive'/>
|
||||
<xsl:with-param name='preceding' select='0'/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name='math:ordinal-as-word'>
|
||||
<xsl:with-param name='number' select='floor(($number mod 1000) + 0.1)'/>
|
||||
<xsl:with-param name='conjunctive' select='$conjunctive'/>
|
||||
<xsl:with-param name='preceding' select='1'/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number > 100'>
|
||||
<xsl:if test='$preceding = 1'>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test='$conjunctive'>and </xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 100) * 100'/>
|
||||
</xsl:call-template>
|
||||
<xsl:call-template name='math:ordinal-as-word'>
|
||||
<xsl:with-param name='number' select='floor(($number mod 100) + 0.1)'/>
|
||||
<xsl:with-param name='conjunctive' select='$conjunctive'/>
|
||||
<xsl:with-param name='preceding' select='1'/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test='$number > 20'>
|
||||
<xsl:if test='$preceding = 1'>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test='$conjunctive'>and </xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 10) * 10'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name='math:ordinal-as-word'>
|
||||
<xsl:with-param name='number' select='floor(($number mod 10) + 0.1)'/>
|
||||
<xsl:with-param name='conjunctive' select='$conjunctive'/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:otherwise/>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="math:number-as-word" xmlns="">
|
||||
<refpurpose>Returns a number as a word</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns the word for a given integer number, for example "one" for 1.</para>
|
||||
<para>Only handles numbers less than 10000000 (ten million).</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>number</term>
|
||||
<listitem>
|
||||
<para>The counting number.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>conjunctive</term>
|
||||
<listitem>
|
||||
<para>Adds the word "and" where appropriate, for example.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns the number as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="math:number-as-word">
|
||||
<xsl:param name="number" select="0"/>
|
||||
<xsl:param name='conjunctive' select='true()'/>
|
||||
|
||||
<xsl:choose>
|
||||
|
||||
<xsl:when test='$number = 0'>zero</xsl:when>
|
||||
|
||||
<xsl:when test='$number < 0'>
|
||||
<xsl:text>minus </xsl:text>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='-1 * $number'/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="$number != floor($number)"/>
|
||||
|
||||
<xsl:when test='$number mod 1000000 = 0'>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 1000000)'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> million</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number >= 1000000'>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 1000000)'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> million </xsl:text>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor(($number mod 1000000) + 0.1)'/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number mod 1000 = 0'>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 1000)'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> thousand</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number >= 1000'>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 1000)'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> thousand </xsl:text>
|
||||
<xsl:if test='$conjunctive and floor(floor(($number mod 1000) + 0.1) div 100) = 0'>and </xsl:if>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor(($number mod 1000) + 0.1)'/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number mod 100 = 0'>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 100)'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> hundred</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number >= 100'>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 100)'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> hundred </xsl:text>
|
||||
<xsl:if test='$conjunctive'>and </xsl:if>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor(($number mod 100) + 0.1)'/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test='$number = 1'>one</xsl:when>
|
||||
<xsl:when test='$number = 2'>two</xsl:when>
|
||||
<xsl:when test='$number = 3'>three</xsl:when>
|
||||
<xsl:when test='$number = 4'>four</xsl:when>
|
||||
<xsl:when test='$number = 5'>five</xsl:when>
|
||||
<xsl:when test='$number = 6'>six</xsl:when>
|
||||
<xsl:when test='$number = 7'>seven</xsl:when>
|
||||
<xsl:when test='$number = 8'>eight</xsl:when>
|
||||
<xsl:when test='$number = 9'>nine</xsl:when>
|
||||
<xsl:when test='$number = 10'>ten</xsl:when>
|
||||
<xsl:when test='$number = 11'>eleven</xsl:when>
|
||||
<xsl:when test='$number = 12'>twelve</xsl:when>
|
||||
<xsl:when test='$number = 13'>thirteen</xsl:when>
|
||||
<xsl:when test='$number = 14'>fourteen</xsl:when>
|
||||
<xsl:when test='$number = 15'>fifteen</xsl:when>
|
||||
<xsl:when test='$number = 16'>sixteen</xsl:when>
|
||||
<xsl:when test='$number = 17'>seventeen</xsl:when>
|
||||
<xsl:when test='$number = 18'>eighteen</xsl:when>
|
||||
<xsl:when test='$number = 19'>nineteen</xsl:when>
|
||||
<xsl:when test='$number = 20'>twenty</xsl:when>
|
||||
<xsl:when test='$number = 30'>thirty</xsl:when>
|
||||
<xsl:when test='$number = 40'>forty</xsl:when>
|
||||
<xsl:when test='$number = 50'>fifty</xsl:when>
|
||||
<xsl:when test='$number = 60'>sixty</xsl:when>
|
||||
<xsl:when test='$number = 70'>seventy</xsl:when>
|
||||
<xsl:when test='$number = 80'>eighty</xsl:when>
|
||||
<xsl:when test='$number = 90'>ninety</xsl:when>
|
||||
|
||||
<xsl:when test='$number < 100'>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor($number div 10) * 10'/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name='math:number-as-word'>
|
||||
<xsl:with-param name='number' select='floor(($number mod 10) + 0.1)'/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
|
229
texml-xsl/node.xsl
Normal file
229
texml-xsl/node.xsl
Normal file
@ -0,0 +1,229 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
|
||||
xmlns:node="http://xsltsl.org/node"
|
||||
extension-element-prefixes="doc node">
|
||||
|
||||
<doc:reference xmlns="">
|
||||
<referenceinfo>
|
||||
<releaseinfo role="meta">
|
||||
$Id$
|
||||
</releaseinfo>
|
||||
<author>
|
||||
<surname>Ball</surname>
|
||||
<firstname>Steve</firstname>
|
||||
</author>
|
||||
<copyright>
|
||||
<year>2001</year>
|
||||
<holder>Steve Ball</holder>
|
||||
</copyright>
|
||||
</referenceinfo>
|
||||
|
||||
<title>Node Templates</title>
|
||||
|
||||
<partintro>
|
||||
<section>
|
||||
<title>Introduction</title>
|
||||
|
||||
<para>This stylesheet module provides functions for reporting on or manipulating nodes and nodesets.</para>
|
||||
|
||||
</section>
|
||||
</partintro>
|
||||
|
||||
</doc:reference>
|
||||
|
||||
<doc:template name="node:xpath" xmlns="">
|
||||
<refpurpose>Returns an XPath location path</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template returns an XPath location path that uniquely identifies the given node within the document.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>node</term>
|
||||
<listitem>
|
||||
<para>The node to create an XPath for. If this parameter is given as a nodeset, then the first node in the nodeset is used.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns an XPath location path as a string.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="node:xpath">
|
||||
<xsl:param name="node" select="."/>
|
||||
|
||||
<xsl:choose>
|
||||
|
||||
<xsl:when test="$node">
|
||||
|
||||
<xsl:for-each select="$node[1]/ancestor-or-self::*">
|
||||
<xsl:text/>/<xsl:value-of select="name()"/>
|
||||
<xsl:text/>[<xsl:value-of select="count(preceding-sibling::*[name() = name(current())]) + 1"/>]<xsl:text/>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:choose>
|
||||
|
||||
<xsl:when test="$node[1]/self::comment()">
|
||||
<xsl:text>/comment()</xsl:text>
|
||||
<xsl:text/>[<xsl:value-of select="count($node[1]/preceding-sibling::comment()) + 1" />]<xsl:text/>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="$node[1]/self::processing-instruction()">
|
||||
<xsl:text>/processing-instruction()</xsl:text>
|
||||
<xsl:text/>[<xsl:value-of select="count($node[1]/preceding-sibling::processing-instruction()) + 1" />]<xsl:text/>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="$node[1]/self::text()">
|
||||
<xsl:text>/text()</xsl:text>
|
||||
<xsl:text/>[<xsl:value-of select="count($node[1]/preceding-sibling::text()) + 1" />]<xsl:text/>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="not($node[1]/..)">
|
||||
<xsl:text>/</xsl:text>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="count($node[1]/../namespace::* | $node[1]) = count($node[1]/../namespace::*)">
|
||||
<xsl:text/>/namespace::<xsl:value-of select="name($node[1])" />
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="count($node[1]/../@* | $node[1]) = count($node[1]/../@*)">
|
||||
<xsl:text/>/@<xsl:value-of select="name($node[1])" />
|
||||
</xsl:when>
|
||||
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:otherwise>
|
||||
<xsl:text>/..</xsl:text>
|
||||
</xsl:otherwise>
|
||||
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="node:type" xmlns="">
|
||||
<refpurpose>Return node type</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>Returns the type of a node as a string.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>node</term>
|
||||
<listitem>
|
||||
<para>The node to get the type for. If this parameter is given as a nodeset, then the first node in the nodeset is used.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns node type as a string. Values returned are:</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>Element</term>
|
||||
<listitem>
|
||||
<para><literal>element</literal></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Text Node</term>
|
||||
<listitem>
|
||||
<para><literal>text</literal></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Comment</term>
|
||||
<listitem>
|
||||
<para><literal>comment</literal></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>Processing Instruction</term>
|
||||
<listitem>
|
||||
<para><literal>processing instruction</literal></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="node:type">
|
||||
<xsl:param name="node" select="."/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="not($node)"/>
|
||||
<xsl:when test="$node[1]/self::*">
|
||||
<xsl:text>element</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$node[1]/self::text()">
|
||||
<xsl:text>text</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$node[1]/self::comment()">
|
||||
<xsl:text>comment</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$node[1]/self::processing-instruction()">
|
||||
<xsl:text>processing instruction</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="not($node[1]/parent::*)">
|
||||
<xsl:text>root</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="count($node[1] | $node[1]/../namespace::*) = count($node[1]/../namespace::*)">
|
||||
<xsl:text>namespace</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="count($node[1] | $node[1]/../@*) = count($node[1]/../@*)">
|
||||
<xsl:text>attribute</xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="node:copy" xmlns="">
|
||||
<refpurpose>Copy Nodes</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>Makes a copy of the given nodes, including attributes and descendants.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>nodes</term>
|
||||
<listitem>
|
||||
<para>The nodes to copy.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns the copied nodes as a result tree fragment.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name='node:copy'>
|
||||
<xsl:param name='nodes' select='.'/>
|
||||
|
||||
<xsl:for-each select='$nodes'>
|
||||
<xsl:copy>
|
||||
<xsl:for-each select='@*'>
|
||||
<xsl:copy/>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:for-each select='node()'>
|
||||
<xsl:call-template name='node:copy'/>
|
||||
</xsl:for-each>
|
||||
</xsl:copy>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
|
340
texml-xsl/stdlib.xsl
Normal file
340
texml-xsl/stdlib.xsl
Normal file
@ -0,0 +1,340 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE xsl:stylesheet [
|
||||
<!ENTITY version "1.2.1">
|
||||
]>
|
||||
|
||||
<xsl:stylesheet
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
|
||||
exclude-result-prefixes="doc"
|
||||
version="1.0">
|
||||
|
||||
<xsl:import href="string.xsl"/>
|
||||
<xsl:import href="date-time.xsl"/>
|
||||
<xsl:import href="node.xsl"/>
|
||||
<xsl:import href="uri.xsl"/>
|
||||
<xsl:import href="markup.xsl"/>
|
||||
<xsl:import href="math.xsl"/>
|
||||
<xsl:import href="cmp.xsl"/>
|
||||
|
||||
<xsl:import href="svg.xsl"/>
|
||||
<!--
|
||||
<xsl:import href="html/html.xsl"/>
|
||||
<xsl:import href="fo/fo.xsl"/>
|
||||
-->
|
||||
|
||||
<!-- For a new module, add an import element here -->
|
||||
<xsl:import href="example.xsl"/>
|
||||
|
||||
<doc:book xmlns="">
|
||||
<bookinfo>
|
||||
<title>XSLT Standard Library</title>
|
||||
<subtitle>Version &version;</subtitle>
|
||||
<!-- $Id$ -->
|
||||
|
||||
<author>
|
||||
<surname>Ball</surname>
|
||||
<firstname>Steve</firstname>
|
||||
</author>
|
||||
<copyright>
|
||||
<year>2004</year>
|
||||
<year>2002</year>
|
||||
<holder>Steve Ball</holder>
|
||||
</copyright>
|
||||
</bookinfo>
|
||||
|
||||
<preface>
|
||||
<para>The <ulink url="http://www.w3.org/Style/XSL">XSLT</ulink> Standard Library, <acronym>xsltsl</acronym>, provides the XSLT developer with a set of XSLT templates for commonly used functions. These are implemented purely in XSLT, that is they do not use any extensions.</para>
|
||||
<para><acronym>xsltsl</acronym> is a <ulink url="http://sourceforge.net/projects/xsltsl/">SourceForge project</ulink>.</para>
|
||||
<para><ulink url="http://sourceforge.net/"><inlinemediaobject>
|
||||
<imageobject>
|
||||
<imagedata fileref="sflogo.gif" width="88" height="31"/>
|
||||
</imageobject>
|
||||
<textobject>
|
||||
<phrase>SourceForge Logo</phrase>
|
||||
</textobject>
|
||||
</inlinemediaobject></ulink></para>
|
||||
<para>Goals of the <acronym>xsltsl</acronym> project include:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>Provision of a high-quality library of XSLT templates, suitable for inclusion by vendors in XSLT processor software products.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Demonstration of best practice in XSLT stylesheet development and documentation.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Provide examples of various techniques used to develop XSLT stylesheets (ie. a working FAQ).</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</preface>
|
||||
|
||||
<chapter>
|
||||
<title>Using The Library</title>
|
||||
|
||||
<para>There are two ways of using the library:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>Use a local copy of the library.</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Download the distribution (see below).</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Unpack the distribution, using either gunzip/tar or unzip.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>In your stylesheet import or include either the main stylesheet, <filename>stdlib.xsl</filename>, or the stylesheet module you wish to use, such as <filename>string.xsl</filename>. This example assumes that the distribution has been extracted into the same directory as your own stylesheet:</para>
|
||||
<informalexample>
|
||||
<programlisting><![CDATA[
|
||||
<xsl:import href="stdlib.xsl"/>
|
||||
]]></programlisting>
|
||||
</informalexample>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Import or include either the main stylesheet, or the stylesheet module you wish to use, directly from the library website; http://xsltsl.sourceforge.net/modules/. The <filename>modules</filename> directory always contains the latest stable release. For example:</para>
|
||||
<informalexample>
|
||||
<programlisting><![CDATA[
|
||||
<xsl:import href="http://xsltsl.sourceforge.net/modules/stdlib.xsl"/>
|
||||
]]></programlisting>
|
||||
</informalexample>
|
||||
<para>Older versions of the library are available in subdirectories. For example, to access version 1.1 of the library use:</para>
|
||||
<informalexample>
|
||||
<programlisting><![CDATA[
|
||||
<xsl:import href="http://xsltsl.sourceforge.net/modules/1.1/stdlib.xsl"/>
|
||||
]]></programlisting>
|
||||
</informalexample>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<para>Next, add XML Namespace declarations for the modules you wish to use. For example, to use templates from the string module, your stylesheet should have the following declaration:</para>
|
||||
<informalexample>
|
||||
<programlisting><![CDATA[
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:str="http://xsltsl.org/string">
|
||||
|
||||
<xsl:import href="http://xsltsl.sourceforge.net/modules/stdlib.xsl"/>
|
||||
]]></programlisting>
|
||||
</informalexample>
|
||||
<para>Finally, use a template with the <sgmltag>call-template</sgmltag> element. Most templates require parameters, which are passed using the <sgmltag>with-param</sgmltag> element. For example:</para>
|
||||
<informalexample>
|
||||
<programlisting><![CDATA[
|
||||
<xsl:template match="foo">
|
||||
<xsl:call-template name="str:subst">
|
||||
<xsl:with-param name="text" select="."/>
|
||||
<xsl:with-param name="replace">a word</xsl:with-param>
|
||||
<xsl:with-param name="with">another word</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
]]></programlisting>
|
||||
</informalexample>
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>Obtaining The Library</title>
|
||||
|
||||
<para>The XSLT Standard Library is available for download as either:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>Gzip'd tarball: <ulink url="http://prdownloads.sourceforge.net/xsltsl/xsltsl-&version;.tar.gz">http://prdownloads.sourceforge.net/xsltsl/xsltsl-&version;.tar.gz</ulink></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Zip file: <ulink url="http://prdownloads.sourceforge.net/xsltsl/xsltsl-&version;.zip">http://prdownloads.sourceforge.net/xsltsl/xsltsl-&version;.zip</ulink></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>Getting Involved</title>
|
||||
|
||||
<para>Contributions to the project are most welcome, and may be in the form of stylesheet modules, patches, bug reports or sample code. Any contributed code must use the LGPL license to be accepted into the library.</para>
|
||||
|
||||
<para>See the SourceForge Project Page <ulink url="http://sourceforge.net/projects/xsltsl/">http://sourceforge.net/projects/xsltsl/</ulink> for information on the development of the project. Bug reports may be submitted here.</para>
|
||||
|
||||
<para>See the project Web Page <ulink url="http://xsltsl.sourceforge.net/">http://xsltsl.sourceforge.net/</ulink> for documentation.</para>
|
||||
|
||||
<para>There are three mailing lists for the project:</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><email>xsltsl-users@lists.sourceforge.net</email></term>
|
||||
<listitem>
|
||||
<para>Discussion of the use of <acronym>xsltsl</acronym>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><email>xsltsl-devel@lists.sourceforge.net</email></term>
|
||||
<listitem>
|
||||
<para>Discussion of the development of <acronym>xsltsl</acronym>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><email>xsltsl-announce@lists.sourceforge.net</email></term>
|
||||
<listitem>
|
||||
<para>Project announcements.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>XML Namespaces</title>
|
||||
|
||||
<para>Apart from the XSLT XML Namespace (http://www.w3.org/1999/XSL/Transform), <acronym>xsltsl</acronym> employs a number of XML Namespaces to allow inclusion of the library in developer stylesheets. In addition, documentation is defined in a separate namespace.</para>
|
||||
<para>Each module is allocated a namespace URI by appending the module name to the URI for the project, http://xsltsl.org/. For example, the string module has the namespace URI http://xsltsl.org/string.</para>
|
||||
<para>All documentation is written using an <ulink url="docbook-extensions.html">extension</ulink> of <ulink url="http://www.docbook.org/">DocBook</ulink> designed for <ulink url="docbook-extensions.html">embedding DocBook into XSLT stylesheets</ulink>. The namespace URI for DocBook embedded in stylesheets is http://xsltsl.org/xsl/documentation/1.0</para>
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>Engineering Standards</title>
|
||||
|
||||
<para>In order to maintain a high engineering standard, all modules and contributions to the <acronym>xsltsl</acronym> project must adhere to the following coding and documentation standards. Submissions which do not meet (or exceed) this standard will not be accepted.</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>All stylesheets must be indented, with each level indented by two spaces. NB. a simple stylesheet could be used to enforce/fix this.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Templates are named using a qualified name (QName). The namespace URI for the template's containing stylesheet is assigned as above.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Parameters for templates should use sensible names. Where possible (or if in doubt), follow these conventions:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>A parameter containing a single node is named <parametername>node</parametername>. Where more than one parameter contains a single node, the suffix <parametername>Node</parametername> is appended to the parameter name, eg. <parametername>referenceNode</parametername></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>A parameter which potentially contains multiple nodes is named <parametername>nodes</parametername>. Where more than one parameter potentially contains multiple nodes, the suffix <parametername>Nodes</parametername> is appended to the parameter name, eg. <parametername>copyNodes</parametername></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>A parameter which contains a string value is named <parametername>text</parametername>.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>All templates in each stylesheet must be documented. A template is documented as a <ulink url="http://www.docbook.org/">DocBook</ulink> RefEntry.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Every stylesheet must include a test suite. The test system is in the <filename>test</filename> subdirectory. See <ulink url="test/test.html">test/test.html</ulink> for further details.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>An <ulink url="example.xsl">example stylesheet</ulink> has been provided, which acts as a template for new stylesheet modules.</para>
|
||||
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>Related Work</title>
|
||||
|
||||
<para>The <ulink url="http://www.exslt.org/">EXSLT</ulink> project is creating a library to standardise extension functions. The XSLT Standard Library is complementary to the EXSLT project.</para>
|
||||
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>Reference Documentation</title>
|
||||
|
||||
<para>Reference documentation is available for each module.</para>
|
||||
|
||||
<section>
|
||||
<title>String Processing</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><ulink url="string.html">string.xsl</ulink></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Nodes</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><ulink url="node.html">node.xsl</ulink></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Date/Time Processing</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><ulink url="date-time.html">date-time.xsl</ulink></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Mathematics</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><ulink url="math.html">math.xsl</ulink></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>URI (Uniform Resource Identifier) Processing</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><ulink url="uri.html">uri.xsl</ulink></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Comparing Nodesets</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><ulink url="cmp.html">cmp.xsl</ulink></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Generating XML Markup</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><ulink url="markup.html">markup.xsl</ulink></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Presentation Media Support</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>Scalable Vector Graphics: <ulink url="svg.html">svg.xsl</ulink></para>
|
||||
</listitem>
|
||||
<!--
|
||||
<listitem>
|
||||
<para><ulink url="html/html.html">html/html.xsl</ulink></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><ulink url="fo/fo.html">fo/fo.xsl</ulink></para>
|
||||
</listitem>
|
||||
-->
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Example</title>
|
||||
|
||||
<!-- Add a new module in a similar fashion -->
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><ulink url="example.html">example.xsl</ulink></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
</doc:book>
|
||||
|
||||
</xsl:stylesheet>
|
1233
texml-xsl/string.xsl
Normal file
1233
texml-xsl/string.xsl
Normal file
File diff suppressed because one or more lines are too long
1
texml-xsl/svg.xsl
Normal file
1
texml-xsl/svg.xsl
Normal file
File diff suppressed because one or more lines are too long
580
texml-xsl/uri.xsl
Normal file
580
texml-xsl/uri.xsl
Normal file
@ -0,0 +1,580 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<xsl:stylesheet
|
||||
version="1.0"
|
||||
extension-element-prefixes="doc"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
|
||||
xmlns:uri="http://xsltsl.org/uri"
|
||||
>
|
||||
|
||||
<doc:reference xmlns="">
|
||||
<referenceinfo>
|
||||
<releaseinfo role="meta">
|
||||
$Id$
|
||||
</releaseinfo>
|
||||
<author>
|
||||
<surname>Diamond</surname>
|
||||
<firstname>Jason</firstname>
|
||||
</author>
|
||||
<copyright>
|
||||
<year>2001</year>
|
||||
<holder>Jason Diamond</holder>
|
||||
</copyright>
|
||||
</referenceinfo>
|
||||
|
||||
<title>URI (Uniform Resource Identifier) Processing</title>
|
||||
|
||||
<partintro>
|
||||
<section>
|
||||
<title>Introduction</title>
|
||||
<para>This module provides templates for processing URIs (Uniform Resource Identifers).</para>
|
||||
</section>
|
||||
</partintro>
|
||||
|
||||
</doc:reference>
|
||||
|
||||
<doc:template name="uri:is-absolute-uri" xmlns="">
|
||||
<refpurpose>Determines if a URI is absolute or relative.</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>Absolute URIs start with a scheme (like "http:" or "mailto:").</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>uri</term>
|
||||
<listitem>
|
||||
<para>An absolute or relative URI.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns 'true' if the URI is absolute or '' if it's not.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="uri:is-absolute-uri">
|
||||
<xsl:param name="uri"/>
|
||||
|
||||
<xsl:if test="contains($uri, ':')">
|
||||
<xsl:value-of select="true()"/>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="uri:get-uri-scheme" xmlns="">
|
||||
<refpurpose>Gets the scheme part of a URI.</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>The ':' is not part of the scheme.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>uri</term>
|
||||
<listitem>
|
||||
<para>An absolute or relative URI.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns the scheme (without the ':') or '' if the URI is relative.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="uri:get-uri-scheme">
|
||||
<xsl:param name="uri"/>
|
||||
<xsl:if test="contains($uri, ':')">
|
||||
<xsl:value-of select="substring-before($uri, ':')"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="uri:get-uri-authority" xmlns="">
|
||||
<refpurpose>Gets the authority part of a URI.</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>The authority usually specifies the host machine for a resource. It always follows '//' in a typical URI.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>uri</term>
|
||||
<listitem>
|
||||
<para>An absolute or relative URI.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns the authority (without the '//') or '' if the URI has no authority.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="uri:get-uri-authority">
|
||||
<xsl:param name="uri"/>
|
||||
|
||||
<xsl:variable name="a">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($uri, ':')">
|
||||
<xsl:if test="substring(substring-after($uri, ':'), 1, 2) = '//'">
|
||||
<xsl:value-of select="substring(substring-after($uri, ':'), 3)"/>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:if test="substring($uri, 1, 2) = '//'">
|
||||
<xsl:value-of select="substring($uri, 3)"/>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($a, '/')">
|
||||
<xsl:value-of select="substring-before($a, '/')" />
|
||||
</xsl:when>
|
||||
<xsl:when test="contains($a, '?')">
|
||||
<xsl:value-of select="substring-before($a, '?')" />
|
||||
</xsl:when>
|
||||
<xsl:when test="contains($a, '#')">
|
||||
<xsl:value-of select="substring-before($a, '#')" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$a" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="uri:get-uri-path" xmlns="">
|
||||
<refpurpose>Gets the path part of a URI.</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>The path usually comes after the '/' in a URI.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>uri</term>
|
||||
<listitem>
|
||||
<para>An absolute or relative URI.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns the path (with any leading '/') or '' if the URI has no path.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="uri:get-uri-path">
|
||||
<xsl:param name="uri"/>
|
||||
|
||||
<xsl:variable name="p">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($uri, '//')">
|
||||
<xsl:if test="contains(substring-after($uri, '//'), '/')">
|
||||
<xsl:value-of select="concat('/', substring-after(substring-after($uri, '//'), '/'))"/>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($uri, ':')">
|
||||
<xsl:value-of select="substring-after($uri, ':')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$uri"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($p, '?')">
|
||||
<xsl:value-of select="substring-before($p, '?')" />
|
||||
</xsl:when>
|
||||
<xsl:when test="contains($p, '#')">
|
||||
<xsl:value-of select="substring-before($p, '#')" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$p" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="uri:get-uri-query" xmlns="">
|
||||
<refpurpose>Gets the query part of a URI.</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>The query comes after the '?' in a URI.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>uri</term>
|
||||
<listitem>
|
||||
<para>An absolute or relative URI.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns the query (without the '?') or '' if the URI has no query.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="uri:get-uri-query">
|
||||
<xsl:param name="uri"/>
|
||||
|
||||
<xsl:variable name="q" select="substring-after($uri, '?')"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($q, '#')">
|
||||
<xsl:value-of select="substring-before($q, '#')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise><xsl:value-of select="$q"/></xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="uri:get-uri-fragment" xmlns="">
|
||||
<refpurpose>Gets the fragment part of a URI.</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>The fragment comes after the '#' in a URI.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>uri</term>
|
||||
<listitem>
|
||||
<para>An absolute or relative URI.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>Returns the fragment (without the '#') or '' if the URI has no fragment.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="uri:get-uri-fragment">
|
||||
<xsl:param name="uri"/>
|
||||
|
||||
<xsl:value-of select="substring-after($uri, '#')"/>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<doc:template name="uri:resolve-uri" xmlns="">
|
||||
<refpurpose>Resolves a URI reference against a base URI.</refpurpose>
|
||||
|
||||
<refdescription>
|
||||
<para>This template follows the guidelines specified by <ulink url="ftp://ftp.isi.edu/in-notes/rfc2396.txt">RFC 2396</ulink>.</para>
|
||||
</refdescription>
|
||||
|
||||
<refparameter>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>reference</term>
|
||||
<listitem>
|
||||
<para>A (potentially relative) URI reference.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>base</term>
|
||||
<listitem>
|
||||
<para>The base URI.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>document</term>
|
||||
<listitem>
|
||||
<para>The URI of the current document. This defaults to the value of the base URI if not specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refparameter>
|
||||
|
||||
<refreturn>
|
||||
<para>The "combined" URI.</para>
|
||||
</refreturn>
|
||||
</doc:template>
|
||||
|
||||
<xsl:template name="uri:resolve-uri">
|
||||
<xsl:param name="reference"/>
|
||||
<xsl:param name="base"/>
|
||||
<xsl:param name="document" select="$base"/>
|
||||
|
||||
<xsl:variable name="reference-scheme">
|
||||
<xsl:call-template name="uri:get-uri-scheme">
|
||||
<xsl:with-param name="uri" select="$reference"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="reference-authority">
|
||||
<xsl:call-template name="uri:get-uri-authority">
|
||||
<xsl:with-param name="uri" select="$reference"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="reference-path">
|
||||
<xsl:call-template name="uri:get-uri-path">
|
||||
<xsl:with-param name="uri" select="$reference"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="reference-query">
|
||||
<xsl:call-template name="uri:get-uri-query">
|
||||
<xsl:with-param name="uri" select="$reference"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="reference-fragment">
|
||||
<xsl:call-template name="uri:get-uri-fragment">
|
||||
<xsl:with-param name="uri" select="$reference"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
|
||||
<xsl:when test="
|
||||
not(string-length($reference-scheme)) and
|
||||
not(string-length($reference-authority)) and
|
||||
not(string-length($reference-path)) and
|
||||
not(string-length($reference-query))"
|
||||
>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($document, '?')">
|
||||
<xsl:value-of select="substring-before($document, '?')"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains($document, '#')">
|
||||
<xsl:value-of select="substring-before($document, '#')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$document"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:if test="string-length($reference-fragment)">
|
||||
<xsl:value-of select="concat('#', $reference-fragment)"/>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="string-length($reference-scheme)">
|
||||
|
||||
<xsl:value-of select="$reference"/>
|
||||
|
||||
</xsl:when>
|
||||
|
||||
<xsl:otherwise>
|
||||
|
||||
<xsl:variable name="base-scheme">
|
||||
<xsl:call-template name="uri:get-uri-scheme">
|
||||
<xsl:with-param name="uri" select="$base"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="base-authority">
|
||||
<xsl:call-template name="uri:get-uri-authority">
|
||||
<xsl:with-param name="uri" select="$base"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="base-path">
|
||||
<xsl:call-template name="uri:get-uri-path">
|
||||
<xsl:with-param name="uri" select="$base"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="base-query">
|
||||
<xsl:call-template name="uri:get-uri-query">
|
||||
<xsl:with-param name="uri" select="$base"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="base-fragment">
|
||||
<xsl:call-template name="uri:get-uri-fragment">
|
||||
<xsl:with-param name="uri" select="$base"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="result-authority">
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($reference-authority)">
|
||||
<xsl:value-of select="$reference-authority"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$base-authority"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="result-path">
|
||||
<xsl:choose>
|
||||
<!-- don't normalize absolute paths -->
|
||||
<xsl:when test="starts-with($reference-path, '/')">
|
||||
<xsl:value-of select="$reference-path" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="uri:normalize-path">
|
||||
<xsl:with-param name="path">
|
||||
<xsl:if test="string-length($reference-authority) = 0 and substring($reference-path, 1, 1) != '/'">
|
||||
<xsl:call-template name="uri:get-path-without-file">
|
||||
<xsl:with-param name="path-with-file" select="$base-path"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="'/'"/>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="$reference-path"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:value-of select="concat($base-scheme, '://', $result-authority, $result-path)"/>
|
||||
|
||||
<xsl:if test="string-length($reference-query)">
|
||||
<xsl:value-of select="concat('?', $reference-query)"/>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="string-length($reference-fragment)">
|
||||
<xsl:value-of select="concat('#', $reference-fragment)"/>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="uri:get-path-without-file">
|
||||
<xsl:param name="path-with-file" />
|
||||
<xsl:param name="path-without-file" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($path-with-file, '/')">
|
||||
<xsl:call-template name="uri:get-path-without-file">
|
||||
<xsl:with-param name="path-with-file" select="substring-after($path-with-file, '/')" />
|
||||
<xsl:with-param name="path-without-file">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$path-without-file">
|
||||
<xsl:value-of select="concat($path-without-file, '/', substring-before($path-with-file, '/'))" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before($path-with-file, '/')" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$path-without-file" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="uri:normalize-path">
|
||||
<xsl:param name="path"/>
|
||||
<xsl:param name="result" select="''"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($path)">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$path = '/'">
|
||||
<xsl:value-of select="concat($result, '/')"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$path = '.'">
|
||||
<xsl:value-of select="concat($result, '/')"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$path = '..'">
|
||||
<xsl:call-template name="uri:get-path-without-file">
|
||||
<xsl:with-param name="path-with-file" select="$result"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="'/'"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains($path, '/')">
|
||||
<!-- the current segment -->
|
||||
<xsl:variable name="s" select="substring-before($path, '/')"/>
|
||||
<!-- the remaining path -->
|
||||
<xsl:variable name="p">
|
||||
<xsl:choose>
|
||||
<xsl:when test="substring-after($path, '/') = ''">
|
||||
<xsl:value-of select="'/'"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-after($path, '/')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$s = ''">
|
||||
<xsl:call-template name="uri:normalize-path">
|
||||
<xsl:with-param name="path" select="$p"/>
|
||||
<xsl:with-param name="result" select="$result"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$s = '.'">
|
||||
<xsl:call-template name="uri:normalize-path">
|
||||
<xsl:with-param name="path" select="$p"/>
|
||||
<xsl:with-param name="result" select="$result"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$s = '..'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($result) and (substring($result, string-length($result) - 2) != '/..')">
|
||||
<xsl:call-template name="uri:normalize-path">
|
||||
<xsl:with-param name="path" select="$p"/>
|
||||
<xsl:with-param name="result">
|
||||
<xsl:call-template name="uri:get-path-without-file">
|
||||
<xsl:with-param name="path-with-file" select="$result"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="uri:normalize-path">
|
||||
<xsl:with-param name="path" select="$p"/>
|
||||
<xsl:with-param name="result" select="concat($result, '/..')"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="uri:normalize-path">
|
||||
<xsl:with-param name="path" select="$p"/>
|
||||
<xsl:with-param name="result" select="concat($result, '/', $s)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat($result, '/', $path)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$result"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
@ -29,7 +29,7 @@
|
||||
-->
|
||||
|
||||
<!--<xsl:include href="xsltsl/string.xsl"/>-->
|
||||
<xsl:import href="http://xsltsl.sourceforge.net/modules/stdlib.xsl"/>
|
||||
<xsl:import href="texml-xsl/stdlib.xsl"/>
|
||||
|
||||
<!-- Create a variable named $maxXEPVersiom containing the MAX version -->
|
||||
<xsl:variable name="maxXEPVersion">
|
||||
|
Loading…
Reference in New Issue
Block a user