简体   繁体   English

CDATA是否会减慢XSLT 1.0中的xslt转换

[英]Does the CDATA slows the xslt transformation in XSLT 1.0

I use XPATH 1.0 and XSLT 1.0. 我使用XPATH 1.0和XSLT 1.0。 I am wondering if the following code 我想知道下面的代码

<xsl:choose>
    <xsl:when test="@name='some'"><![CDATA[one]]></xsl:when>
    <xsl:otherwise><![CDATA[two]]></xsl:otherwise>
</xsl:choose>

has a difference in case of performance with 在性能方面有所不同

 <xsl:choose>
        <xsl:when test="@name='some'"><xsl:value-of select="'one'"/></xsl:when>
        <xsl:otherwise><xsl:value-of select="'two'"/></xsl:otherwise>
    </xsl:choose>

if we know that there must be no need for some special symbols in the select? 如果我们知道必须有没有必要在选择一些特殊符号? Is it a good practice to use <![CDATA[one]]> . 使用<![CDATA[one]]>是一个好习惯<![CDATA[one]]> Or its use decrease the xslt compilation time, or it is easy to read?? 还是它的使用减少了xslt的编译时间,还是很容易阅读?

In my opinion if there's a performance improvement it is not so significant to justify your first example. 我认为,如果性能有所提高,那么证明您的第一个例子并不重要。

In this case I would pay more attention about maintenance and readability as your second example. 在这种情况下,作为第二个示例,我将更加关注维护和可读性。 With this solution if you want change how elements have to be rendered (as cdata or not) you can use the attribute cdata-section-elements in the output element. 使用此解决方案,如果要更改必须呈现元素的方式(是否以cdata呈现),可以在输出元素中使用属性cdata-section-elements。

Here's a good example about it How to use cdata in xslt 这是一个很好的例子, 如何在xslt中使用cdata

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM