InsertFalsePrecision1.xsl

TEI datatypes permit times on the value= attribute of the various date &amp; time elements to be expressed to any precision (year, month, day, hour, minute, second, or decimal fraction of a second). However, because the W3C XML Schema datatypes for times do not permit precision to the hour or minute, there exists software that does not handle these values. E.g., such software will reject "13:30" but accept "13:30:00". This styleseet (as well as the better version that only works with XSLT 2 processors) converts times that are precise to only the minute or hour to times that are precise to the second.





            - </xsl:when> <xsl:when test="contains($value,'+')"> +</xsl:text> </xsl:when> <xsl:when test="contains($value,'Z')"> Z</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="time"> <xsl:choose> <xsl:when test="$zoneSep=''"> <xsl:value-of select="$value"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="substring-before($value,$zoneSep)"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="zone"> <xsl:choose> <xsl:when test="$zoneSep=''"> <xsl:text/> </xsl:when> <xsl:otherwise> <xsl:value-of select="substring-after($value,$zoneSep)"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="newValue"> <xsl:choose> <xsl:when test="string-length($time)=2"> <xsl:value-of select="$time"/> :00:00</xsl:text> <xsl:value-of select="$zoneSep"/> <xsl:value-of select="$zone"/> </xsl:when> <xsl:when test="string-length($time)=5"> <xsl:value-of select="$time"/> :00</xsl:text> <xsl:value-of select="$zoneSep"/> <xsl:value-of select="$zone"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$value"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:element name="name(.)"> <xsl:copy-of select="@*"/> <xsl:attribute name="value"> <xsl:value-of select="$newValue"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template>

</xsl:stylesheet>