]> granicus.if.org Git - docbook-dsssl/commitdiff
attributes spec
authorSteve Ball <balls@users.sourceforge.net>
Sun, 26 Dec 2004 01:40:12 +0000 (01:40 +0000)
committerSteve Ball <balls@users.sourceforge.net>
Sun, 26 Dec 2004 01:40:12 +0000 (01:40 +0000)
xsl/wordml/docbook.xsl
xsl/wordml/specifications.xml
xsl/wordml/wordml-final.xsl

index 74754e60b350aaba766731870fe5090bc6f10609..3fba58f158c47756a631e159ad946e6c27058d70 100755 (executable)
     <xsl:apply-templates select='title|subtitle|titleabbrev'/>
     <xsl:apply-templates select='author|releaseinfo'/>
     <!-- current implementation ignores all other metadata -->
+    <xsl:for-each select='*[not(self::title|self::subtitle|self::titleabbrev|self::author|self::releaseinfo)]'>
+      <xsl:call-template name='nomatch'/>
+    </xsl:for-each>
   </xsl:template>
 
   <xsl:template match='title|subtitle|titleabbrev'>
         <w:outlineLvl w:val='{count(ancestor::*) - count(parent::*[contains(name(), "info")]) - 1}'/>
       </w:pPr>
 
-      <xsl:call-template name='attributes'>
-        <xsl:with-param name='node' select='..'/>
-      </xsl:call-template>
+      <xsl:choose>
+        <xsl:when test='contains(name(..), "info")'>
+          <xsl:call-template name='attributes'>
+            <xsl:with-param name='node' select='../..'/>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:call-template name='attributes'>
+            <xsl:with-param name='node' select='..'/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
 
       <xsl:apply-templates/>
     </w:p>
                        keywordset|
                        msg'/>
 
-  <xsl:template match='*'>
+  <xsl:template match='*' name='nomatch'>
     <xsl:message>
       <xsl:value-of select='name()'/>
       <xsl:text> encountered</xsl:text>
         <w:rPr>
           <w:rStyle w:val='attributes'/>
         </w:rPr>
-        <w:t> </w:t>
+        <w:t>
+          <xsl:text> </xsl:text>
+        </w:t>
       </w:r>
       <aml:annotation aml:id='{count(preceding::*) + 1}' w:type='Word.Comment.End'/>
       <w:r>
index e0cd73a6ff9e5e297da1a57d526e862eedf63d12..9cce83c850bfdd2894d789a45880471f0331eb74 100755 (executable)
@@ -112,9 +112,6 @@ dated 5 November, 2004</releaseinfo>
 </listitem>
 </itemizedlist>
 <para>Sequential structures are colesced into a single parent element.  For example, a sequence of <sgmltag>itemizedlist</sgmltag> paragraphs becomes a single <sgmltag>itemizedlist</sgmltag> element with several <sgmltag>listitem</sgmltag> children.</para>
-<para>Attributes are a feature of DocBook XML that have no direct counterpart in Word. One approach is to use Word Bookmarks for attributes. For example, a Word Bookmark named <literal>att_role_foobar</literal> could be inserted into a paragraph. When converted to DocBook XML, this would become a <sgmltag class="attribute">role="foobar"</sgmltag> attribute on the element derived from the paragraph containing the Bookmark.</para>
-<para>[Alternatively, we could use hidden text for attributes.]</para>
-<para>[Do we need a parameter to specify whether titles should be placed in the *info subelement?]</para>
 <table>
 <title>DocBook to WordML styles</title>
 <tgroup cols="3"><colspec colnum="1" colname="col1"
@@ -552,5 +549,21 @@ variablelist4</literallayout></entry>
 </tbody>
 </tgroup>
 </table>
+<section>
+<title>Attributes</title>
+<para>Attributes are a feature of DocBook XML that have no direct counterpart in Word.  Several approaches are possible:</para>
+<itemizedlist>
+  <listitem>
+    <para>Use Word comments; the currently implemented approach.  Some dummy text (just a space, using a character style that includes the hidden property) anchors the comment.  Within the comment text, character types are used to indicate attribute names and values (these must be paired).  This approach keeps the attributes separate to the main body and allows multiple attributes to be encoded.</para>
+    <para>A disadvantage to this approach (which also applies to the other approaches below) is that a paragraph may be related to more than one element, but the attributes are associated with only one element (by default the parent).  For example, a section may have an attribute as well as the title child element, but only a single paragraph (with paragraph style <literal>section-title</literal>) represents both elements.  Any attribute defined in a comment would be associated with the <sgmltag>section</sgmltag> element.</para>
+  </listitem>
+  <listitem>
+    <para>Use Word Bookmarks for attributes. For example, a Word Bookmark named <literal>att_role_foobar</literal> could be inserted into a paragraph. When converted to DocBook XML, this would become a <sgmltag class="attribute">role="foobar"</sgmltag> attribute on the element derived from the paragraph containing the Bookmark.</para>
+  </listitem>
+  <listitem>
+    <para>Use hidden text.  Define character styles that have their text hidden, and place these at the beginning of a paragraph.</para>
+  </listitem>
+</itemizedlist>
+</section> 
 </section> 
 </article>
index 913684b2128a4fc66c3d6fff388c51b980d4391c..ef6e508fed89e469de3ee56603f6ad0b7c986b2d 100644 (file)
       <xsl:when test='$element.name != "bogus"'>
         <xsl:element name="{$element.name}">
           <xsl:call-template name="object.id"/>
+          <xsl:call-template name='attributes'>
+            <xsl:with-param name='node' select='$first.node'/>
+          </xsl:call-template>
           <xsl:apply-templates mode="group"/>
         </xsl:element>
       </xsl:when>
     <xsl:variable name='annotation' select='$attr/preceding-sibling::aml:annotation[1]'/>
 
     <xsl:if test='$attr and $annotation'>
-      <xsl:variable name='comment' select='w:r[w:rPr/w:rStyle/@w:val = "CommentReference"]/aml:annotation[@w:type = "Word.Comment" and @aml:id = $annotation/@aml:id]/aml:content'/>
+      <xsl:variable name='comment' select='$node/w:r[w:rPr/w:rStyle/@w:val = "CommentReference"]/aml:annotation[@w:type = "Word.Comment" and @aml:id = $annotation/@aml:id]/aml:content'/>
       <xsl:for-each select='$comment/w:p/w:r[w:rPr/w:rStyle/@w:val = "attribute-name"]'>
         <xsl:attribute name='{w:t}'>
           <xsl:value-of select='following-sibling::w:r[w:rPr/w:rStyle/@w:val = "attribute-value"][1]/w:t'/>
 
   <xsl:template match='aml:annotation' mode='group'/>
   <xsl:template match='aml:annotation'/>
+  <xsl:template match='w:r[w:rPr/w:rStyle/@w:val = "attributes"]'/>
   <xsl:template match='w:r[w:rPr/w:rStyle/@w:val = "CommentReference"]'/>
 
 </xsl:stylesheet>