s/\s+xmlns:xlink=([\"\']).*?\1\s+/ /g;
s/\s*xmlns:xlink=([\"\']).*?\1\s*//g;
- s/\s+xmlns:dtd=([\"\']).*?\1\s+/ /g;
- s/\s*xmlns:dtd=([\"\']).*?\1\s*//g;
+ s/\s+xmlns:a=([\"\']).*?\1\s+/ /g;
+ s/\s*xmlns:a=([\"\']).*?\1\s*//g;
- s/<grammar /<grammar xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" xmlns:dtd=\"http:\/\/relaxng.org\/ns\/compatibility\/annotations\/1.0\" /g;
+ s/\s+xmlns:html=([\"\']).*?\1\s+/ /g;
+ s/\s*xmlns:html=([\"\']).*?\1\s*//g;
+
+ s/\s+xmlns:dbx=([\"\']).*?\1\s+/ /g;
+ s/\s*xmlns:dbx=([\"\']).*?\1\s*//g;
+
+ s/<grammar /<grammar xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" xmlns:a=\"http:\/\/relaxng.org\/ns\/compatibility\/annotations\/1.0\" xmlns:html=\"http:\/\/www.w3.org\/1999\/xhtml\" /g;
s/<(s:rule\s+.*?)>/<\1 xmlns:s=\"http:\/\/www.ascc.net\/xml\/schematron\">/g;
s/<(ctrl:\S+\s+.*?)(\/?>)/<\1 xmlns:ctrl=\"http:\/\/nwalsh.com\/xmlns\/schema-control\/\"\2/g;
+ s/<(dbx:\S+\s+.*?)(\/?>)/<\1 xmlns:dbx=\"http:\/\/sourceforge\.net\/projects\/docbook\/defguide\/schema\/extra-markup\"\2/g;
+ s/<(dbx:\S+)(\/?>)/<\1 xmlns:dbx=\"http:\/\/sourceforge\.net\/projects\/docbook\/defguide\/schema\/extra-markup\"\2/g;
+
print $_;
print "\n" if /<\/define>/ || /<ctrl:/ || /<\/start>/;
}
<xsl:apply-templates mode="include"/>
</xsl:variable>
+ <xsl:variable name="conditional">
+ <xsl:apply-templates select="exsl:node-set($expanded)/*"
+ mode="conditional"/>
+ </xsl:variable>
+
<xsl:variable name="overridden">
- <xsl:apply-templates select="exsl:node-set($expanded)/*" mode="override"/>
+ <xsl:apply-templates select="exsl:node-set($conditional)/*"
+ mode="override"/>
</xsl:variable>
- <xsl:apply-templates select="exsl:node-set($overridden)/*" mode="combine"/>
+ <xsl:apply-templates select="exsl:node-set($overridden)/*"
+ mode="combine"/>
</xsl:template>
<!-- ====================================================================== -->
<xsl:template match="rng:include" mode="include">
- <xsl:message>Including <xsl:value-of select="@href"/></xsl:message>
<xsl:variable name="doc" select="document(@href,.)"/>
<xsl:variable name="nestedGrammar">
<xsl:apply-templates mode="markOverride"/>
</xsl:variable>
- <xsl:apply-templates select="exsl:node-set($nestedGrammar)/*" mode="override"/>
+ <xsl:apply-templates select="exsl:node-set($nestedGrammar)/*"
+ mode="override"/>
- <xsl:message>Done including <xsl:value-of select="@href"/></xsl:message>
+ <xsl:message>Included <xsl:value-of select="@href"/></xsl:message>
</xsl:template>
<xsl:template match="*" mode="include">
<!-- ====================================================================== -->
+ <xsl:template match="ctrl:conditional" mode="conditional">
+ <xsl:variable name="pat" select="@pattern"/>
+
+ <xsl:choose>
+ <xsl:when test="//rng:define[@name = $pat]">
+ <xsl:message>
+ <xsl:text>Including conditional pattern=</xsl:text>
+ <xsl:value-of select="$pat"/>
+ </xsl:message>
+ <xsl:apply-templates mode="conditional"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>
+ <xsl:text>Excluding conditional pattern=</xsl:text>
+ <xsl:value-of select="$pat"/>
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="*" mode="conditional">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates mode="conditional"/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="comment()|processing-instruction()|text()"
+ mode="conditional">
+ <xsl:copy/>
+ </xsl:template>
+
+ <!-- ====================================================================== -->
+
<xsl:template match="rng:start" mode="override">
<xsl:choose>
<xsl:when test="@override">
</xsl:copy>
</xsl:template>
- <xsl:template match="comment()|processing-instruction()|text()" mode="override">
+ <xsl:template match="comment()|processing-instruction()|text()"
+ mode="override">
<xsl:copy/>
</xsl:template>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:exsl="http://exslt.org/common"
+ xmlns:rng="http://relaxng.org/ns/structure/1.0"
+ xmlns:ctrl="http://nwalsh.com/xmlns/schema-control/"
+ xmlns:s="http://www.ascc.net/xml/schematron"
+ xmlns:db="http://docbook.org/ns/docbook"
+ xmlns:dbx = "http://sourceforge.net/projects/docbook/defguide/schema/extra-markup"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
+ exclude-result-prefixes="exsl ctrl db dbx html"
+ version="1.0">
+
+<xsl:output method="xml" encoding="utf-8" indent="yes"/>
+
+<xsl:strip-space elements="*"/>
+
+<xsl:template match="db:*"/>
+<xsl:template match="dbx:*"/>
+<xsl:template match="ctrl:*"/>
+
+<xsl:template match="rng:element">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates/>
+
+ <xsl:if test="ancestor::rng:div/db:refpurpose">
+ <xsl:element name="a:documentation">
+ <xsl:value-of select="ancestor::rng:div/db:refpurpose"/>
+ </xsl:element>
+ </xsl:if>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="rng:attribute">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates/>
+
+ <xsl:if test="db:refpurpose">
+ <xsl:element name="a:documentation">
+ <xsl:value-of select="db:refpurpose"/>
+ </xsl:element>
+ </xsl:if>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="rng:grammar">
+ <xsl:element name="{name(.)}" namespace="http://relaxng.org/ns/structure/1.0">
+ <xsl:for-each select="namespace::*">
+ <xsl:if test="local-name(.) != 'dbx' and local-name(.) != ''">
+ <xsl:copy/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates/>
+ </xsl:element>
+</xsl:template>
+
+<xsl:template match="*">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="comment()|processing-instruction()|text()">
+ <xsl:copy/>
+</xsl:template>
+
+</xsl:stylesheet>