Created
July 23, 2012 20:00
-
-
Save anonymous/3165861 to your computer and use it in GitHub Desktop.
custom constraint XQuery in MarkLogic
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"; | |
module namespace my="http://stuartmyles.com/ns/mysearch"; | |
declare namespace appl="http://ap.org/schemas/03/2005/appl"; | |
declare namespace appls="http://ap.org/schemas/09/2011/applsearch"; | |
declare function ovparty( | |
$constraint-qtext as xs:string, | |
$right as schema-element(cts:query)) | |
as schema-element(cts:query) | |
{ | |
let $query := | |
<root>{ | |
let $s := fn:string($right//cts:text/text()) | |
return | |
cts:element-query( | |
xs:QName("appl:EntityClassification"), | |
cts:and-query(( | |
cts:element-attribute-value-query( | |
xs:QName("appl:EntityClassification"), | |
xs:QName("Authority"), | |
"AP Party"), | |
cts:element-attribute-word-query( | |
xs:QName("appl:Occurrence"), | |
xs:QName("Value"), | |
$s) | |
)) | |
) | |
} | |
</root>/* | |
return | |
$query | |
} ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment