Reputation: 900
I have created the following XSLT that will ensure that the field being sent is only populated with numbers, however I'm not sure how to adapt this to include an extra statement to ensure it is no longer than 8 characters long.
<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>
Upvotes: 0
Views: 267
Reputation: 70638
Are you saying you wish to ignore records with employeeNumbers greater than 8 characters? If so, you can just add another matching template like this to ignore them
<xsl:template match="record[string-length(employeeNumber) > 8]"/>
Upvotes: 1
Reputation: 216
Here is a template you can use to truncate a string... hope this does the job!
<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>
You can call the template using call-template
<xsl:call-template name="fullortruncate">
<xsl:with-param name="input" select="[your input]"/>
</xsl:call-template>
Upvotes: 0