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/docbook-ng"
+ xmlns:db="http://docbook.org/ns/docbook"
xmlns:dbx = "http://sourceforge.net/projects/docbook/defguide/schema/extra-markup"
exclude-result-prefixes="exsl ctrl"
version="1.0">
<xsl:template match="rng:grammar" priority="2">
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:s="http://www.ascc.net/xml/schematron"
- xmlns:db="http://docbook.org/docbook-ng"
+ xmlns:db="http://docbook.org/ns/docbook"
xmlns:dbx = "http://sourceforge.net/projects/docbook/defguide/schema/extra-markup">
<!-- Make sure the datatypeLibrary is specified -->
<!-- Make sure the ns is specified -->
<xsl:attribute name="ns">
- <xsl:value-of select="'http://docbook.org/docbook-ng'"/>
+ <xsl:value-of select="'http://docbook.org/ns/docbook'"/>
</xsl:attribute>
<xsl:copy-of select="@*"/>
<xsl:text> </xsl:text>
<xsl:comment> DocBook NG: The "KahlĂșa" Release </xsl:comment>
<xsl:text> </xsl:text>
- <xsl:comment> See http://docbook.org/docbook-ng/ </xsl:comment>
+ <xsl:comment> See http://docbook.org/ns/docbook </xsl:comment>
<xsl:text> </xsl:text>
<xsl:apply-templates/>
</dtd:element>
</xsl:variable>
+<xsl:variable name="merged-caption">
+ <dtd:element name="caption">
+ <dtd:group>
+ <dtd:choice repeat="*">
+ <dtd:PCDATA/>
+ <dtd:ref name="itemizedlist"/>
+ <dtd:ref name="orderedlist"/>
+ <dtd:ref name="procedure"/>
+ <dtd:ref name="simplelist"/>
+ <dtd:ref name="variablelist"/>
+ <dtd:ref name="segmentedlist"/>
+ <dtd:ref name="glosslist"/>
+ <dtd:ref name="bibliolist"/>
+ <dtd:ref name="calloutlist"/>
+ <dtd:ref name="qandaset"/>
+ <dtd:ref name="caution"/>
+ <dtd:ref name="important"/>
+ <dtd:ref name="note"/>
+ <dtd:ref name="tip"/>
+ <dtd:ref name="warning"/>
+ <dtd:ref name="example"/>
+ <dtd:ref name="figure"/>
+ <dtd:ref name="table"/>
+ <dtd:ref name="informalexample"/>
+ <dtd:ref name="informalfigure"/>
+ <dtd:ref name="informaltable"/>
+ <dtd:ref name="sidebar"/>
+ <dtd:ref name="blockquote"/>
+ <dtd:ref name="address"/>
+ <dtd:ref name="epigraph"/>
+ <dtd:ref name="mediaobject"/>
+ <dtd:ref name="screenshot"/>
+ <dtd:ref name="task"/>
+ <dtd:ref name="productionset"/>
+ <dtd:ref name="constraintdef"/>
+ <dtd:ref name="msgset"/>
+ <dtd:ref name="programlisting"/>
+ <dtd:ref name="screen"/>
+ <dtd:ref name="literallayout"/>
+ <dtd:ref name="synopsis"/>
+ <dtd:ref name="programlistingco"/>
+ <dtd:ref name="screenco"/>
+ <dtd:ref name="cmdsynopsis"/>
+ <dtd:ref name="funcsynopsis"/>
+ <dtd:ref name="classsynopsis"/>
+ <dtd:ref name="methodsynopsis"/>
+ <dtd:ref name="constructorsynopsis"/>
+ <dtd:ref name="destructorsynopsis"/>
+ <dtd:ref name="fieldsynopsis"/>
+ <dtd:ref name="bridgehead"/>
+ <dtd:ref name="remark"/>
+ <dtd:ref name="revhistory"/>
+ <dtd:ref name="indexterm"/>
+ <dtd:ref name="equation"/>
+ <dtd:ref name="informalequation"/>
+ <dtd:ref name="anchor"/>
+ <dtd:ref name="para"/>
+ <dtd:ref name="formalpara"/>
+ <dtd:ref name="simpara"/>
+ <dtd:ref name="html:form"/>
+ <dtd:ref name="annotation"/>
+ </dtd:choice>
+ </dtd:group>
+ </dtd:element>
+</xsl:variable>
+
</xsl:stylesheet>
<!-- Handle the thead patterns -->
+ <!-- Note: the extra testing in here for not(@name='xml:id') is necessary
+ because the attribute generation code uses the presence of xml:id
+ to decide if common attributes should be output, so it mustn't appear
+ twice. -->
+
<xsl:when test="@name = 'db.cals.thead' and key('pattern', 'db.html.thead')">
<xsl:variable name="html.thead"
select="key('pattern', 'db.html.thead')"/>
<dtd:attlist name="thead">
<xsl:apply-templates select="rng:element/doc:attributes"
mode="attributes"/>
- <xsl:apply-templates select="$html.thead/rng:element/doc:attributes"
+ <xsl:apply-templates select="$html.thead/rng:element/doc:attributes//rng:attribute[not(@name='xml:id')]"
mode="attributes"/>
</dtd:attlist>
</xsl:when>
<dtd:attlist name="tfoot">
<xsl:apply-templates select="rng:element/doc:attributes"
mode="attributes"/>
- <xsl:apply-templates select="$html.tfoot/rng:element/doc:attributes"
+ <xsl:apply-templates select="$html.tfoot/rng:element/doc:attributes//rng:attribute[not(@name='xml:id')]"
mode="attributes"/>
</dtd:attlist>
</xsl:when>
<dtd:attlist name="tbody">
<xsl:apply-templates select="rng:element/doc:attributes"
mode="attributes"/>
- <xsl:apply-templates select="$html.tbody/rng:element/doc:attributes"
+ <xsl:apply-templates select="$html.tbody/rng:element/doc:attributes//rng:attribute[not(@name='xml:id')]"
mode="attributes"/>
</dtd:attlist>
</xsl:when>
<dtd:attlist name="informaltable">
<xsl:apply-templates select="rng:element/doc:attributes"
mode="attributes"/>
- <xsl:apply-templates select="$html.informaltable/rng:element/doc:attributes"
+ <xsl:apply-templates select="$html.informaltable/rng:element/doc:attributes//rng:attribute[not(@name='xml:id')]"
mode="attributes"/>
</dtd:attlist>
</xsl:when>
<dtd:attlist name="table">
<xsl:apply-templates select="rng:element/doc:attributes"
mode="attributes"/>
- <xsl:apply-templates select="$html.table/rng:element/doc:attributes"
+ <xsl:apply-templates select="$html.table/rng:element/doc:attributes//rng:attribute[not(@name='xml:id')]"
mode="attributes"/>
</dtd:attlist>
</xsl:when>
<!-- nop; handled by the db.cals.table branch -->
</xsl:when>
+ <xsl:when test="@name = 'db.caption' and key('pattern', 'db.html.caption')">
+ <xsl:variable name="html.caption"
+ select="key('pattern', 'db.html.caption')"/>
+
+ <xsl:copy-of select="$merged-caption"/>
+
+ <dtd:attlist name="caption">
+ <xsl:apply-templates select="rng:element/doc:attributes"
+ mode="attributes"/>
+ <xsl:apply-templates select="$html.caption/rng:element/doc:attributes//rng:attribute[not(@name='xml:id')]"
+ mode="attributes"/>
+ </dtd:attlist>
+ </xsl:when>
+
+ <xsl:when test="@name = 'db.html.caption'
+ and key('pattern', 'db.caption')">
+ <!-- nop; handled by the db.caption branch -->
+ </xsl:when>
+
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
<xsl:when test="@name = 'userlevel'"/>
<xsl:when test="@name = 'vendor'"/>
<xsl:when test="@name = 'wordsize'"/>
+ <xsl:when test="@name = 'annotations'"/>
<xsl:when test="@name = 'linkend'">
<dtd:peref name="db.common.linking.attributes"/>
<xsl:key name="defs" match="rng:define" use="@name"/>
<xsl:key name="combines" match="rng:define[@combine='choice']" use="@name"/>
+ <xsl:key name="interleaves"
+ match="rng:define[@combine='interleave']"
+ use="@name"/>
<xsl:key name="overrides" match="rng:define[@override]" use="@name"/>
<xsl:template match="/">
<xsl:template match="rng:define" mode="combine">
<xsl:choose>
<xsl:when test="@combine = 'choice'"/>
- <xsl:when test="@combine = 'interleave'">
- <!-- these are always attributes, right? -->
- <xsl:message>
- <xsl:text>Interleaving attributes for </xsl:text>
- <xsl:value-of select="@name"/>
- </xsl:message>
-
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates mode="combine"/>
- </xsl:copy>
- </xsl:when>
+ <xsl:when test="@combine = 'interleave'"/>
<xsl:when test="@combine">
<!-- what's this!? -->
<xsl:message>
<xsl:apply-templates mode="combine"/>
</xsl:copy>
</xsl:when>
+
<xsl:otherwise>
<xsl:variable name="choices" select="key('combines', @name)"/>
+ <xsl:variable name="ileaves" select="key('interleaves', @name)"/>
<xsl:choose>
+ <xsl:when test="$choices and $ileaves">
+ <xsl:message>
+ <xsl:text>Warning: choice and interleave for </xsl:text>
+ <xsl:value-of select="@name"/>
+ </xsl:message>
+ </xsl:when>
+ <xsl:when test="$ileaves">
+ <!-- these are always attributes, right? -->
+ <xsl:message>
+ <xsl:text>Interleaving definitions for </xsl:text>
+ <xsl:value-of select="@name"/>
+ </xsl:message>
+
+ <xsl:if test="not(rng:interleave) or count(*) > 1">
+ <xsl:message>
+ <xsl:text>Unexpected content for </xsl:text>
+ <xsl:value-of select="@name"/>
+ </xsl:message>
+ </xsl:if>
+
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <rng:interleave>
+ <xsl:apply-templates select="rng:interleave/*" mode="combine"/>
+ <xsl:apply-templates select="$ileaves/*" mode="combine"/>
+ </rng:interleave>
+ </xsl:copy>
+ </xsl:when>
<xsl:when test="$choices">
<xsl:message>
<xsl:text>Combining definitions for </xsl:text>
XMLFILES=$@
SRCDIR=/sourceforge/docbook/testdocs/tests
-DB4UPG=../tools/db4-upgrade.xsl
+DB4UPG=../../tools/db4-upgrade.xsl
if [ ! -d passed ]; then
echo "Directory 'passed' must exist. Are you sure you're in the right place?"
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
- xmlns:db = "http://docbook.org/docbook-ng"
+ xmlns:db = "http://docbook.org/ns/docbook"
exclude-result-prefixes="exsl db"
version="1.0">
my %used = ();
-recurse($start ,1);
+foreach my $pat (@{$start}) {
+ recurse($pat ,1);
+}
@pats = keys %used;
my $usedPat = $#pats + 1;
while ($child) {
if ($child->getNodeType() == XML::DOM::ELEMENT_NODE) {
if ($child->getTagName() eq 'define') {
- $patterns{$child->getAttribute('name')} = $child;
+ my $name = $child->getAttribute('name');
+# print "PAT $name\n";
+ $patterns{$name} = [] if ! exists $patterns{$name};
+ push(@{$patterns{$name}}, $child);
} elsif ($child->getTagName() eq 'start') {
- $patterns{"*start"} = $child;
+ my $name = "*start";
+# print "PAT $name\n";
+ $patterns{$name} = [] if ! exists $patterns{$name};
+ push(@{$patterns{$name}}, $child);
} elsif ($child->getTagName() eq 'div') {
findPatterns($child);
}
my $child = $node->getFirstChild();
# print "X", " " x $depth, $node->getTagName();
-# print " (", $node->getAttribute('name'), ")\n";
+# print " (", $node->getAttribute('name'), ")";
+# print " has children" if $child;
+# print "\n";
while ($child) {
if ($child->getNodeType() == XML::DOM::ELEMENT_NODE) {
$used{$name} = 1;
print "D", " " x $depth, $name, "\n" if $showRecurse;
die "No pattern for $name\n" if ! exists $patterns{$name};
- recurse($patterns{$name},$depth+1);
+ foreach my $pat (@{$patterns{$name}}) {
+ recurse($pat,$depth+1);
+ }
}
} elsif ($child->getTagName() eq 'ref') {
my $name = $child->getAttribute('name');
$used{$name} = 1;
print "R", " " x $depth, $name, "\n" if $showRecurse;
die "No pattern for $name\n" if ! exists $patterns{$name};
- recurse($patterns{$name},$depth+1);
+ foreach my $pat (@{$patterns{$name}}) {
+ recurse($pat,$depth+1);
+ }
}
} else {
- recurse($child, $depth);
+ recurse($child, $depth+1);
}
}
<xsl:strip-space elements="*"/>
-<xsl:param name="ns" select="'http://docbook.org/docbook-ng'"/>
+<xsl:param name="ns" select="'http://docbook.org/ns/docbook'"/>
<xsl:template match="/">
<xsl:apply-templates/>