Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > test to find value

Reply
Thread Tools

test to find value

 
 
mike
Guest
Posts: n/a
 
      03-13-2005
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

 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      03-13-2005

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

<xsl:if test="contains($x,',1,') and contains($x,',8,')">
contains 1 and 8
....
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      03-13-2005


mike wrote:

> 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'">

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
David Carlisle
Guest
Posts: n/a
 
      03-13-2005

I wrote

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

I meant

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
test test test richard Computer Support 3 01-24-2007 05:18 AM
TEST TEST Test...Blah Blah Blah generalbatguano@pacbell.net Computer Support 2 09-15-2006 03:47 AM
TEST TEST Test...Blah Blah Blah Generalbatguano@pacbell.net Computer Support 6 09-13-2006 01:53 AM
TEST TEST TEST Gazwad Computer Support 2 09-05-2003 07:32 PM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments