<!-- If the contents of an attdecl is a ref, inline the referenced content -->
-<xsl:param name="prefix" select="''"/>
<xsl:param name="ns" select="'http://docbook.org/ns/docbook'"/>
<xsl:output method="text" encoding="utf-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
+ <xsl:variable name="prefix-list" as="xs:string*">
+ <xsl:for-each select="//dtx:element[contains(@gi,':')]">
+ <xsl:value-of select="substring-before(@gi, ':')"/>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:variable name="prefixes" select="distinct-values($prefix-list)"/>
+
+ <xsl:variable name="root" select="/*"/>
+
<!-- This is silly, but we do it for XProc -->
<dtd>
+ <xsl:text><!ENTITY % db.xmlns.attrib 	"xmlns</xsl:text>
+ <xsl:text>	CDATA	#FIXED '</xsl:text>
+ <xsl:value-of select="$ns"/>
+ <xsl:text>'" > </xsl:text>
+
+ <xsl:text><!ENTITY % xlink.xmlns.attrib 	"xmlns:xlink</xsl:text>
+ <xsl:text>	CDATA	#FIXED 'http://www.w3.org/1999/xlink'" > </xsl:text>
+
+ <xsl:for-each select="$prefixes">
+ <xsl:text><!ENTITY % </xsl:text>
+ <xsl:value-of select="."/>
+ <xsl:text>.prefix 	"</xsl:text>
+ <xsl:value-of select="."/>
+ <xsl:text>" > </xsl:text>
+ <xsl:text><!ENTITY % </xsl:text>
+ <xsl:value-of select="."/>
+ <xsl:text>.xmlns.attrib 	"xmlns:%</xsl:text>
+ <xsl:value-of select="."/>
+ <xsl:text>.prefix;	CDATA	#FIXED '</xsl:text>
+ <xsl:value-of select="namespace-uri-for-prefix(., $root)"/>
+ <xsl:text>'" > </xsl:text>
+ </xsl:for-each>
+
+ <!-- Now we need all the names... -->
+ <xsl:for-each select="//dtx:element[contains(@gi,':')]">
+ <xsl:text><!ENTITY % </xsl:text>
+ <xsl:value-of select="translate(@gi, ':', '.')"/>
+ <xsl:text>.name	"%</xsl:text>
+ <xsl:value-of select="substring-before(@gi, ':')"/>
+ <xsl:text>.prefix;:</xsl:text>
+ <xsl:value-of select="substring-after(@gi, ':')"/>
+ <xsl:text>"> </xsl:text>
+ </xsl:for-each>
+
<xsl:apply-templates/>
</dtd>
</xsl:template>
<xsl:call-template name="implicit-group"/>
</xsl:otherwise>
</xsl:choose>
-<!--
- <xsl:choose>
- <xsl:when test="count(dtx:ref) > 1">
- <xsl:for-each select="dtx:ref">
- <xsl:if test="position() > 1"> | </xsl:if>
- <xsl:apply-templates select="."/>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates/>
- </xsl:otherwise>
- </xsl:choose>
--->
<xsl:text>" > </xsl:text>
</xsl:template>
<xsl:template match="dtx:element">
<xsl:text> <!ATTLIST </xsl:text>
- <xsl:value-of select="if ($prefix) then concat($prefix, ':') else ''"/>
- <xsl:value-of select="@gi"/>
- <xsl:text> 	</xsl:text>
- <xsl:text>xmlns</xsl:text>
- <xsl:value-of select="if ($prefix) then concat(':', $prefix) else ''"/>
- <xsl:text>	CDATA	#FIXED "</xsl:text>
- <xsl:value-of select="$ns"/>
- <xsl:text>" 	</xsl:text>
+ <xsl:choose>
+ <xsl:when test="contains(@gi, ':')">
+ <xsl:text>%</xsl:text>
+ <xsl:value-of select="translate(@gi, ':', '.')"/>
+ <xsl:text>.name;</xsl:text>
+ <xsl:text> 	</xsl:text>
+ <xsl:text>%</xsl:text>
+ <xsl:value-of select="substring-before(@gi, ':')"/>
+ <xsl:text>.xmlns.attrib; 	</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@gi"/>
+ <xsl:text> 	</xsl:text>
+ <xsl:text>%db.xmlns.attrib; 	</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
- <xsl:text>xmlns:xlink</xsl:text>
- <xsl:text>	CDATA	#FIXED "http://www.w3.org/1999/xlink"</xsl:text>
- <xsl:text> 	</xsl:text>
+ <xsl:text>%xlink.xmlns.attrib; 	</xsl:text>
<xsl:apply-templates select="dtx:attref"/>
<xsl:text> > </xsl:text>
<xsl:text> <!ELEMENT </xsl:text>
- <xsl:value-of select="if ($prefix) then concat($prefix, ':') else ''"/>
- <xsl:value-of select="@gi"/>
+
+ <xsl:choose>
+ <xsl:when test="contains(@gi, ':')">
+ <xsl:text>%</xsl:text>
+ <xsl:value-of select="translate(@gi, ':', '.')"/>
+ <xsl:text>.name;</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@gi"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text> 	</xsl:text>
<xsl:variable name="cm" select="*[not(self::dtx:attref)]"/>
</xsl:choose>
</xsl:when>
<xsl:when test="$target/self::dtx:element">
- <xsl:value-of select="if ($prefix) then concat($prefix, ':') else ''"/>
- <xsl:value-of select="$target/@gi"/>
+ <xsl:choose>
+ <xsl:when test="contains($target/@gi, ':')">
+ <xsl:text>%</xsl:text>
+ <xsl:value-of select="translate($target/@gi, ':', '.')"/>
+ <xsl:text>.name;</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$target/@gi"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:if test="@optional = 'true'">?</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:template name="mixed-content">
<xsl:param name="cm"/>
-<!--
- <xsl:variable name="refs" as="xs:string*">
- <xsl:apply-templates select="$cm" mode="mixed-refs"/>
- </xsl:variable>
-
- <xsl:message>element: <xsl:value-of select="@gi"/></xsl:message>
- <xsl:message><xsl:value-of select="distinct-values($refs)"/></xsl:message>
-
- <xsl:call-template name="collapse-mixed">
- <xsl:with-param name="refs" select="distinct-values($refs)"/>
- </xsl:call-template>
--->
-
<xsl:variable name="gis" as="xs:string*">
<xsl:apply-templates select="$cm" mode="mixed"/>
</xsl:variable>
<xsl:sort select="."/>
<xsl:if test=". != '#PCDATA'">
<xsl:text> | </xsl:text>
- <xsl:value-of select="if ($prefix) then concat($prefix, ':') else ''"/>
- <xsl:value-of select="."/>
+
+ <xsl:choose>
+ <xsl:when test="contains(., ':')">
+ <xsl:text>%</xsl:text>
+ <xsl:value-of select="translate(., ':', '.')"/>
+ <xsl:text>.name;</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:if>
</xsl:for-each>
<xsl:text>)*</xsl:text>
<xsl:choose>
<xsl:when test="$target/self::dtx:element">
- <xsl:value-of select="concat(if ($prefix) then concat($prefix, ':') else '',
- $target/@gi)"/>
+ <xsl:value-of select="$target/@gi"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$target/*" mode="mixed"/>