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
TL WSubject: Returning Values
Author: TL W
Date: 05 Apr 2006 10:14 AM
Hi,

Ok i have a .xq file that im using to return a list of photos in alphabetical order from my index.xml file, this is the code im using for the .xql file:

<html>
<body>
List abstract photos in order:
<br/>
<ul>
{
for $x in doc("index2.xml")/site/nav/thumbs/thumb/title
order by $x
return <li>{data($x)}</li>
}
</ul>
</body>
</html>

It does not output the thumbs nav title in alphabetical order as i expected it too, is there a reason why?

Heres the XML im using:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="index.xsl"?>
<site>
<sitename>XML/XSL Photo Application</sitename>
<css>style.css</css>
<nav>
<link>
<name>abstract</name>
<url>index.xml</url>
</link>
<link>
<name>architecture</name>
<url>architecture.xml</url>
</link>
<link>
<name>nature</name>
<url>nature.xml</url>
</link>
<link>
<name>food</name>
<url>food.xml</url>
</link>

<sectionname>abstract</sectionname> <!-- The abstract gallery -->
<thumbs>
<!-- Image One -->
<thumb>
<thumbsnavhref>abstract-brokenheart-main.xml</thumbsnavhref>
<thumbsnavclass>galleryimage</thumbsnavclass>
<thumbsnavtitle>Broken Heart</thumbsnavtitle>
<thumbssrc>abstract-brokenheart.jpg</thumbssrc>
<thumbswidth>140</thumbswidth>
<thumbsheight>80</thumbsheight>
<captiontitle>Broken Heart</captiontitle>
<indent>0</indent>
</thumb>
<!-- Image Two -->
<thumb>
<thumbsnavhref>abstract-lonelyfootsteps-main.xml</thumbsnavhref>
<thumbsnavclass>galleryimage</thumbsnavclass>
<thumbsnavtitle>Lonely Footsteps</thumbsnavtitle>
<thumbssrc>abstract-lonelyfootsteps.jpg</thumbssrc>
<thumbswidth>140</thumbswidth>
<thumbsheight>80</thumbsheight>
<captiontitle>Lonely Footsteps</captiontitle>
<indent>1</indent>
</thumb>
<!-- Image Three -->
<thumb>
<thumbsnavhref>abstract-mouse-main.xml</thumbsnavhref>
<thumbsnavclass>galleryimage</thumbsnavclass>
<thumbsnavtitle>Mouse</thumbsnavtitle>
<thumbssrc>abstract-mouse.jpg</thumbssrc>
<thumbswidth>140</thumbswidth>
<thumbsheight>80</thumbsheight>
<captiontitle>Mouse</captiontitle>
<indent>1</indent>
</thumb>
<!-- Image Four -->
<thumb>
<thumbsnavhref>notsureyet.xml</thumbsnavhref>
<thumbsnavclass>galleryimage</thumbsnavclass>
<thumbsnavtitle>Pure White</thumbsnavtitle>
<thumbssrc>abstract-purewhite.jpg</thumbssrc>
<thumbswidth>140</thumbswidth>
<thumbsheight>80</thumbsheight>
<captiontitle>Pure White</captiontitle>
<indent>0</indent>
</thumb>
<!-- Image Five -->
<thumb>
<thumbsnavhref>notsureyet.xml</thumbsnavhref>
<thumbsnavclass>galleryimage</thumbsnavclass>
<thumbsnavtitle>Falling Droplet</thumbsnavtitle>
<thumbssrc>abstract-fallingdroplet.jpg</thumbssrc>
<thumbswidth>140</thumbswidth>
<thumbsheight>80</thumbsheight>
<captiontitle>Falling Droplet</captiontitle>
<indent>1</indent>
</thumb>
<!-- Image Six -->
<thumb>
<thumbsnavhref>notsureyet.xml</thumbsnavhref>
<thumbsnavclass>galleryimage</thumbsnavclass>
<thumbsnavtitle>Beads</thumbsnavtitle>
<thumbssrc>abstract-beads.jpg</thumbssrc>
<thumbswidth>140</thumbswidth>
<thumbsheight>80</thumbsheight>
<captiontitle>Beads</captiontitle>
<indent>1</indent>
</thumb>
</thumbs>

</nav>
</site>

Thankyou for your time.

Postnext
Minollo I.Subject: Returning Values
Author: Minollo I.
Date: 05 Apr 2006 10:27 AM
As long as you use captiontitle (and not title, that doesn't exist) on the for instruction, it seems to work fine for me:

<html><body>
List abstract photos in order:
<br/><ul><li>Beads</li><li>Broken Heart</li><li>Falling Droplet</li><li>Lonely Footsteps</li><li>Mouse</li><li>Pure White</li></ul></body></html>

Postnext
TL WSubject: Returning Values
Author: TL W
Date: 05 Apr 2006 12:37 PM
Sorry that was just a typo error. Ah well im glad it is working but it doesnt seem to work if i drag these files in eXist and view them.

Ok if I wanted to advance this further by having the XQL search through my other 3 xml docs would I do this to the code:

<html>
<body>
List photos in order:
<br/>
<ul>
{
for $x in doc("index2.xml")/site/nav/thumbs/thumb/title
for $x in doc("index3.xml")/site/nav/thumbs/thumb/title
for $x in doc("index4.xml")/site/nav/thumbs/thumb/title
for $x in doc("index5.xml")/site/nav/thumbs/thumb/title

order by $x
return <li>{data($x)}</li>
}
</ul>
</body>
</html>

What about if I wanted also display the thumbssrc too (so the image)?
Thanks for your time

Postnext
Minollo I.Subject: Returning Values
Author: Minollo I.
Date: 05 Apr 2006 12:44 PM
Once again, I suggest that you talk about issues specific to eXist through the proper support channel.

About your second question, we are not going to walk you step by step through the process of learning XQuery; I'll just say that the cascading for loops are probably not going to work the way you expect (each nested for is going to loop through all items for each item of the outer loop); about showing additional data, either loop on "thumb" rather than on title, and then display $x/title and $x/whateverelse, or do $x/../whateverelse.

Minollo

Posttop
Tony LavinioSubject: Returning Values
Author: Tony Lavinio
Date: 06 Apr 2006 09:37 AM
Why don't you download a copy of Stylus Studio and use our XQuery
debugger, instead of using a tool which provides little development-time
support, from a group that in your own words provides no product support?
It seems you are making it unnecessarily hard on yourself.

"If you don't buy the tools you need, you will eventually pay for it, but
not have your tool." --Henry Ford.

 
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.