【问题标题】:MarkLogic Structure query searchMarkLogic 结构查询搜索
【发布时间】:2017-05-26 11:54:58
【问题描述】:

我有以下 xml。

<prop:properties xmlns:prop="http://marklogic.com/xdmp/property">
  <cpf:processing-status xmlns:cpf="http://marklogic.com/cpf">done</cpf:processing-status>
  <cpf:property-hash xmlns:cpf="http://marklogic.com/cpf">6b9dab35ed148cd08bba59503892a0fd</cpf:property-hash>
  <cpf:last-updated xmlns:cpf="http://marklogic.com/cpf">2017-05-23T17:56:54.5734822+05:30</cpf:last-updated>
  <cpf:state xmlns:cpf="http://marklogic.com/cpf">http://marklogic.com/states/converted</cpf:state>
  <lnk:link from="/mycompany/mlabcNew_doc.xhtml" to="/mycompany/mlabcNew.doc" rel="source" rev="conversion" strength="strong" xmlns:lnk="http://marklogic.com/cpf/links"/>
  <cpf:self xmlns:cpf="http://marklogic.com/cpf">/mycompany/mlabcNew.doc</cpf:self>
</prop:properties>

我想使用 java 客户端 API 获取属性 'to' 的值(即 /mycompany/mlabcNew.doc)

我尝试了以下结构化查询来获取结果,但没有得到结果

StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder();

    StructuredQueryDefinition query = qb.properties(
                qb.word(qb.elementAttribute(
                            qb.element(new QName("http://marklogic.com/cpf/links", "link")), 
                            qb.attribute(new QName("http://marklogic.com/cpf/links", "to"))), 
                        "/mycompany/mlabcNew_doc.xhtml"));

我没有找到获得这个的方法。请帮忙

【问题讨论】:

    标签: marklogic marklogic-8


    【解决方案1】:

    根据您的示例,名为“to”的属性的命名空间不是 cpf/links 命名空间。

    试试:

    StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder();
    
        StructuredQueryDefinition query = qb.properties(
                    qb.word(qb.elementAttribute(
                                qb.element(new QName("http://marklogic.com/cpf/links", "link")), 
                                qb.attribute(new QName("", "to"))), 
                            "/mycompany/mlabcNew_doc.xhtml"));
    

    注意:在排除此类问题时,我通常使用 xPath 在查询控制台中确认元素和属性名称以及命名空间。这会移除许多层,并且在某些情况下使故障排除更加简单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多