OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: [docbook-apps] Converting Website to DB5: suppressing version="5.0"attribute on children of root


I'm working on an XSL 1.0 stylesheet that processes a DocBook Website 
autolayout file, transforming its Website pages into DocBook 5 articles. 
My stylesheet imports Norm's db4-upgrade.xsl, which does most of the 
work. My output is valid, and looks fine except for one nagging detail: 
some elements are transformed with 'version="5.0" attributes.

Sample output:
=====================
<article xmlns="http://docbook.org/ns/docbook"; 
xmlns:xi="http://www.w3.org/2001/XInclude"; 
xmlns:html="http://www.w3.org/1999/xhtml"; 
xmlns:m="http://www.w3.org/1998/Math/MathML"; 
xmlns:svg="http://www.w3.org/2000/svg"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; version="5.0" xml:id="upreview">

   <?dbhtml filename="upreview.html" dir="arts"?>

   <title>Up and other Pixar reviews</title>

   <para version="5.0">From
   <citetitle>Pixar Gone Too Far This Time</link></citetitle>: </para>

   <blockquote version="5.0">

     <para><quote>If the Pixar sensibility seemed strangely locked in to 
a mid-20th century mindset, well, they made it clear they intended to 
inherit the Disney mantle, didn’t they?</quote></para></blockquote>
    ...

</article>


=====================

Notice that all the children of <article> (except for <title>, which my 
stylesheet extracts out of context) have the version attribute, while 
their children do not. I'd like the version attribute to be suppressed 
on all elements (except the root article, of course). Any ideas? Here's 
the entire customization:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
     xmlns:xi="http://www.w3.org/2001/XInclude";
     xmlns:html="http://www.w3.org/1999/xhtml";
     xmlns:m="http://www.w3.org/1998/Math/MathML";
     xmlns:svg="http://www.w3.org/2000/svg";
     xmlns:xlink="http://www.w3.org/1999/xlink";
     xmlns:saxon="http://icl.com/saxon";
     xmlns:exsl="http://exslt.org/common";
     extension-element-prefixes="saxon exsl"
     version='1.0'>

<xsl:import href="/usr/share/xml/docbook5/tools/db4-upgrade.xsl"/>

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>

<xsl:template match="autolayout">
         <xsl:apply-templates/>
</xsl:template>

<xsl:template match="toc|tocentry|notoc">
   <xsl:call-template name="doWebpage">
     <xsl:with-param name="filename" select="@filename"/>
     <xsl:with-param name="dir" select="@dir"/>
     <xsl:with-param name="page" select="@page"/>
     <xsl:with-param name="pagedoc" select="document(@page,/*)" />
   </xsl:call-template>
</xsl:template>

<xsl:template name="doWebpage">
   <xsl:param name="dir"/>
   <xsl:param name="filename"/>
   <xsl:param name="page"/>
   <xsl:param name="pagedoc"/>

   <xsl:for-each select="$pagedoc//webpage">
     <xsl:variable name="pageid">
       <xsl:value-of select="@id"/>
     </xsl:variable>
     <xsl:message><xsl:value-of select="$page"/></xsl:message>
         <xsl:variable name="converted">
             <xsl:apply-templates/>
         </xsl:variable>
         <xsl:comment>
             <xsl:text> Converted by db4-upgrade version </xsl:text>
             <xsl:value-of select="$version"/>
             <xsl:text> </xsl:text>
         </xsl:comment>
         <xsl:text>&#10;</xsl:text>

     <saxon:output href="{$page}">
       <article xmlns="http://docbook.org/ns/docbook";
         version="5.0" xml:id="{$pageid}">

         <xsl:processing-instruction name="dbhtml">
           <xsl:text>filename="</xsl:text>
           <xsl:value-of select="$filename"/>
           <xsl:text>" </xsl:text>
           <xsl:if test="$dir !=''">
             <xsl:variable name="dirlen" select="string-length($dir)"/>
             <xsl:text>dir="</xsl:text>
             <xsl:value-of select="substring($dir,0,($dirlen))"/>
             <xsl:text>"</xsl:text>
           </xsl:if>
         </xsl:processing-instruction>

         <title><xsl:value-of select="head/title"/></title>
         <xsl:apply-templates  select="exsl:node-set($converted)/*" 
mode="addNS"/>
       </article>

     </saxon:output>
   </xsl:for-each>
<xsl:apply-templates />
</xsl:template>

<xsl:template match="config"/>
<xsl:template match="autolayout/title"/>
<xsl:template match="autolayout/summary"/>
<xsl:template match="head"/>
<xsl:template match="layout/style"/>
<xsl:template match="webtoc"/>

</xsl:stylesheet>



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]