From: <lou...@us...> - 2015-06-09 17:33:47
|
Revision: 13256 http://sourceforge.net/p/tei/code/13256 Author: louburnard Date: 2015-06-09 17:33:45 +0000 (Tue, 09 Jun 2015) Log Message: ----------- add script to purify existing datatypes Added Paths: ----------- branches/P5-Pure/Source/purifyData.xsl Added: branches/P5-Pure/Source/purifyData.xsl =================================================================== --- branches/P5-Pure/Source/purifyData.xsl (rev 0) +++ branches/P5-Pure/Source/purifyData.xsl 2015-06-09 17:33:45 UTC (rev 13256) @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tei="http://www.tei-c.org/ns/1.0" + xmlns:rng="http://relaxng.org/ns/structure/1.0" exclude-result-prefixes="xs tei" version="2.0"> + <xsl:template match="tei:teiHeader"/> + <xsl:template match="tei:text"> + <TEI xmlns="http://www.tei-c.org/ns/1.0"> + <teiHeader> + <fileDesc> + <titleStmt> + <title>Purified Datatypes</title> + </titleStmt> + <publicationStmt> + <publisher>Lou Burnard Consulting</publisher> + </publicationStmt> + <sourceDesc> + <p>Report generated by purifyData stylesheet</p> + </sourceDesc> + </fileDesc> + </teiHeader> + <text> + <body> + <table> + <xsl:apply-templates select="//tei:macroSpec[@type='dt']"> + <xsl:sort select="@ident"/> + </xsl:apply-templates> + </table> + </body> + </text> + </TEI> + </xsl:template> + <xsl:template match="tei:macroSpec"> + <xsl:variable name="nomen"> + <xsl:value-of select="concat('tei',@ident)"/> + </xsl:variable> + <row> + <cell role="label"> + <xsl:value-of select="@ident"/> + </cell> + <cell> + <xsl:copy-of select="tei:content"/> + </cell> + + <cell> + <dataSpec ident="{$nomen}"> + <xsl:choose> + <xsl:when test="tei:content/rng:choice"> + <alternate> + <xsl:for-each select="tei:content/rng:choice/rng:data"> + <dataRef name="{@type}"> + <xsl:if test="rng:param/@name='pattern'"> + <xsl:attribute name="restriction"> + <xsl:value-of select="rng:param"/> + </xsl:attribute> + </xsl:if> + </dataRef> + </xsl:for-each> + <xsl:if test="tei:content/rng:choice/rng:value"> + <valList> + <xsl:for-each select="tei:content/rng:choice/rng:value"> + <valItem ident="{.}"/> + </xsl:for-each> + </valList> + </xsl:if> + </alternate> + </xsl:when> + <xsl:when test="tei:content/rng:data/rng:param/@name='pattern'"> + <dataRef name="{tei:content/rng:data/@type}" + restriction="{tei:content/rng:data/rng:param}"/> + </xsl:when> + <xsl:when test="tei:content/rng:data"> + <dataRef name="{tei:content/rng:data/@type}"/> + </xsl:when> + <xsl:when test="tei:content/rng:ref"> + <dataRef key="{concat('tei',tei:content/rng:ref/@name)}"/> + </xsl:when> + <xsl:otherwise> + <textNode/> + </xsl:otherwise> + </xsl:choose> + </dataSpec> + </cell> + </row> + </xsl:template> +</xsl:stylesheet> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |