Search
Tuesday, January 06, 2009 ..:: Forum ::.. Register  Login
 
  Forum  Templates  Tags & Template...   testing for last element
Previous Previous
 
Next Next
New Post 1/23/2008 5:28 PM
Resolved
  rfligg
43 posts
7th Level Poster


testing for last element 
can you use an if statement like "position() != last()" in AutoTag? I cant seem to get it to work.
 
New Post 1/23/2008 5:28 PM
  rfligg
43 posts
7th Level Poster


Re: testing for last element 
Charlie,

That should work, however it has to be a completly legit XPath statement - Could you post your complete XPath statement you are using so I could try in our test environment?

--Ryan
 
New Post 1/23/2008 5:30 PM
  rfligg
43 posts
7th Level Poster


Re: testing for last element 
Modified By rfligg  on 1/23/2008 5:33:28 PM)

This is in a for-each loop and I am listing out text from the elements and separating them by commas. I do not want the last element to have a comma after it.

This is what my xpath expression looks like in AutoTag
<wr:if test=&quot;position() != last() &quot;">

Here is example xml
<cars>
<car>
<Type>SUV</Type>
</car>
<car>
<Type>Sedan</Type>
</car>
<car>
<Type>Minivan</Type>
</car>
</cars>

So the output would look like:
SUV,Sedan,Minivan

I can get the text from the elements to output correctly, just can't get the commas to look right.

 
New Post 1/23/2008 5:33 PM
  rfligg
43 posts
7th Level Poster


Re: testing for last element 

 Charlie,

First, to use an XPath statement you must use select=, not test=.

Second, the best way to do this is to do a varStatus in the forEach and then do a test="! ${varStatus_name.last}"

--Ryan

 
Previous Previous
 
Next Next
  Forum  Templates  Tags & Template...   testing for last element
Membership Membership:
Latest New User Latest: GrahamA
New Today New Today: 0
New Yesterday New Yesterday: 0
User Count Overall: 56

People Online People Online:
Visitors Visitors: 1
Members Members: 0
Total Total: 1

Online Now Online Now:
All contents copyright (c) 2002 - 2008 by Windward Studios, Inc. All Rights Reserved.   Terms Of Use  Privacy Statement