0

送信されるフィールドに数字のみが入力されるようにする次のXSLTを作成しましたが、8文字を超えないように追加のステートメントを含めるようにこれを適応させる方法がわかりません。

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

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

    <xsl:template match="record[translate(employeeNumber, '0123456789', '')]"/>
</xsl:stylesheet>
4

2 に答える 2

1

employeeNumbers が 8 文字を超えるレコードを無視したいということですか? その場合は、このような別の一致するテンプレートを追加して、それらを無視することができます

<xsl:template match="record[string-length(employeeNumber) > 8]"/>
于 2012-05-10T12:53:20.780 に答える
0

これは、文字列を切り捨てるために使用できるテンプレートです...これでうまくいくことを願っています!

<xsl:template name="fullortruncate">
    <xsl:param name="input" />
    <xsl:choose>
        <xsl:when test="string-length($input)>8">
            <xsl:value-of select="substring($input, 0, 8)"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$input"/>
        </xsl:otherwise>
    </xsl:choose> 
</xsl:template>

call-template を使用してテンプレートを呼び出すことができます

<xsl:call-template name="fullortruncate">
<xsl:with-param name="input" select="[your input]"/>
</xsl:call-template>
于 2012-05-10T12:57:41.713 に答える