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
ho manSubject: how to list distinct value?
Author: ho man
Date: 13 Mar 2009 02:52 AM
Good morning all,
I create an xml sitemap from http://www.xml-sitemaps.com/ and import to db2

- <urlset>
- <url>
<loc>http://www.comp.polyu.edu.hk/</loc>
<priority>1.00</priority>
<lastmod>2009-02-13T01:22:18-00:00</lastmod>
<changefreq>daily</changefreq>
</url>
- <url>
<loc>http://www.comp.polyu.edu.hk/contentpage.php-id=20060522151723-lang=e</loc>
<priority>0.80</priority>
<changefreq>daily</changefreq>
</url>
- <url>
<loc>http://www.comp.polyu.edu.hk/contentpage.php-id=20070823112439-lang=e</loc>
<priority>0.64</priority>
<changefreq>daily</changefreq>
</url>
.
.
.
- <url>
<loc>http://www.comp.polyu.edu.hk/icwl2005/icwl-cfp-web.pdf</loc>
<priority>0.41</priority>
<changefreq>daily</changefreq>
</url>
- <url>
<loc>http://www.comp.polyu.edu.hk/conference/2005/icwl2005-all.pdf</loc>
<priority>0.41</priority>
<changefreq>daily</changefreq>
</url>
- <url>
<loc>http://www.comp.polyu.edu.hk/conference/PRDC05/cfp.htm</loc>
<priority>0.41</priority>
<lastmod>2005-05-12T06:36:43-00:00</lastmod>
<changefreq>daily</changefreq>
</url>
- <url>
<loc>http://www.comp.polyu.edu.hk/conference/PRDC05/The Program for PRDC05.htm</loc>
<priority>0.41</priority>
<lastmod>2005-12-08T14:08:43-00:00</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>

I want to use xquery to list the website path which have the word "conference" in the path and return only the distinct path if the same path have more than one file.

For example:
The above list have three path that contain the word "conference", but two of them have the same path


http://www.comp.polyu.edu.hk/conference/2005/
http://www.comp.polyu.edu.hk/conference/PRDC05/


I know the contains function which return the list of path which contain the word "conference", but I don't know what the next step to do...

xquery
for $tmp in db2-fn:xmlcolumn('SITEMAP_TABLE.SITEMAP_XML')/urlset/url
where ($tmp/loc) [contains(.,"conference")]
return data($tmp/loc);

Postnext
John BamptonSubject: how to list distinct value?
Author: John Bampton
Date: 13 Mar 2009 02:54 AM
use the distinct-values function

Postnext
ho manSubject: how to list distinct value?
Author: ho man
Date: 13 Mar 2009 03:24 AM
Originally Posted: 13 Mar 2009 02:58 AM
but the path have the file name at the end, so the distinct value not work

Postnext
Minollo I.Subject: how to list distinct value?
Author: Minollo I.
Date: 13 Mar 2009 04:51 PM
Something like this:

declare function local:get-path($url as xs:string) as xs:string {
let $urlComponents := tokenize($url, "/")
return string-join(subsequence($urlComponents, 1, count($urlComponents)-1), "/")
};

let $input :=
<urlset>
...
</urlset>
for $url in distinct-values($input//url/loc[contains(., "/conference/")]/local:get-path(.))
return $url

Posttop
ho manSubject: how to list distinct value?
Author: ho man
Date: 14 Mar 2009 02:23 PM
It work.
Thank for your help.

 
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.