--- /dev/null
+<?xml version='1.0'?>\r
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
+ xmlns:its="http://www.w3.org/2005/11/its"\r
+ exclude-result-prefixes="its"\r
+ version='1.0'>\r
+\r
+<!-- ********************************************************************\r
+ $Id: html.xsl 9306 2012-04-28 03:49:00Z bobstayton $\r
+ ********************************************************************\r
+\r
+ This file is part of the XSL DocBook Stylesheet distribution.\r
+ See ../README or http://docbook.sf.net/release/xsl/current/ for\r
+ copyright and other information.\r
+\r
+ Templates in this stylesheet convert ITS 2.0 markup\r
+ http://www.w3.org/TR/its20/ into corresponding HTML5 attributes\r
+ (prefixed with its-*).\r
+\r
+ ******************************************************************** -->\r
+\r
+<!-- List of recognized ITS attributes -->\r
+<xsl:variable name="its-attrs"> its-allowed-characters its-annotators-ref its-line-break-type its-loc-note its-loc-note-ref its-loc-note-type its-loc-quality-issue-comment its-loc-quality-issue-enabled its-loc-quality-issue-profile-ref its-loc-quality-issue-severity its-loc-quality-issue-type its-loc-quality-issues-ref its-loc-quality-rating-profile-ref its-loc-quality-rating-score its-loc-quality-rating-score-threshold its-loc-quality-rating-vote its-loc-quality-rating-vote-threshold its-locale-filter-list its-locale-filter-type its-mt-confidence its-org its-org-ref its-person its-person-ref its-prov-ref its-provenance-records-ref its-rev-org its-rev-org-ref its-rev-person its-rev-person-ref its-rev-tool its-rev-tool-ref its-storage-encoding its-storage-size its-ta-class-ref its-ta-confidence its-ta-ident its-ta-ident-ref its-ta-source its-term its-term-confidence its-term-info-ref its-tool its-tool-ref its-within-text </xsl:variable>\r
+\r
+<xsl:template name="its.attributes">\r
+ <xsl:param name="inherit" select="0"/>\r
+ <xsl:apply-templates select="." mode="its.attributes">\r
+ <xsl:with-param name="inherit" select="$inherit"/>\r
+ </xsl:apply-templates>\r
+</xsl:template>\r
+\r
+<xsl:template match="*" mode="its.attributes">\r
+ <xsl:param name="inherit" select="0"/>\r
+\r
+ <xsl:choose>\r
+ <!-- Handle inheritance; especially necessary for chunking -->\r
+ <xsl:when test="$inherit = 1">\r
+ <xsl:variable name="attrs" select="ancestor-or-self::*/@its:*"/>\r
+ <xsl:for-each select="$attrs">\r
+ <xsl:variable name="name" select="local-name(.)"/>\r
+ <xsl:if test="not(..//*/@*[local-name(.) = $name and (count(. | $attrs) = 1)])">\r
+ <xsl:apply-templates select="."/>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:apply-templates select="@its:*"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+<!-- translate attribute is special in HTML -->\r
+<xsl:template match="@its:translate">\r
+ <xsl:attribute name="translate">\r
+ <xsl:value-of select="."/>\r
+ </xsl:attribute>\r
+</xsl:template>\r
+\r
+<xsl:template match="@its:*">\r
+ <xsl:variable name="attr">\r
+ <xsl:call-template name="its-html-attribute-name">\r
+ <xsl:with-param name="name" select="local-name(.)"/>\r
+ </xsl:call-template>\r
+ </xsl:variable>\r
+\r
+ <xsl:choose>\r
+ <xsl:when test="contains($its-attrs, concat(' ', $attr, ' '))">\r
+ <xsl:attribute name="{$attr}">\r
+ <xsl:value-of select="."/>\r
+ </xsl:attribute>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:message>Attribute <xsl:value-of select="name(.)"/> is not recognized as ITS attribute. Ignoring.</xsl:message>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+<xsl:template name="its-html-attribute-name">\r
+ <xsl:param name="name"/>\r
+\r
+ <xsl:text>its-</xsl:text>\r
+ <xsl:call-template name="its-camel-case-to-dashes">\r
+ <xsl:with-param name="text" select="$name"/>\r
+ </xsl:call-template>\r
+</xsl:template>\r
+\r
+<xsl:template name="its-camel-case-to-dashes">\r
+ <xsl:param name="text"/>\r
+\r
+ <xsl:variable name="first" select="substring($text, 1, 1)"/>\r
+ <xsl:variable name="rest" select="substring($text, 2)"/>\r
+\r
+ <xsl:choose>\r
+ <xsl:when test="$first != translate($first, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')">\r
+ <xsl:value-of select="'-'"/>\r
+ <xsl:value-of select="translate($first, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="$first"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ \r
+ <xsl:if test="$rest != ''">\r
+ <xsl:call-template name="its-camel-case-to-dashes">\r
+ <xsl:with-param name="text" select="$rest"/>\r
+ </xsl:call-template>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+</xsl:stylesheet>\r