Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > testing a field

Reply
Thread Tools

testing a field

 
 
Michael Hill
Guest
Posts: n/a
 
      01-21-2005
I have a xslt stylesheet where I need to test for not one item, but
many.

I know I can do:

<xsl:test="field='one'">

but if I have a list to check like:

'one', 'two', 'three' how would I check those.

This does not work:

<xsl:test="field='one|two|three'">

Mike


 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      01-21-2005
In article <Z2ZHd.2054$(E-Mail Removed)>,
Michael Hill <(E-Mail Removed)> wrote:

>This does not work:
>
><xsl:test="field='one|two|three'">


<xsl:if test="field='one'|field='two'|field='three'">

-- Richard

 
Reply With Quote
 
 
 
 
Michael Hill
Guest
Posts: n/a
 
      01-21-2005

>>This does not work:
>>
>><xsl:test="field='one|two|three'">

>
> <xsl:if test="field='one'|field='two'|field='three'">
>
> -- Richard
>


Does not work. I am getting this error message:


Expression does not return a DOM node.
status=-->'Approved'|<--status='Proposed'

Mike



 
Reply With Quote
 
David Carlisle
Guest
Posts: n/a
 
      01-21-2005

test="field[.='one' or . = 'two' or .='three']"

David
 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      01-21-2005
In article <TN6Id.2637$(E-Mail Removed)>,
Michael Hill <(E-Mail Removed)> wrote:

>> <xsl:if test="field='one'|field='two'|field='three'">


Oops, I meant "or" not "|":

<xsl:if test="field='one' or field='two' or field='three'">

-- Richard
 
Reply With Quote
 
Joris Gillis
Guest
Posts: n/a
 
      01-24-2005
Tempore 02:36:58, die Friday 21 January 2005 AD, hinc in foro {comp.text.xml} scripsit Michael Hill <(E-Mail Removed)>:

> I have a xslt stylesheet where I need to test for not one item, but
> many.
>
> I know I can do:
>
> <xsl:test="field='one'">
>
> but if I have a list to check like:
>
> 'one', 'two', 'three' how would I check those.

Hi,

use the 'contains()' function an a string version of the possible values. Choose a separator that will not occur in the 'field' element's text nodes.
In most occassions, this will work:
<xsl:if test="contains('one,two,three',field)" />

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Laudeo W3C et dona ferens
 
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
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
1.Enter space bar for field names and save the field.The field shoud not get saved and an alert should be there as"Space bars are not allowed" Sound Javascript 2 09-28-2006 02:43 PM
testing testing neville Computer Support 2 05-27-2005 09:57 AM
testing testing 123 daniel edwards Computer Support 4 05-20-2004 10:36 PM
testing--news2004--testing Boomer Computer Support 3 09-24-2003 06:54 PM



Advertisments