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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2017)
-> + Issue with Processing Instruct... (2)
-> + problem converting json to XML... (2)
-> + Problem base64 decoding string... (3)
-> + Problems posting multipart for... (5)
-> + trouble with download of price... (2)
-> + Problem with http-post not bei... (3)
-> + path problem, xps_file:writeAl... (9)
-> + Xquery update support? (2)
-> + problem with Stylus studio try... (5)
-> + adding dtd reference to xml ou... (4)
-> + xquery escaping ambarsand when... (3)
-> + Whitespace problem when return... (5)
-> + Problem with namespace prefix ... (5)
-> - Sending via SFTP returns unexp... (1)
-> + Query and Sftp clent (4)
-> + xquery and try - catch (3)
-> + Query + ddtek:http-post optio... (5)
-> + Example files referenced in do... (3)
-> + Automatic Error Detection and ... (3)
-> + Working with result of ddtek:h... (2)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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%

   
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.