如何在Marklogic或Couchbase中进行xslt类型转换?

如何在Marklogic或Couchbase中进行xslt类型转换?,couchbase,marklogic,nosql,Couchbase,Marklogic,Nosql,我正在寻找一种noSQL解决方案,用于数据连接和转换到其他数据结构——特别是在marklogic和couchbase 我的问题是:如何在基于json的数据库中进行xslt之类的转换?我对CouchBase不够熟悉,无法评论它的功能 MarkLogic允许通过XPath或JSONPath进行简单的转换。我不会称之为“像xslt”,但它绝对是更新JSON文档特定部分的一种方法。此外,MarkLogic允许您选择更适合您的风格。MarkLogic的REST API、Java API和Node.JS A

我正在寻找一种noSQL解决方案,用于数据连接和转换到其他数据结构——特别是在marklogic和couchbase


我的问题是:如何在基于json的数据库中进行xslt之类的转换?

我对CouchBase不够熟悉,无法评论它的功能


MarkLogic允许通过XPath或JSONPath进行简单的转换。我不会称之为“像xslt”,但它绝对是更新JSON文档特定部分的一种方法。此外,MarkLogic允许您选择更适合您的风格。MarkLogic的REST API、Java API和Node.JS API的用户可以使用转换和修补程序。

我对CouchBase不太熟悉,无法评论它的功能


MarkLogic允许通过XPath或JSONPath进行简单的转换。我不会称之为“像xslt”,但它绝对是更新JSON文档特定部分的一种方法。此外,MarkLogic允许您选择更适合您的风格。MarkLogic的REST API、Java API和Node.JS API的用户可以使用转换和修补程序。

此外,MarkLogic支持SPARQL,它可以执行RDF转换(如果这是所选的数据格式),并且可以以XML或JSON格式序列化。与Couchbase不同,RDF三元组可以在文档中表示(通常为文档元数据),也可以表示为三元组存储。文档既可以表示文档的元数据,也可以提供与基于RDF的外部数据(包括链接的开放数据)的类型化关系。

此外,MarkLogic支持SPARQL,可以执行RDF转换(如果这是所选的数据格式),并且可以以XML或JSON格式序列化。与Couchbase不同,RDF三元组可以在文档中表示(通常为文档元数据),也可以表示为三元组存储。文档既可以表示文档的元数据,也可以提供与外部RDF的类型化关系,包括链接的开放数据。

使用MarkLogic JSON模块将JSON转换为XML,并使用XSLT语言:

xquery version "1.0-ml";
import module namespace json = "http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy";
declare variable $j := '{"content": {"name": "Joe Parent","children": [{"name": "Bob Child"}, {"name": "Sue Child"}, {"name": "Guy Child"}]}}';
let $doc := json:transform-from-json($j),
$params := map:map(),
$_put := map:put($params,"childName","Bob Child")
return xdmp:xslt-invoke("/templates.xsl",$doc,$params)
其中“/templates.xsl”被插入到模块数据库中:

xquery version "1.0-ml";
let $xslt:= <xsl:stylesheet version="2.0" exclude-result-prefixes="json" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:json="http://marklogic.com/xdmp/json/basic">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:param name="childName"/>
<xsl:template match="json:content">
&quot;ParentName&quot;:<xsl:if test='$childName = json:children/json:json/json:name/text()'>&quot;<xsl:value-of select="json:name/text()"/>&quot;</xsl:if>
</xsl:template>
</xsl:stylesheet>
return xdmp:document-insert("/templates.xsl",$xslt)
xquery版本“1.0-ml”;
让$xslt:=
“父项名称”:”
返回xdmp:documentinsert(“/templates.xsl”,$xslt)

使用MarkLogic JSON模块将JSON转换为XML,并使用XSLT语言:

xquery version "1.0-ml";
import module namespace json = "http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy";
declare variable $j := '{"content": {"name": "Joe Parent","children": [{"name": "Bob Child"}, {"name": "Sue Child"}, {"name": "Guy Child"}]}}';
let $doc := json:transform-from-json($j),
$params := map:map(),
$_put := map:put($params,"childName","Bob Child")
return xdmp:xslt-invoke("/templates.xsl",$doc,$params)
其中“/templates.xsl”被插入到模块数据库中:

xquery version "1.0-ml";
let $xslt:= <xsl:stylesheet version="2.0" exclude-result-prefixes="json" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:json="http://marklogic.com/xdmp/json/basic">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:param name="childName"/>
<xsl:template match="json:content">
&quot;ParentName&quot;:<xsl:if test='$childName = json:children/json:json/json:name/text()'>&quot;<xsl:value-of select="json:name/text()"/>&quot;</xsl:if>
</xsl:template>
</xsl:stylesheet>
return xdmp:document-insert("/templates.xsl",$xslt)
xquery版本“1.0-ml”;
让$xslt:=
“父项名称”:”
返回xdmp:documentinsert(“/templates.xsl”,$xslt)

MarkLogic 8也存储本机JSON。但这个问题不符合SO准则,所以我怀疑它会被关闭。MarkLogic 8也存储本机JSON。但是这个问题不符合指导方针,所以我怀疑它会被关闭。谢谢。回答得好,谢谢。回答得很好。