test to find value

M

mike

I have an xml structure like:

<data>
<struct>1,8,7,30</struct>
</data>

and I need to develop a test that finds this node in each of these
cases, something like:

should find because 1 is in the node
<xsl:if test="struct='1'">

should find because 1 and 8 is in the node
<xsl:if test="struct='1,8'">

should find because 1 and 8 and 7 is in the node
<xsl:if test="struct='1,8,7'">

should find because 1 and 8 and 7 and 30 is in the node
<xsl:if test="struct='1,8,7,30'">

any help is appreciated.

Mike
 
D

David Carlisle

<xsl:variable name="x" select="concat(,normalize-space(struct),',')"/>

<xsl:if test="contains($x,',1,') and contains($x,',8,')">
contains 1 and 8
....
 
M

Martin Honnen

mike said:
I have an xml structure like:

<data>
<struct>1,8,7,30</struct>
</data>

and I need to develop a test that finds this node in each of these
cases, something like:

should find because 1 is in the node
<xsl:if test="struct='1'">

should find because 1 and 8 is in the node
<xsl:if test="struct='1,8'">

should find because 1 and 8 and 7 is in the node
<xsl:if test="struct='1,8,7'">

should find because 1 and 8 and 7 and 30 is in the node
<xsl:if test="struct='1,8,7,30'">

In XSLT there is
<xsl:choose>
<xsl:when test="struct = '1'">
...
</xsl:when>
<xsl:when test="struct = '1,8'">

</xsl:when>
</xsl:choose>
perhaps you are looking for that?
Or you can write an XPath expression with the boolean or
<xsl:if test="struct = '1' or struct = '1,8'">
 
D

David Carlisle

I wrote

<xsl:variable name="x" select="concat(,normalize-space(struct),',')"/>

I meant

<xsl:variable name="x" select="concat(',',normalize-space(struct),',')"/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top