XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
nido abuSubject: Xquery
Author: nido abu
Date: 25 Oct 2005 06:46 AM
Hi
I have problem with the following xquery


<books>

{
for $d in //td[contains(b/a/text(),"The Year of Magical Thinking")]
for $row in $d/parent::tr/parent::tbody/tr
where contains($d/b/a/text(),"The Year of Magical Thinking")
return
<book>
<probe name= "{($row/td[3]/text())}"></probe>
<Author>{substring-before(($row/td[3]/text()),':')} </Author>
<booktitile>{data($row/td[3]/b/a)} </booktitile>
</book>

}

</books>

everything was ok. despite of the following line:

<Author>{substring-before(($row/td[3]/text()),':')} </Author>

I became this error:
A sequence of more than one item is not allowed as the first argument of
substring-before().
Is here anybody who can help me
thanks a lot


Postnext
(Deleted User) Subject: Xquery
Author: (Deleted User)
Date: 25 Oct 2005 09:17 AM
This is probably because text() in your case matches 2 text nodes:

compare :

<td>
just one text node
</td>

with:

<td>
text node before
<a/>
text node after
</td>

Postnext
nido abuSubject: Xquery
Author: nido abu
Date: 26 Oct 2005 05:17 AM
I tried the following (without substring-before):
<books>

{
for $d in //td[contains(b/a/text(),"The Year of Magical Thinking")]
for $row in $d/parent::tr/parent::tbody/tr
where contains($d/b/a/text(),"The Year of Magical Thinking")
return
<book>
<booktitle>{data($row/td[3]/b/a)} </booktitle>
<Author>{($row/td[3]/text())} </Author>
</book>
}

</books>

the result was like this:
.
.
<book>
<booktitle>A Million Little Pieces </booktitle>
<Author>James Frey Average Customer Review</Author>
</book>
.
.
.
but what I realy need, only the name of the Author. so i thought that substring-before function will be helpful (all the text before 'Average')

can you help me pleas.
thanks a lot

Postnext
(Deleted User) Subject: Xquery
Author: (Deleted User)
Date: 26 Oct 2005 09:58 AM
You can use substring-before($row/td[3]/text()[1],':')
to get first text node

or

substring-before($row/td[3]/text()[2],':')
to get second text node

or join all text nodes to form single string.

Posttop
nido abuSubject: Xquery
Author: nido abu
Date: 27 Oct 2005 06:30 AM
thank you very much
it worked 100%

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.