Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Class 将类应用于通过测试找到的元素_Class_Xslt - Fatal编程技术网

Class 将类应用于通过测试找到的元素

Class 将类应用于通过测试找到的元素,class,xslt,Class,Xslt,我还不熟悉XSLT 如何将类应用于使用xsl:if找到的元素 XML: 一些文本 我想要的输出: <h3 class="box-list-link">Some Text </h3> 一些文本 我有这样的东西: <xsl:for-each select ="./ColumnBody" > <xsl:call-template name="RichText"></xsl:call-template> </xsl:for

我还不熟悉XSLT

如何将类应用于使用xsl:if找到的元素

XML:

一些文本
我想要的输出:

<h3 class="box-list-link">Some Text </h3>
一些文本
我有这样的东西:

<xsl:for-each select ="./ColumnBody" >
     <xsl:call-template name="RichText"></xsl:call-template>
</xsl:for-each>

<xsl:template name="RichText">
      <p>
            <xsl:copy-of select="./node()" />
      </p>
</xsl:template>



您喜欢这项工作吗

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<!-- identity transform -->
<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="h3">
    <h3 class="box-list-link">
        <xsl:apply-templates/>
    </h3>
</xsl:template>

</xsl:stylesheet>

如果我们能看到输入XML和预期的输出,这个问题就会清楚得多。
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<!-- identity transform -->
<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="h3">
    <h3 class="box-list-link">
        <xsl:apply-templates/>
    </h3>
</xsl:template>

</xsl:stylesheet>