Difference between revisions of "Relaxng refAtt resolver.xslt"
Jump to navigation
Jump to search
(New page: This stylesheet reads in a TEI P4 RELAX NG schema (XML syntax) — such a thing would be created by converting a flat TEI P4 DTD with a tool like <tt>trang</tt> — and writes out the same...) |
m (reduce verbosity) |
||
| Line 19: | Line 19: | ||
</xsl:template> | </xsl:template> | ||
| − | <xsl:template | + | <xsl:template match="@*|node()"> |
| − | |||
<xsl:copy> | <xsl:copy> | ||
| − | <xsl:apply-templates | + | <xsl:apply-templates select="@*|node()"/> |
| − | |||
</xsl:copy> | </xsl:copy> | ||
</xsl:template> | </xsl:template> | ||
| Line 38: | Line 36: | ||
<xsl:comment>resolved define <xsl:value-of select="@name"/></xsl:comment> | <xsl:comment>resolved define <xsl:value-of select="@name"/></xsl:comment> | ||
<xsl:variable name="name" select="@name"/> | <xsl:variable name="name" select="@name"/> | ||
| − | <xsl:apply-templates mode="referred" | + | <xsl:apply-templates mode="referred" select="//rng:define[@name=$name]"/> |
| − | |||
</xsl:template> | </xsl:template> | ||
Revision as of 14:45, 19 November 2008
This stylesheet reads in a TEI P4 RELAX NG schema (XML syntax) — such a thing would be created by converting a flat TEI P4 DTD with a tool like trang — and writes out the same schema with references to attribute lists resolved.
This is not generally a useful thing to do, but makes it easier to process the schema further, e.g. with GenerateDefaultAttributeRemover.xslt.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:rng="http://relaxng.org/ns/structure/1.0">
<!-- Reads in a TEI RELAX NG (XML syntax) file, and writes out the same with -->
<!-- references to attribute list definitions resolved -->
<!-- Conceived and started 2008-03-15 -->
<!-- First working version 2008-03-16 (I don't know why, but it wouldn't work -->
<!-- witout explicit namespace prefixes; i.e., unqualified names even with -->
<!-- default NS decl above did not work.) -->
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="rng:define[starts-with(@name,'attlist.')]">
<xsl:comment>deleted define <xsl:value-of select="@name"/></xsl:comment>
</xsl:template>
<xsl:template match="rng:define" mode="referred">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="rng:ref[starts-with(@name,'attlist.')]">
<xsl:comment>resolved define <xsl:value-of select="@name"/></xsl:comment>
<xsl:variable name="name" select="@name"/>
<xsl:apply-templates mode="referred" select="//rng:define[@name=$name]"/>
</xsl:template>
</xsl:stylesheet>