在xslt中嵌入标签 [英] embedding tags in xslt

查看:137
本文介绍了在xslt中嵌入标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个正在工作的xslt:

I have this xslt which is working:

<xsl:when test="area_of_expertise">

    <div>
        <xsl:value-of select="area_of_expertise"/>
    </div>
</xsl:when>

但我需要的是:

<xsl:when test="area_of_expertise">

    <div id="<xsl:value-of select="area_of_expertise"/>">
        <xsl:value-of select="area_of_expertise"/>
    </div>
</xsl:when>

然而,第二个例子有错误..有人知道为什么吗?

However the second example has errors.. does anyone know why?

Btw有没有一种方法可以将节点名称 area_of_expertise 转换为 areaOfExperiseLabel 并插入作为身份证?我真正需要的输出是这样的:

Btw Is there a way we can transform the node's name area_of_expertise into areaOfExperiseLabel and insert that as the id? the output that i really need is this:

<div id="areaOfExpertiseLabel">
    asasdasdasd
</div>


推荐答案

第二部分尝试使用此模板:

For 2nd part try using this template:

<xsl:template name="parse">
        <xsl:param name="input"/>
        <xsl:param name="position"/>


        <xsl:if test="$position &lt;= string-length($input)">

            <xsl:choose>
                <xsl:when test="substring($input, $position, 1) = '_'">
                    <xsl:value-of select="translate(substring($input, $position + 1, 1), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>

                    <xsl:call-template name="parse">
                        <xsl:with-param name="input" select="$input"/>
                        <xsl:with-param name="position" select="$position + 2"/>
                    </xsl:call-template>
                </xsl:when>

                <xsl:otherwise>

                    <xsl:value-of select="substring($input, $position, 1)"/>

                    <xsl:call-template name="parse">
                        <xsl:with-param name="input" select="$input"/>
                        <xsl:with-param name="position" select="$position + 1"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>

        </xsl:if>


    </xsl:template>

用法:

Usage:

<xsl:call-template name="parse">
            <xsl:with-param name="input" select="'area_of_expertise'"/>
            <xsl:with-param name="position" select="1"/>
        </xsl:call-template>

这篇关于在xslt中嵌入标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆