[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: error in XSL file when using JAXP

Subject: RE: error in XSL file when using JAXP
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 28 Jul 2005 12:20:12 +0100
xsl distinct values
test="distinct-values($aVal[for $a in .
return normalize-space($oVal)[contains(lower-case(.),lower-case($a))]])

I think you're trying to test whether at least one of the values in $aVal
satisfies some condition.

Firstly, I can't see why you're removing duplicates. If some $x in
distinct-values(X) satisfies a condition, then some $x in X must satisfy the
condition, so removing duplicates is unnecessary work.

So this reduces to 

test="exists($aVal[for $a in .
return normalize-space($oVal)[contains(lower-case(.),lower-case($a))]])

But this is still fishy. normalize-space() returns either a string or
nothing (an empty sequence). So it's an odd thing to apply a predicate to. I
think this reduces to

test="exists($aVal[contains(lower-case(normalize-space(.)),
lower-case($a))])"

or if you prefer

test="some $v in $aVal satisfies contains(lower-case(normalize-space($v)),
lower-case($a))"

This isn't precisely equivalent to the meaning of your expression under the
earlier version of the spec, but I suspect it's what you intended. For
example if distinct-values returns a single zero-length string then the EBV
is false, but exists() return true.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Rahil Qamar [mailto:qamar_rahil@xxxxxxxxxxx] 
> Sent: 28 July 2005 11:56
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  error in XSL file when using JAXP
> 
> Thanks David and Michael
> 
> Okay at least I think I know where the problem is
> arising now.
> 
> I have a section of code soon after the for-each loop
> which tests for the common values present in both the
> XML files imported at the start of the XSL.
> 
> The lines are:
> -----------
> <xsl:choose>
>    <xsl:when test="distinct-values($aVal[for $a in .
> return
> normalize-space($oVal)[contains(lower-case(.),lower-case($a))]])">
> 
> 	<xsl:variable name="matchingVals"
> select="distinct-values($aVal[for $a in . return
> normalize-space($oVal)[contains(lower-case(.),lower-case($a))]])"/>
> 					
> 	<xsl:if test="not(empty($matchingVals))">
> ----------
> Now the variable $matchingVals does not contain nodes
> but common atomic values.
> 
> Is there any other way of writing out this test case
> so that I can deal with the new version processor
> requirements?
> 
> Note: $aVal and $oVal are -
> ----------
> ////$arch = File1.xml
> ////$ont = File2.xml
> <xsl:variable name="aVal"
> select="$arch/SubConcepts/SubConcept/Value"/>
> 		
> <xsl:for-each select="$ont/SubConcepts/SubConcept">
>      <xsl:variable name="oVal" select="."/>
> 
> ---------
> 
> Thanks
> Rahil
> 
> --- David Carlisle <davidc@xxxxxxxxx> wrote:
> 
> > 
> > > Line 162 in the said file is :
> > 
> > That is not the line with generating the error
> > though. (Line numbering
> > can easily be out due to vagaries in dos/unix line
> > ends etc.
> > 
> > The error means that you have something like
> > 
> > test="zzzz"  or  ... [zzzzz]  and zzz evaluates to a
> > sequence whose
> > first item is not a node but is a number or a string
> > or some other
> > atomic value.  If the sequence doesn't consist of
> > nodes then to use it
> > as a boolean in a test it has to consist of a single
> > item, which is a
> > boolean value either true or false. If the sequence
> > is a sequence of
> > nodes then, as in xpath1 it will count as false if
> > it is empty and true
> > otherwise.
> > 
> > David
> > 
> > 
> >
> ______________________________________________________________
> __________
> > This e-mail has been scanned for all viruses by
> > Star. The
> > service is powered by MessageLabs. For more
> > information on a proactive
> > anti-virus service working around the clock, around
> > the globe, visit:
> > http://www.star.net.uk
> >
> ______________________________________________________________
> __________
> > 
> > 
> 
> 
> 
> 		
> ___________________________________________________________ 
> How much free photo storage do you get? Store your holiday 
> snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.