Preserve text with styles inside lists, discard styles

This commit is contained in:
Nathan Gray 2011-09-05 20:04:15 +00:00
parent cb5ee32664
commit 40a89ac81e
2 changed files with 37 additions and 5 deletions

View File

@ -86,7 +86,11 @@ Breakers
</xsl:template> </xsl:template>
--> -->
<xsl:template name="apply-styles" match="w:r[descendant::strong|descendant::em|descendant::u|descendant::span]"> <xsl:template match="w:r[descendant::strong|descendant::em|descendant::u|descendant::span]">
<xsl:call-template name="apply-styles"/>
</xsl:template>
<xsl:template name="apply-styles">
<xsl:for-each select="node()|@*[not(w:rPr)]"> <xsl:for-each select="node()|@*[not(w:rPr)]">
<xsl:choose> <xsl:choose>
<xsl:when test="descendant::strong|descendant::em|descendant::u|descendant::span" > <xsl:when test="descendant::strong|descendant::em|descendant::u|descendant::span" >
@ -210,9 +214,23 @@ Breakers
<w:t>&#xB7;</w:t><w:tab/> <w:t>&#xB7;</w:t><w:tab/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</w:r><w:r>
<w:t><xsl:value-of select="normalize-space(text())" /></w:t>
</w:r> </w:r>
<xsl:choose>
<xsl:when test="count(child::*)=0">
<xsl:variable name="text">
<xsl:value-of select="substring-after(text(),' ')"/>
</xsl:variable>
<w:r><w:t>
<xsl:value-of select="normalize-space($text)"/>
</w:t></w:r>
</xsl:when>
<xsl:otherwise>
<!-- Strip out styles, they would need to be processed-->
<w:r><w:t>
<xsl:value-of select = "normalize-space(child::*)"/>
</w:t></w:r>
</xsl:otherwise>
</xsl:choose>
</w:p> </w:p>
</xsl:for-each> </xsl:for-each>
</xsl:template> </xsl:template>

View File

@ -208,9 +208,23 @@ Breakers
<w:t>&#xB7;</w:t><w:tab/> <w:t>&#xB7;</w:t><w:tab/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</w:r><w:r>
<w:t><xsl:value-of select="normalize-space(text())" /></w:t>
</w:r> </w:r>
<xsl:choose>
<xsl:when test="count(child::*)=0">
<xsl:variable name="text">
<xsl:value-of select="substring-after(text(),' ')"/>
</xsl:variable>
<w:r><w:t>
<xsl:value-of select="normalize-space($text)"/>
</w:t></w:r>
</xsl:when>
<xsl:otherwise>
<!-- Strip out styles, they would need to be processed-->
<w:r><w:t>
<xsl:value-of select = "normalize-space(child::*)"/>
</w:t></w:r>
</xsl:otherwise>
</xsl:choose>
</w:p> </w:p>
</xsl:for-each> </xsl:for-each>
</xsl:template> </xsl:template>