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-ml"; | |
(: Copyright 2012 Grtjn. All Rights Reserved. :) | |
declare namespace textscan = "http://grtjn.nl/marklogic/plugin/textscan"; | |
import module namespace plugin = "http://marklogic.com/extension/plugin" at "/MarkLogic/plugin/plugin.xqy"; | |
import module namespace info="http://marklogic.com/appservices/infostudio" at "/MarkLogic/appservices/infostudio/info.xqy"; | |
import module namespace infodev="http://marklogic.com/appservices/infostudio/dev" at "/MarkLogic/appservices/infostudio/infodev.xqy"; |
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
ntripleDoc ::= (line eoln?)* EOF | |
line ::= comment | triple | |
triple ::= subject predicate object context? '.' | |
subject ::= uriref | nodeID | |
predicate ::= uriref |
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
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:local="local" xmlns:xdmp="http://marklogic.com/xdmp"> | |
<xsl:variable name="quot">"</xsl:variable> | |
<xsl:variable name="encoded-string-pattern">^"(([^\\"]+|\\[\\"nrt]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]|\\U[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])+)"(.*)</xsl:variable> | |
<xsl:template match="/"> | |
<!-- http://dbpedia.org/Downloads37 --> | |
<!-- example input: |
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
<xsl:stylesheet version="2.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
exclude-result-prefixes="#all"> | |
<!--+ | |
| Output specs | |
+--> | |
<xsl:output method="xml" encoding="UTF-8" indent="no" omit-xml-declaration="yes"/> | |
<xsl:preserve-space elements="*" /> |
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
(: A brief exampe of XQuery 3.0 + Scripting Extensions.. :) | |
(: This example was taken from a Twitter application | |
: written in XQuery! | |
:) | |
(: Follow functionality of Twitter :) | |
declare sequential function twitter:follow-friend() | |
{ | |
(: Get the id of user to be followed.. :) |
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
(: Small example of using versioning.. :) | |
(: Search for older editions of the current book | |
: of which the price was twice as much. | |
:) | |
past::book[(price div 2) ge current()/price] |
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
(: A small example of XQuery Data Definition Facility.. :) | |
(: Declare a ‘users’ collection :) | |
declare collection users as element()*; | |
(: Declare an index on top of ‘users’ using @id :) | |
declare automatically maintained index users-by-id | |
on nodes xqddf:collection( xs:QName("users") ) | |
by @id as xs:string; |
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
(: A small example of Update Facility.. :) | |
(: Add a new book.. :) | |
insert node | |
<book><title>XQuery novelties revisited</title></book> | |
as last into doc('books.xml')/books |
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
(: A small example of XPath Full Text.. :) | |
(: Search books of which the title begins with | |
‘XQuery’ and ‘novelties’ :) | |
//book[ | |
title contains text 'XQuery' ftand 'novelties' | |
ordered distance at most 2 words at start | |
] |
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
(: A brief comparison between XQuery and XSLT code :) | |
(: For-each in XQuery.. :) | |
for $b in $books | |
order by $b/title | |
return | |
$b/title | |
(: For-each in XSLT.. :) |