Permalink
Browse files

Merge pull request #87 from isubiker/master

Bugs and languages
  • Loading branch information...
2 parents f08dd27 + 38ef76f commit 1e729e7a015a041b5c9f331c6d031ab4c0f86f1c @eedeebee eedeebee committed Jul 6, 2012
View
@@ -45,6 +45,7 @@ declare variable $endpoints:ENDPOINTS as element(rest:options) :=
<param name="addPermission" alias="addPermission[]" repeatable="true" required="false"/>
<param name="removePermission" alias="removePermission[]" repeatable="true" required="false"/>
<param name="quality" required="false"/>
+ <param name="language" required="false" />
<param name="contentForBinary" required="false"/>
<param name="moveTo" required="false"/>
<param name="extractMetadata" required="false" as="boolean" default="true"/>
@@ -59,6 +60,7 @@ declare variable $endpoints:ENDPOINTS as element(rest:options) :=
<param name="property" alias="property[]" repeatable="true" required="false"/>
<param name="permission" alias="permission[]" repeatable="true" required="false"/>
<param name="quality" required="false"/>
+ <param name="language" required="false" />
<param name="contentForBinary" required="false"/>
<param name="extractMetadata" required="false" as="boolean" default="true"/>
<param name="extractContent" required="false" as="boolean" default="true"/>
@@ -86,6 +88,7 @@ declare variable $endpoints:ENDPOINTS as element(rest:options) :=
<param name="qualityWeight" required="false" as="decimal" default="1.0"/>
<param name="include" alias="include[]" repeatable="true" required="false" default="content"/>
<param name="filtered" required="false" default="false" as="boolean"/>
+ <param name="language" required="false" />
<param name="extractPath" required="false"/>
<param name="applyTransform" required="false"/>
<param name="collection" alias="collection[]" required="false" repeatable="true"/>
@@ -123,6 +126,7 @@ declare variable $endpoints:ENDPOINTS as element(rest:options) :=
<uri-param name="facets">$1</uri-param>
<param name="stringQuery" required="false"/>
<param name="structuredQuery" required="false"/>
+ <param name="language" required="false" />
<param name="limit" as="integer" default="25" required="false"/>
<param name="order" required="false" default="frequency" values="descending|ascending|frequency"/>
<param name="frequency" required="false" default="document" values="document|key"/>
View
@@ -45,15 +45,11 @@ let $frequency := map:get($params, "frequency")
let $includeAllValues := map:get($params, "includeAllValues")
let $txid := map:get($params, "txid")
-let $errors := (
- if(empty($stringQuery) and empty($structuredQuery))
- then common:error("corona:MISSING-PARAMETER", "Must supply either a string or a structured query", $outputFormat)
- else ()
-)
+let $errors := ()
let $query :=
if(exists($stringQuery))
- then stringquery:parse($stringQuery)
+ then stringquery:parse($stringQuery, map:get($params, "language"))
else if(exists($structuredQuery))
then try {
structquery:getCTS(structquery:getParseTree($structuredQuery), ())
@@ -103,7 +99,7 @@ let $values :=
let $query :=
if(exists($stringQuery))
- then stringquery:getCTSFromParseTree($rawQuery, $ignoreFacet)
+ then stringquery:getCTSFromParseTree($rawQuery, map:get($params, "language"), $ignoreFacet)
else if(exists($structuredQuery))
then structquery:getCTSFromParseTree($rawQuery, $ignoreFacet)
else $query
View
@@ -45,7 +45,7 @@ let $extractPath := map:get($params, "extractPath")
let $applyTransform := map:get($params, "applyTransform")
let $txid := map:get($params, "txid")
-let $outputFormat := map:get($params, "outputFormat")
+let $outputFormat := common:getOutputFormat((), map:get($params, "outputFormat"))
let $errors := (
if(exists($attribute) and empty($element))
View
@@ -383,7 +383,7 @@ declare function common:nsFromQName(
{
if(contains($item, ":"))
then
- let $ns := namespace-uri-from-QName($item)
+ let $ns := namespace-uri-from-QName(xs:QName($item))
where string-length($ns)
return $ns
else ()
@@ -394,7 +394,7 @@ declare function common:nameFromQName(
) as xs:string?
{
if(contains($item, ":"))
- then local-name-from-QName($item)
+ then local-name-from-QName(xs:QName($item))
else ()
};
View
@@ -126,12 +126,23 @@ declare function json:serialize(
A JSON item may also be the result return value of json:array or json:object.
:)
declare function json:document(
- $value as item()
+ $value as item(),
+ $language as xs:string?
) as element(json:json)
{
- <json:json version="1.0">{
+ <json:json version="1.0">{(
+ if(exists($language))
+ then attribute { xs:QName("xml:lang") } { $language }
+ else (),
json:untypedToJSONType($value)/(@*, node())
- }</json:json>
+ )}</json:json>
+};
+
+declare function json:document(
+ $value as item()
+) as element(json:json)
+{
+ json:document($value, ())
};
(:
View
@@ -153,7 +153,7 @@ declare function store:outputDocument(
if($outputFormat = "json")
then json:object((
"uri", $documentURI,
- if($include = ("content", "all"))
+ if($include = ("content", "highlighting", "all"))
then ("content", store:wrapContentNodes($content, $contentType))
else (),
if($include = ("collections", "all"))
@@ -184,7 +184,7 @@ declare function store:outputDocument(
else if($outputFormat = "xml")
then <corona:result>{(
<corona:uri>{ $documentURI }</corona:uri>,
- if($include = ("content", "all"))
+ if($include = ("content", "highlighting", "all"))
then <corona:content>{
if($contentType = "json")
then json:serialize(store:wrapContentNodes($content, $contentType))
@@ -461,7 +461,7 @@ declare function store:insertDocument(
$repair as xs:boolean
) as empty-sequence()
{
- store:insertDocument($uri, $content, $collections, $properties, $permissions, $quality, $contentType, $repair, (), map:map(), false())
+ store:insertDocument($uri, $content, $collections, $properties, $permissions, $quality, $contentType, (), $repair, (), map:map(), false())
};
declare function store:insertDocument(
@@ -472,6 +472,7 @@ declare function store:insertDocument(
$permissions as element()*,
$quality as xs:integer?,
$contentType as xs:string,
+ $language as xs:string?,
$repair as xs:boolean,
$applyTransform as xs:string?,
$requestParameters as map:map,
@@ -481,7 +482,7 @@ declare function store:insertDocument(
let $test := store:validateURI($uri)
let $body :=
if($contentType = "json")
- then json:parse($content)
+ then json:document(json:parse($content), $language)
else if($contentType = "xml")
then store:unquoteXML($content, $repair)
else if($contentType = "text")
@@ -562,13 +563,14 @@ declare function store:updateDocumentContent(
$repair as xs:boolean
) as empty-sequence()
{
- store:updateDocumentContent($uri, $content, $contentType, $repair, (), map:map(), false())
+ store:updateDocumentContent($uri, $content, $contentType, (), $repair, (), map:map(), false())
};
declare function store:updateDocumentContent(
$uri as xs:string,
$content as xs:string,
$contentType as xs:string,
+ $language as xs:string?,
$repair as xs:boolean,
$applyTransform as xs:string?,
$requestParameters as map:map,
@@ -582,7 +584,7 @@ declare function store:updateDocumentContent(
else ()
let $body :=
if($contentType = "json")
- then json:parse($content)
+ then json:document(json:parse($content), $language)
else if($contentType = "xml")
then store:unquoteXML($content, $repair)
else if($contentType = "text")
Oops, something went wrong.

0 comments on commit 1e729e7

Please sign in to comment.