xslt - Validating xml attribute value with dynamic length -
i have following xml part:
<column customerfield="title" companyfield="2241" datatype="alphanumeric" length="17" customervalue="manager sales compensation head office" companyvalue="manager sales compensation head office" remark=""/>
i check xslt 2.0 customervalue doesn't exceed specified length (that present in xml).
what have far this
<xsl:template match="column[@companyfield='2241' , @datatype='alphanumeric' , @companyvalue[string-length()>number(@length)]]"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:attribute name="companyvalue"> <xsl:value-of select="substring(@customervalue,1,17)"/> </xsl:attribute> <xsl:attribute name="remark">string value long.</xsl:attribute> </xsl:copy> </xsl:template>
at first used '>@length' changed 'number(@length)' thinking might interpreted string didn't help. when change 'number(@length)' or '@length' fixed number let's 17 works.
any ideas welcome.
when number(@length)
evaluated, in context of companyvalue
attribute. looking length
attribute on companyvalue
attribute, not company
element.
you need this...
column[@companyfield='2241' , @datatype='alphanumeric' , @companyvalue[string-length() > number(../@length)]]
or maybe this...
column[@companyfield='2241' , @datatype='alphanumeric' , string-length(@companyvalue) > number(@length)]
Comments
Post a Comment