Created
April 7, 2012 19:33
-
-
Save joewiz/2331558 to your computer and use it in GitHub Desktop.
My XQuery snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<collection xmlns="http://exist-db.org/collection-config/1.0"> | |
<index> | |
<!-- Old full text index configuration. Deprecated. --> | |
<fulltext default="none" attributes="false"/> | |
<!-- New full text index based on Lucene --> | |
<lucene> | |
<text qname="SPEECH"> | |
<ignore qname="SPEAKER"/> | |
</text> | |
<text qname="TITLE"/> | |
</lucene> | |
<!-- Range indexes --> | |
<create qname="title" type="xs:string"/> | |
<!-- N-gram indexes --> | |
<ngram qname="title"/> | |
</index> | |
</collection> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0"; | |
declare namespace tei="http://www.tei-c.org/ns/1.0"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0"; | |
declare namespace tei="http://www.tei-c.org/ns/1.0"; | |
declare function local:render($node) { | |
typeswitch($node) | |
case text() return $node | |
case element(tei:div) return <div>{local:recurse($node)}</div> | |
case element(tei:p) return <p>{local:recurse($node)}</p> | |
default return local:recurse($node) | |
}; | |
declare function local:recurse($node) { | |
for $child in $node/node() | |
return | |
local:render($child) | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0"; | |
declare option exist:serialize "method=xhtml media-type=text/html indent=yes"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0"; | |
declare option exist:serialize "method=xhtml media-type=text/html indent=yes"; | |
let $title := 'My Title' | |
let $content := <p>My Content</p> | |
return | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>{$title}</title> | |
</head> | |
<body> | |
<div> | |
<h1>{$title}</h1> | |
{$content} | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment