]> granicus.if.org Git - docbook-dsssl/commitdiff
Map info elements to the right *info element when stripping NS. Set xml:base on exter...
authorNorman Walsh <ndw@nwalsh.com>
Thu, 27 Oct 2005 13:47:55 +0000 (13:47 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Thu, 27 Oct 2005 13:47:55 +0000 (13:47 +0000)
xsl/common/stripns.xsl

index e813be47af842d21c6b2e6f3711025bdcf038fb9..8cd9f826368138a180e81510d42c1373e56cc91b 100644 (file)
   <xsl:choose>
     <xsl:when test="self::ng:* or self::db:*">
       <xsl:element name="{local-name(.)}">
-        <xsl:copy-of select="@*"/>
+        <xsl:copy-of select="@*[not(name(.) = 'xml:id')]"/>
+       <xsl:if test="@xml:id">
+         <xsl:attribute name="id">
+           <xsl:value-of select="@xml:id"/>
+         </xsl:attribute>
+       </xsl:if>
         <xsl:apply-templates mode="stripNS"/>
       </xsl:element>
     </xsl:when>
     <xsl:otherwise>
       <xsl:copy>
-        <xsl:copy-of select="@*"/>
+        <xsl:copy-of select="@*[not(name(.) = 'xml:id')]"/>
+       <xsl:if test="@xml:id">
+         <xsl:attribute name="id">
+           <xsl:value-of select="@xml:id"/>
+         </xsl:attribute>
+       </xsl:if>
         <xsl:apply-templates mode="stripNS"/>
       </xsl:copy>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
 
+<xsl:template match="db:info" mode="stripNS">
+  <xsl:variable name="info">
+    <xsl:choose>
+      <xsl:when test="parent::db:article
+                     |parent::db:appendix
+                     |parent::db:bibliography
+                     |parent::db:book
+                     |parent::db:chapter
+                     |parent::db:glossary
+                     |parent::db:index
+                     |parent::db:part
+                     |parent::db:preface
+                     |parent::db:refentry
+                     |parent::db:reference
+                     |parent::db:refsect1
+                     |parent::db:refsect2
+                     |parent::db:refsect3
+                     |parent::db:refsection
+                     |parent::db:refsynopsisdiv
+                     |parent::db:sect1
+                     |parent::db:sect2
+                     |parent::db:sect3
+                     |parent::db:sect4
+                     |parent::db:sect5
+                     |parent::db:section
+                     |parent::db:setindex
+                     |parent::db:set
+                     |parent::db:sidebar">
+       <xsl:value-of select="local-name(parent::*)"/>
+       <xsl:text>info</xsl:text>
+      </xsl:when>
+      <xsl:when test="parent::db:audioobject
+                     |parent::db:imageobject
+                     |parent::db:inlinemediaobject
+                     |parent::db:mediaobject
+                     |parent::db:mediaobjectco
+                     |parent::db:textobject
+                     |parent::db:videoobject">
+       <xsl:text>objectinfo</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>blockinfo</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:element name="{$info}">
+    <xsl:copy-of select="@*[not(name(.) = 'xml:id')]"/>
+    <xsl:if test="@xml:id">
+      <xsl:attribute name="id">
+       <xsl:value-of select="@xml:id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates mode="stripNS"/>
+  </xsl:element>
+</xsl:template>
+
 <xsl:template match="ng:link|db:link" mode="stripNS">
   <xsl:variable xmlns:xlink="http://www.w3.org/1999/xlink"
                name="href" select="@xlink:href|@href"/>
     <xsl:when test="$href != '' and not(starts-with($href,'#'))">
       <ulink url="{$href}">
        <xsl:for-each select="@*">
-         <xsl:if test="local-name(.) != 'href'">
+         <xsl:if test="local-name(.) != 'href' and name(.) != 'xml:id'">
            <xsl:copy/>
          </xsl:if>
        </xsl:for-each>
+       <xsl:if test="@xml:id">
+         <xsl:attribute name="id">
+           <xsl:value-of select="@xml:id"/>
+         </xsl:attribute>
+       </xsl:if>
        <xsl:apply-templates mode="stripNS"/>
       </ulink>
     </xsl:when>
     <xsl:when test="$href != '' and starts-with($href,'#')">
       <link linkend="{substring-after($href,'#')}">
        <xsl:for-each select="@*">
-         <xsl:if test="local-name(.) != 'href'">
+         <xsl:if test="local-name(.) != 'href' and name(.) != 'xml:id'">
            <xsl:copy/>
          </xsl:if>
        </xsl:for-each>
+       <xsl:if test="@xml:id">
+         <xsl:attribute name="id">
+           <xsl:value-of select="@xml:id"/>
+         </xsl:attribute>
+       </xsl:if>
        <xsl:apply-templates mode="stripNS"/>
       </link>
     </xsl:when>
     <xsl:otherwise>
       <link>
-       <xsl:copy-of select="@*"/>
+        <xsl:copy-of select="@*[not(name(.) = 'xml:id')]"/>
+       <xsl:if test="@xml:id">
+         <xsl:attribute name="id">
+           <xsl:value-of select="@xml:id"/>
+         </xsl:attribute>
+       </xsl:if>
        <xsl:apply-templates mode="stripNS"/>
       </link>
     </xsl:otherwise>
                     |ng:videodata|db:videodata
                     |ng:audiodata|db:audiodata" mode="stripNS">
   <xsl:element name="{local-name(.)}">
-    <xsl:copy-of select="@*[name(.) != 'fileref' and name(.) != 'entityref']"/>
+    <xsl:copy-of select="@*[not(name(.) = 'xml:id')]"/>
+    <xsl:if test="@xml:id">
+      <xsl:attribute name="id">
+       <xsl:value-of select="@xml:id"/>
+      </xsl:attribute>
+    </xsl:if>
 
     <xsl:choose>
       <xsl:when test="@fileref
                      and not(contains(@fileref,':'))
                      and not(starts-with(@fileref,'/'))
                      and function-available('saxon:systemId')">
-       <xsl:attribute name="fileref">
+       <xsl:attribute name="xml:base">
          <xsl:call-template name="systemIdToBaseURI">
            <xsl:with-param name="systemId">
              <xsl:choose>
              </xsl:choose>
            </xsl:with-param>
          </xsl:call-template>
-         <xsl:value-of select="@fileref"/>
        </xsl:attribute>
       </xsl:when>
       <xsl:otherwise>
 
     <xsl:choose>
       <xsl:when test="@entityref">
-       <xsl:attribute name="fileref">
+       <xsl:attribute name="xml:base">
          <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
        </xsl:attribute>
       </xsl:when>