Difference between revisions of "DateStructLess.xslt"
Jump to navigation
Jump to search
Piotr Banski (talk | contribs) m (revert (vandalism)) |
m |
||
| Line 48: | Line 48: | ||
<xsl:text>="</xsl:text> | <xsl:text>="</xsl:text> | ||
<xsl:value-of select="normalize-space(current())"/> | <xsl:value-of select="normalize-space(current())"/> | ||
| − | <xsl:text>" attribute of | + | <xsl:text>" attribute of</nowiki></pre> |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Revision as of 18:54, 15 June 2007
A stylesheet to convert P4 <dateStruct> and <timeStruct> elements into P5 <date> and
<?xml version="1.0" encoding="UTF-8"?>
<!-- Tiny XSLT 1.0 stylesheet that reads in a TEI (P4) file and writes out the same -->
<!-- file with <dateStruct> and <timeStruct> elements converted to P5 <date> and -->
<!-- <time> elements respectively. -->
<!-- We handle the xml:id= and xml:lang= attributes in addition to the expected P4 -->
<!-- attributes in case we are somewhere in a P4->P5 pipeline in which that has -->
<!-- already been done. -->
<!-- The exact= attribute of p4:dateStruct is converted to the precision= attribute -->
<!-- of p5:date. This is likely to produce invalid results, as the values of the -->
<!-- latter must conform to a short enumerated list. -->
<!-- Note that this stylesheet does not (yet) handle the changes in the attributes -->
<!-- of the children of <dateStruct> and <timeStruct>. -->
<!-- Copyleft 2006 Syd Bauman and the Text Encoding Initiative Consortium -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="Copy-All.xsl"/>
<xsl:output method="xml" encoding="UTF-8" cdata-section-elements="eg"/>
<!-- match <dateStruct>, output <date> with attrs adjusted -->
<xsl:template match="dateStruct">
<xsl:element name="date">
<!-- global attrs -->
<xsl:apply-templates select="@id|@xml:id|@n|@lang|@xml:lang|@rend"/>
<!-- attrs common to P4 'temporalExpr' and P5 'att.datePart' -->
<xsl:apply-templates select="@value"/>
<!-- attrs common to P4 <dateStruct> and P5 <date> -->
<xsl:apply-templates select="@calendar"/>
<!-- attrs that change between P4 <dateStruct> and P5 <date> -->
<xsl:if test="@exact">
<xsl:attribute name="precision">
<xsl:value-of select="./@exact"/>
</xsl:attribute>
</xsl:if>
<!-- attrs not available -->
<xsl:for-each select="@key|@reg|@type|@full">
<xsl:message>
<xsl:text>WARNING: </xsl:text>
<xsl:value-of select="name(.)"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="normalize-space(current())"/>
<xsl:text>" attribute of