Created
February 21, 2019 09:48
-
-
Save jhorsman/1ea61f92191153e940d1629118359a72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- this XSLT is from the article schema in the core module from DXA 2.1 --> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></xsl:output> | |
<xsl:template match="/ | node() | @*"> | |
<xsl:copy> | |
<xsl:apply-templates select="node() | @*"></xsl:apply-templates> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="*[ (self::br or self::p or self::div) and normalize-space(translate(., ' ', '')) = '' and not(@*) and not(processing-instruction()) and not(comment()) and not(*[not(self::br) or @* or * or node()]) and not(following::node()[not( (self::text() or self::br or self::p or self::div) and normalize-space(translate(., ' ', '')) = '' and not(@*) and not(processing-instruction()) and not(comment()) and not(*[not(self::br) or @* or * or node()]) )]) ]"> | |
<!-- ignore all paragraphs and line-breaks at the end that have nothing but (non-breaking) spaces and line breaks --> | |
</xsl:template> | |
<xsl:template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]"> | |
<!-- Chrome generates <div><br/></div>. Renders differently in different browsers. Replace it with a non-breaking space --> | |
<xsl:text> </xsl:text> | |
</xsl:template> | |
<!-- remove disallowed elements but keep its children --> | |
<xsl:template match="font"> | |
<xsl:apply-templates></xsl:apply-templates> | |
</xsl:template> | |
<!-- remove all style attributes except those for a table and its cells and to allow underline --> | |
<xsl:template match="*[not(local-name() = 'table' or local-name() = 'tr' or local-name() = 'th' or local-name() = 'td' or local-name() = 'col')]/@style"></xsl:template> | |
<xsl:template match="span/@style"> | |
<xsl:if test="contains(.,'text-decoration')"> | |
<xsl:copy></xsl:copy> | |
</xsl:if> | |
</xsl:template> | |
<!-- remove rowspan and collspan when set to 1 --> | |
<xsl:template match="@colspan[.='1'] | @rowspan[.='1']"></xsl:template> | |
<!-- remove well known Microsoft Word classes --> | |
<xsl:template match="@class[starts-with(., 'Mso')] | @class[starts-with(., 'mso')]"></xsl:template> | |
<!-- remove conditional comments that Microsoft Word uses --> | |
<xsl:template match="comment()[contains(., 'if')] | comment()[contains(., 'endif')]"></xsl:template> | |
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- this XSLT is the default XSLT for a rich text field in Tridion Sites 9 --> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></xsl:output> | |
<xsl:template match="/ | node() | @*"> | |
<xsl:copy> | |
<xsl:apply-templates select="node() | @*"></xsl:apply-templates> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="*[ (self::br or self::p or self::div) and normalize-space(translate(., ' ', '')) = '' and not(@*) and not(processing-instruction()) and not(comment()) and not(*[not(self::br) or @* or * or node()]) and not(following::node()[not( (self::text() or self::br or self::p or self::div) and normalize-space(translate(., ' ', '')) = '' and not(@*) and not(processing-instruction()) and not(comment()) and not(*[not(self::br) or @* or * or node()]) )]) ]"> | |
<!-- ignore all paragraphs and line-breaks at the end that have nothing but (non-breaking) spaces and line breaks --> | |
</xsl:template> | |
<xsl:template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]"> | |
<!-- Chrome generates <div><br/></div>. Renders differently in different browsers. Replace it with a non-breaking space --> | |
<xsl:text> </xsl:text> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment