Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > another XSLT problem

Reply
Thread Tools

another XSLT problem

 
 
Peter Flynn
Guest
Posts: n/a
 
      09-07-2005
ned786 wrote:
>> > <xsl:variable name="wri"
>> > select="count(items/item[(not(@doc = 'no') and @iname !=
>> > starts-with(@iname,'dr')) and
>> > (not(@doc = 'no') and @iname != starts-with(@iname,'hr')) and
>> > (not(@doc = 'no') and @iname != starts-with(@iname,'usr')) and
>> > (not(@doc = 'no') and @iname != starts-with(@iname,'szr')) and
>> > (not(@doc = 'no') and @iname != starts-with(@iname,'ulr')) and
>> > (not(@doc = 'no') and @iname != starts-with(@iname,'ipr')) and
>> > (not(@doc = 'no') and @iname != starts-with(@iname,'br')) and
>> > (not(@doc = 'no') and @iname != starts-with(@iname,'ucr'))])"/>

>>
>> I'm not clear what this is trying to achieve. @iname is an attribute:
>> testing its inequality against a boolean like starts-with will probably
>> have unexpected effects, depending on whether the attribute is present
>> or not. If present, and starting with 'hr', then the first test should
>> always evaluate false.

>
> Here's what this achieves. This XPath finds all the writable <item>
> elements for me, because I can identify them when the iname attribute
> does NOT start with one of the read-only strings (hr, usr, ulr, etc.).
>
> If you are questioning the syntax of saying "@iname !=
> starts-with(@iname,...)" instead of just "!= starts-with(@iname,...)",
> I did it that way because it seemed I had to or it didn't work. When I
> remove the "@iname !=", I get the error "Unexpected token != in
> expression" and it stops the transform. (I'm using Saxon at the command
> line.)


It's the = sign I'm questioning. What about !starts-with or
not(starts-with(...))

I am reminded of the programming language built into the P-Stat stats
package (PPL) which contained the amazingly useful syntax

if any(varname,varname,varname,...) among (value,value,value,...)



///Peter

 
Reply With Quote
 
 
 
 
ned786
Guest
Posts: n/a
 
      09-08-2005
I tried out what you suggest.

This works:
(not(@doc = 'no') and not(starts-with(@iname,'dr')))

This doesn't work and stops the transform:
(not(@doc = 'no') and !starts-with(@iname,'dr'))

with this error:
"!" without "=" in expression count(...etc.

Your "not(starts-with..." makes the XPath simpler and easier for
someone to understand, so I'll use it.

Thanks yet again!
Mark

 
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
XSLT question: How to lookup another tag's children in XSLT yinglcs@gmail.com XML 18 10-03-2006 11:22 PM
Multiple XSLT Transforms using a Controller XSLT sneill@mxlogic.com XML 2 10-19-2005 11:00 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
xslt alone or xslt/java for static site? ted XML 1 01-26-2004 10:41 AM
[XSLT]Passing values from Javascript to a XSLT variable Benjamin Hillsley XML 3 09-25-2003 04:50 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57