如何检查元素中的前3个字符? [英] How do I check the first 3 characters in an element?
本文介绍了如何检查元素中的前3个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有下面的StatuteCode节点,我想检查前3个字符是否不等于169.
< pre lang =xml> < StatuteCode Word = 169142a4 < span class =code-keyword>> 正在运行< / StatuteCode >
如何使用xslt选择?
我尝试了什么。我认为这是错误的。
我的尝试:
< xsl:choose >
< ; xsl:when test =' (StatuteCode,1,4)=169)' >
< xsl:value-of < span class =code-attribute> select = true() / >
< / xsl:何时 >
< xsl:否则 >
< xsl:value-of 选择 = false() / >
< / xsl:否则 >
< / xsl:choose < span class =code-keyword>>
解决方案
尝试:
< pre lang =XML> < xsl:choose > 跨度>
< xsl:when test = starts-with(StatuteCode,'169 ') >
< xsl:value-of 选择 = true() / >
< / xsl:when >
< xsl:否则 >
< xsl:value-of 选择 = false() / >
< / xsl:otherwise >
< / xsl:choose >
I have the StatuteCode node below, I would like to check if the first 3 characters are not equal to 169.
<StatuteCode Word="169142a4">Running</StatuteCode>
How do I do it using xslt choose?
What I have tried. I think this is wrong.
What I have tried:
<xsl:choose>
<xsl:when test='(StatuteCode,1,4)="169")'>
<xsl:value-of select="true()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="false()"/>
</xsl:otherwise>
</xsl:choose>
解决方案
Try:
<xsl:choose> <xsl:when test="starts-with(StatuteCode, '169')"> <xsl:value-of select="true()"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="false()"/> </xsl:otherwise> </xsl:choose>
这篇关于如何检查元素中的前3个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文