开发者

Filtering Nodes based on its text()

I have the below XML

<Categories>
<cat>Video</cat>
<cat>Audio</cat>
<cat>Hybrid</cat>
</Categories>

In my XSL, I would like to filter 'Audio' and pass the rest of nodes to a calling template which takes nodes as one of the parameter. How to achieve this.

I tried the below, but no luck.

attempt 1:

<xsl:call-template name='xx'>
<xsl:with-param name='nodes' select="/Categories/cat[text()='Hybrid' or 'Video']"/>
</xsl:call-template>

attempt 2:

<xsl:call-template name='xx'>
<xsl:with-param name='nodes' select="/Categories/cat[text()='Hybrid' or text()='Video']"/>
</xsl:call-template>

attempt 3:

<xsl:call-template name='xx'>
<xsl:w开发者_C百科ith-param name='nodes' select="/Categories/cat[contains(text(),'Hybrid,Video']"/>
</xsl:call-template>

It works if I just one value like below

<xsl:call-template name='xx'>
<xsl:with-param name='nodes' select="/Categories/cat[text()='Video']"/>
</xsl:call-template>

Thanks in advance.


I would like to filter 'Audio' and pass the rest of nodes to a calling template

Your second expression should be:

/Categories/cat[text()='Hybrid' or text()='Video']

But, I would use:

/Categories/cat[.!='Audio']

Or

/Categories/cat[not(.='Audio')]


This approach worked fine.

/Categories/cat[. ='Hybrid' or . ='Video']

thanks for the help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜