|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<xsl:stylesheet xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
xmlns:saxon="http://saxon.sf.net/"
|
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
xmlns:schold="http://www.ascc.net/xml/schematron"
|
|
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
|
|
xmlns:util="foo:util"
|
|
version="2.0">
|
|
<xsl:function xmlns:sch="http://purl.oclc.org/dsdl/schematron" name="util:unsortedValues"
|
|
as="xs:string">
|
|
<xsl:param name="attribute"/>
|
|
<xsl:param name="tokenList" as="xs:string+"/>
|
|
<xsl:variable name="attrValues" select="tokenize(normalize-space(string($attribute)), ' ')"/>
|
|
|
|
<xsl:variable name="badValues">
|
|
<xsl:for-each select="$attrValues">
|
|
|
|
<xsl:if test="not(index-of($attrValues, current())[last()] = count($attrValues))">
|
|
|
|
|
|
<xsl:variable name="indexOfValue" select="util:getIndexFromListMatch(current(), $tokenList)"/>
|
|
<xsl:variable name="indexOfNextValue"
|
|
select="util:getIndexFromListMatch($attrValues[index-of($attrValues,current())+1], $tokenList)"/>
|
|
|
|
|
|
<xsl:choose>
|
|
<xsl:when test="$indexOfValue = $indexOfNextValue">
|
|
|
|
|
|
<xsl:if test="compare(current(), $attrValues[index-of($attrValues,current())+1]) = 1">
|
|
<xsl:value-of select="$attrValues[index-of($attrValues,current())+1]"/>
|
|
</xsl:if>
|
|
</xsl:when>
|
|
<xsl:when test="$indexOfValue > $indexOfNextValue">
|
|
|
|
<xsl:value-of select="$attrValues[index-of($attrValues,current())+1]"/>
|
|
</xsl:when>
|
|
</xsl:choose>
|
|
</xsl:if>
|
|
</xsl:for-each>
|
|
</xsl:variable>
|
|
<xsl:value-of select="normalize-space(string($badValues))"/>
|
|
</xsl:function>
|
|
<xsl:function xmlns:sch="http://purl.oclc.org/dsdl/schematron"
|
|
name="util:getIndexFromListMatch"
|
|
as="xs:integer">
|
|
<xsl:param name="value" as="xs:string"/>
|
|
<xsl:param name="list" as="xs:string+"/>
|
|
|
|
<xsl:variable name="index">
|
|
<xsl:for-each select="$list">
|
|
<xsl:if test="matches($value,concat('^',current(),'$'))">
|
|
<xsl:value-of select="index-of($list,current())[1]"/>
|
|
</xsl:if>
|
|
</xsl:for-each>
|
|
</xsl:variable>
|
|
|
|
<xsl:choose>
|
|
<xsl:when test="$index = ''">
|
|
<xsl:value-of select="-1"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:value-of select="number($index[1])"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:function>
|
|
</xsl:stylesheet>
|