2010-09-27 79 views
1

我正在处理XML项目,当我尝试连接我的Xquery中的json文件时遇到问题。解析来自Xquery的json

我会解释我的问题更多的细节:

我不知道如何读XQuery中的JSON文件,我在XQuery中有一个URL(此URL有一个JSON文件),并且该网址是下一页:

http://discomap.eea.europa.eu/ArcGIS/rest/services/Admin/EuroBoundaries_Dyna_WGS84/MapServer/2/query?text=&geometry=16.4027431529776,57.0126631873995&geometryType=esriGeometryPoint&inSR=&spatialRel=esriSpatialRelIntersects&where=&returnGeometry=false&outSR=&outFields=NUTS_CODE&f=json 

此URL下一个信息:

{ 
"displayFieldName":"ICC", 
"fieldAliases":{ 
     "ICC":"ICC", 
     "NUTS_CODE":"NUTS_CODE" 
      }, 
"features":[{ 
     "attributes":{ 
      "ICC":"SE", 
      "NUTS_CODE":"SE21" 
        } 
      }] 
} 

所以,我要读XQuery中此JSON文件或得到一个函数来此JSON文件转换为XML文件。

通过互联网,我得到这个代码:

我们进口的json模块,他们是功能,但下面的网址不工作,所以这是不可能解析这个功能。

import module namespace json ="http://www.zorba-xquery.com/zorba/json-functions"; 

declare function xmlconv:RestWEB() 
{ 
let $var := "&" 

let $datocor1 := "16.4027431529776," 
let $datocor2 := "57.0126631873995" 
let $dat1 := concat("geometry=",$datocor1, $datocor2) 

let $dat2 := "geometryType=esriGeometryPoint" 
let $dat3 := "inSR=" 
let $dat4 := "spatialRel=esriSpatialRelIntersects" 
let $dat5 := "where=" 
let $dat6 := "returnGeometry=false" 
let $dat7 := "outSR=" 
let $dat8 := "outFields=NUTS_CODE" 
let $dat9 := "f=json" 

let $URLinicial := concat($var,$dat1,$var,$dat2,$var,$dat3,$var,$dat4,$var,$dat5,$var,$dat6,$var,$dat7,$var,$dat8,$var,$dat9) 

let $URLFinal := concat($restWeb2,$URLinicial) 

let $FinalResult := json:parse((doc($URLFinal))) 
return 
    <div> 

     {$FinalResult} 

    </div> 
}; 

正如你所看到的,json:parse((doc($URLFinal)))是我尝试解析JSON文件,XML文件的功能,但它是不可能执行,因为我不能在此页面中输入的模块:www.zorba- xquery.com/zorba/json-functions。

让我知道如果你知道一些功能来解决这个问题,或者你需要更多的信息。

在此先感谢

大卫

回答

1

正确的模块导入:

进口模块命名空间JSON = “http://www.zorba-xquery.com/modules/json”;

请检查出左巴JSON文件:http://www.zorba-xquery.com/doc/zorba-1.2.0/zorba/xqdoc/xhtml/com/zorba-xquery/www/modules/json.html

在28msec网站上,你可以找到写在XQuery的Web应用程序,其使用这些功能的例如:http://www.28msec.com/support_templates_json_jsonml/index

+0

Zorba现在已经为JSON提供了一流的支持。你可以试试http://www.zorba-xquery.com/html/jsoniq – wcandillon 2012-02-22 08:44:21