我已经创建了以下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>发布于 2012-05-10 20:53:21
您是说要忽略employeeNumbers大于8个字符的记录吗?如果是这样,您只需添加另一个与此匹配的模板即可忽略它们
<xsl:template match="record[string-length(employeeNumber) > 8]"/>发布于 2012-05-10 20:57:42
这是一个你可以用来截断字符串的模板...希望这能解决这个问题!
<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>https://stackoverflow.com/questions/10534197
复制相似问题