xml SDL Tridion Sites 9和DXA 2.1富文本字段XSLT

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml SDL Tridion Sites 9和DXA 2.1富文本字段XSLT相关的知识,希望对你有一定的参考价值。

<!-- 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(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;     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(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;        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() = &apos;table&apos; or local-name() = &apos;tr&apos; or local-name() = &apos;th&apos; or local-name() = &apos;td&apos; or local-name() = &apos;col&apos;)]/@style"></xsl:template>
	<xsl:template match="span/@style">
		<xsl:if test="contains(.,&apos;text-decoration&apos;)">
			<xsl:copy></xsl:copy>
		</xsl:if>
	</xsl:template>
	<!-- remove rowspan and collspan when set to 1 -->
	<xsl:template match="@colspan[.=&apos;1&apos;] | @rowspan[.=&apos;1&apos;]"></xsl:template>
	<!-- remove well known Microsoft Word classes -->
	<xsl:template match="@class[starts-with(., &apos;Mso&apos;)] | @class[starts-with(., &apos;mso&apos;)]"></xsl:template>
	<!-- remove conditional comments that Microsoft Word uses -->
	<xsl:template match="comment()[contains(., &apos;if&apos;)] | comment()[contains(., &apos;endif&apos;)]"></xsl:template>
</xsl:stylesheet>
<!-- 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(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;     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(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;        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>

以上是关于xml SDL Tridion Sites 9和DXA 2.1富文本字段XSLT的主要内容,如果未能解决你的问题,请参考以下文章

xml SDL Tridion内容交付日志配置。

xml SDL Tridion内容交付日志配置。

xml 适用于SDL Tridion ADF的IPv6兼容IP白名单

xml 适用于SDL Tridion ADF的IPv6兼容IP白名单

xml SDL Tridion 2013 SP1中cd_storage_conf.xml的项类型映射示例

xml SDL Tridion 2013 SP1中cd_storage_conf.xml的项类型映射示例