Skip to content

Instantly share code, notes, and snippets.

@baskaufs
Created May 26, 2015 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baskaufs/045687fa9c14df8d33b9 to your computer and use it in GitHub Desktop.
Save baskaufs/045687fa9c14df8d33b9 to your computer and use it in GitHub Desktop.
query with problematic default namespace declaration
xquery version "3.0";
declare namespace sitemap="http://www.sitemaps.org/schemas/sitemap/0.9";
(:
*********** Get data from GitHub *********
:)
let $textOrganisms := http:send-request(<http:request method='get' href='https://raw.githubusercontent.com/baskaufs/Bioimages/master/organisms.csv'/>)[2]
let $xmlOrganisms := csv:parse($textOrganisms, map { 'header' : true(),'separator' : "|" })
(:
*********** Main query *********
:)
return (
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">{
for $org in $xmlOrganisms//record
order by $org/dcterms_modified descending
return (
<url>
<loc>{$org/dcterms_identifier/text()}</loc>
<lastmod>{$org/dcterms_modified/text()}</lastmod>
</url>
)
}</urlset>
)
@CliffordAnderson
Copy link

Try this

xquery version "3.0";
declare default element namespace "http://www.sitemaps.org/schemas/sitemap/0.9";

(:
*********** Get data from GitHub *********
:)
let $textOrganisms := http:send-request(<http:request method='get' href='https://raw.githubusercontent.com/baskaufs/Bioimages/master/organisms.csv'/>)[2]
let $xmlOrganisms := csv:parse($textOrganisms, map { 'header' : true(),'separator' : "|" })
return 
(:
*********** Main query *********
:) 
(
        <urlset>{
          for $org in $xmlOrganisms//*:record
          order by $org/*:dcterms_modified descending
          return (
                 <url>
                   <loc>{$org/*:dcterms_identifier/text()}</loc>
                   <lastmod>{$org/*:dcterms_modified/text()}</lastmod>
                 </url>
                 )
        }</urlset>
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment