Permalink
Browse files

List improvements

  • Loading branch information...
1 parent 36c3fc2 commit 7013e4adbb14f7718e32bdf318295d546d4d6966 @holloway committed Dec 18, 2011
@@ -93,13 +93,13 @@
<xsl:template match="db:literallayout">
- <xsl:element name="pre">
- <xsl:apply-templates/>
- </xsl:element>
+ <xsl:element name="pre">
+ <xsl:apply-templates/>
+ </xsl:element>
</xsl:template>
<xsl:template match="db:literal[@role='additionalSpace']">
- <xsl:text>&#160;</xsl:text>
+ <xsl:text>&#160;</xsl:text>
</xsl:template>
<xsl:template match="db:footnote">
@@ -2,17 +2,6 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:db="http://docbook.org/ns/docbook">
<xsl:output method="xml" omit-xml-declaration="no"/>
-<xsl:template match="db:orderedlist">
- <xsl:copy>
- <xsl:apply-templates select="@*"/>
- <xsl:if test="ancestor::db:orderedlist[1][@continuation][db:listitem/*[not(self::db:orderedlist[@continuation])]]">
- <xsl:attribute name="continuation">
- <xsl:text>continues</xsl:text>
- </xsl:attribute>
- </xsl:if>
- <xsl:apply-templates select="node()"/>
- </xsl:copy>
-</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
@@ -1,25 +1,26 @@
<?xml version='1.0' encoding="UTF-8"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0">
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0">
<xsl:output method="xml" omit-xml-declaration="no"/>
<xsl:variable name="lowercase">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="uppercase">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
+<xsl:variable name="lowercaseAndUppercase" select="concat($lowercase,$uppercase)"/>
<xsl:variable name="remove-when-normalizing">_- 01234567890</xsl:variable><!-- space character is intentional -->
<xsl:variable name="remove-for-outline-level" select="concat($uppercase,$lowercase,'_- ')"/><!-- space character is intentional -->
+<xsl:variable name="indentation-to-be-considered-additional-list-item" select="number(0.25)"/><!-- TODO: add units of length and convert between them -->
<!-- these variables are | separated lists of normalized (as per above) style names AND ending with a | character -->
<xsl:variable name="table-heading-styles">tableheading|tableheader|titredetableau|titretableau|</xsl:variable>
<xsl:variable name="document-title-styles">title|titre|</xsl:variable>
<xsl:variable name="heading-styles">heading|header|</xsl:variable>
<xsl:variable name="bulleted-list-style">bullet</xsl:variable>
+<xsl:variable name="numbered-list-style">numbered</xsl:variable>
<xsl:key name="styles-by-name" match="style:style" use="@style:name"/>
<xsl:key name="list-styles-by-name" match="text:list-style" use="@style:name"/>
<xsl:key name="elements-by-style-name" match="*[@text:style-name]" use="@text:style-name"/>
<xsl:key name='bullet-groups' match="text:p[contains(translate(@text:style-name,$uppercase,$lowercase), $bulleted-list-style)]" use="generate-id(preceding-sibling::*[not(contains(translate(@text:style-name,$uppercase,$lowercase), $bulleted-list-style))][1])"/>
-
-
<xsl:template match="text:p">
<xsl:variable name="style" select="key('styles-by-name', @text:style-name)"/>
<xsl:variable name="normalized-style-name" select="translate(translate($style/@style:name, $uppercase, $lowercase),$remove-when-normalizing,'')"/>
@@ -74,6 +75,7 @@
</xsl:choose>
</xsl:if>
</xsl:variable>
+ <!--<xsl:variable name="is-a-numbered-list" select="contains($normalized-style-name, $numbered-list-style)"/> -->
<xsl:variable name="is-a-bullet" select="normalize-space($looks-like-a-bullet)"/>
<xsl:variable name="inner-text" select="normalize-space(.)"/>
<xsl:if test="$inner-text or descendant::draw:frame/draw:image">
@@ -119,6 +121,18 @@
</xsl:element>
</xsl:if>
</xsl:when>
+ <!--
+ <xsl:when test="$is-a-numbered-list">
+ <xsl:element name="text:ordered-list">
+ <xsl:attribute name="text:style-name"><xsl:value-of select="concat(@text:style-name, '_list-from-normalize-opendocument-xsl')"/></xsl:attribute>
+ <xsl:element name="text:list-item">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:element>
+ </xsl:element>
+ </xsl:when>
+ -->
</xsl:choose>
</xsl:if>
</xsl:template>
@@ -151,23 +165,68 @@
<xsl:variable name="parent-style" select="key('list-styles-by-name', $style/@style:parent-style-name)"/>
<xsl:variable name="normalized-parent-style-name" select="translate(translate($parent-style/@style:name, $uppercase, $lowercase),$remove-when-normalizing,'')"/>
<xsl:variable name="list-depth" select="count(ancestor::text:list-item) + 1"/>
+ <xsl:variable name="list-indentation-node" select="$style/descendant::style:list-level-label-alignment[1]"/>
+ <xsl:variable name="preceding-root-level-list" select="preceding-sibling::*[1][self::text:list or self::text:ordered-list or self::text:unordered-list][not(parent::list-item)]"/>
+ <xsl:variable name="preceding-root-level-list-style" select="key('list-styles-by-name', $preceding-root-level-list/@text:style-name)"/>
+
+ <xsl:variable name="preceding-root-level-list-indentation-node" select="$preceding-root-level-list-style/descendant::style:list-level-label-alignment[1]"/>
+ <xsl:variable name="current-list-indentation" select="(number(translate($list-indentation-node/@fo:text-indent,$lowercaseAndUppercase,'')) + number(translate($list-indentation-node/@fo:margin-left,$lowercaseAndUppercase,''))) div $indentation-to-be-considered-additional-list-item"/>
+ <xsl:variable name="preceding-list-indentation" select="(number(translate($preceding-root-level-list-indentation-node/@fo:text-indent,$lowercaseAndUppercase,'')) + number(translate($preceding-root-level-list-indentation-node/@fo:margin-left,$lowercaseAndUppercase,''))) div $indentation-to-be-considered-additional-list-item"/>
+
+
<xsl:choose>
<xsl:when test="$style/text:list-level-style-number[@text:level=$list-depth] or $parent-style/text:list-level-style-number[@text:level=$list-depth]">
<xsl:element name="text:ordered-list">
<xsl:if test="normalize-space($list-style)"><xsl:attribute name="text:style-name"><xsl:value-of select="$list-style"/></xsl:attribute></xsl:if>
<xsl:if test="@text:continue-numbering"><xsl:attribute name="text:continue-numbering"><xsl:value-of select="@text:continue-numbering"/></xsl:attribute></xsl:if>
- <xsl:apply-templates/>
+ <xsl:call-template name="draw-extra-item-items">
+ <xsl:with-param name="number-of-list-items" select="$current-list-indentation - $preceding-list-indentation"/>
+ <xsl:with-param name="list-type" select="'ordered-list'"/>
+ </xsl:call-template>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="text:unordered-list">
<xsl:if test="normalize-space($list-style)"><xsl:attribute name="text:style-name"><xsl:value-of select="$list-style"/></xsl:attribute></xsl:if>
- <xsl:apply-templates/>
+ <xsl:call-template name="draw-extra-item-items">
+ <xsl:with-param name="number-of-list-items" select="$current-list-indentation - $preceding-list-indentation"/>
+ <xsl:with-param name="list-type" select="'unordered-list'"/>
+ </xsl:call-template>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
+<xsl:template name="draw-extra-item-items">
+ <xsl:param name="number-of-list-items"/>
+ <xsl:param name="list-type"/>
+ <xsl:choose>
+ <xsl:when test="$number-of-list-items">
+ <xsl:element name="text:list-item">
+ <xsl:choose>
+ <xsl:when test="$list-type='unordered-list'">
+ <xsl:element name="text:unordered-list">
+ <xsl:call-template name="draw-extra-item-items">
+ <xsl:with-param name="number-of-list-items" select="$number-of-list-items - 1"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <xsl:when test="$list-type='ordered-list'">
+ <xsl:element name="text:ordered-list">
+ <xsl:call-template name="draw-extra-item-items">
+ <xsl:with-param name="number-of-list-items" select="$number-of-list-items - 1"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
<xsl:template match="office:meta">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
@@ -85,6 +85,12 @@
<xsl:apply-templates/>
</xsl:element>
</xsl:when>
+ <xsl:when test="contains($text-style/style:text-properties/@fo:font-weight, 'bold')">
+ <xsl:element name="db:emphasis">
+ <xsl:attribute name="role">bold</xsl:attribute>
+ <xsl:apply-templates/>
+ </xsl:element>
+ </xsl:when>
<xsl:when test="contains($text-style/style:text-properties/@fo:font-style, 'italic')">
<xsl:element name="db:emphasis">
<xsl:apply-templates/>
@@ -2,7 +2,7 @@
<pipeline>
<stage process="ConvertImages" formats="wmf2png, wmf2svg, bmp2png" deleteOriginals="true" autoCrop="false" autoCropThreshold="20"/>
- <stage process="TransformOpenDocumentToDocBook"/><!-- debugAfterOpenDocumentNormalization="true" -->
+ <stage process="TransformOpenDocumentToDocBook" /><!-- debugAfterOpenDocumentNormalization="true" -->
<stage process="DocBookToXHTML"/>
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<autopipeline>
<stage process="WriteMetaData"/>
-
<stage process="Transform" withFile="pretty-lists.xsl"/>
</autopipeline>
Binary file not shown.
@@ -0,0 +1,6 @@
+Return and check the text. Numbering continues, further text shows indent check also tests OK
+Return and indent used for next level of list. Numbering continues and indent checked OK
+Return gives correct number return
+Return and indent for the next line gives correct result
+line continued for indent check that shows incorrectly...
+The next line is another multi level list. Numbering continues OK
@@ -35,4 +35,14 @@
<stage process="Test" withFile="continuation.xsl" prefix="HTML list continuations"/>
+ <stage process="Generate" withFile="docvert-test-five-new.odt"/>
+ <stage process="Test" withFile="docvert-test-five-new.txt" prefix="4. Pre-normalized OpenDocument"/>
+ <stage process="TransformOpenDocumentToDocBook" />
+ <stage process="Test" withFile="docvert-test-five-new.txt" prefix="4. DocBook"/>
+ <stage process="DocBookToXHTML"/>
+ <stage process="Test" withFile="docvert-test-five-new.txt" prefix="4. HTML"/>
+<!-- <stage process="Debug"/> -->
+<!-- <stage process="Debug" contentType="text/html"/> -->
+
+
</pipeline>

0 comments on commit 7013e4a

Please sign in to comment.