【问题标题】:How to query from inside BaseX?如何从 BaseX 内部查询?
【发布时间】:2013-02-04 10:35:57
【问题描述】:

我已将我的 Maven 配置导入 BaseX,但找不到查询它的方法。

我想查询 id="thirdparty-releases" 的仓库

以下都不起作用:

/settings/profiles/profile/repositories/repository[id="thirdparty-releases"]

db:open("settings","settings.xml")/settings/profiles/profile/repositories/repository[id="thirdparty-releases"]

我的配置如下:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>D:\Users\Dims\Design\!Lib\!m2\repository</localRepository>



  <pluginGroups>

  </pluginGroups>
  <proxies>
  </proxies>
  <servers>
  </servers>
  <mirrors>
  </mirrors>
  <profiles>
    <profile>
      <id>env-dev</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <repositories>
        <repository>
          <id>jboss-public-repository-group</id>
          <name>JBoss Public Repository Group</name>
          <url>http://repository.jboss.org/nexus/content/groups/public/</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </snapshots>
        </repository>
        <repository>
          <id>thirdparty-releases</id>
          <name>JBoss Thirdparty Releases</name>
          <url>https://repository.jboss.org/nexus/content/repositories/thirdparty-releases</url>
        </repository>
        <repository>
          <id>maven2-repository.dev.java.net</id>
          <name>Java.net Repository for Maven</name>
          <url>http://download.java.net/maven/2/</url>
        </repository>
      </repositories>
    </profile>
  </profiles>
</settings>

【问题讨论】:

  • 您使用哪种语言和库?
  • BaseX 数据库中的 XQuery 3.0
  • doc("filename.xml")/document/page[id=1]

标签: xml xquery basex


【解决方案1】:

您的数据具有不同的命名空间(请参阅 &lt;settings /&gt; 节点中的 xmlns)。您要么必须更改查询中的命名空间,要么也可以使用通配符选择器进行查询,例如/*:settings/*:profiles/...

【讨论】:

  • 以及如何更改查询中的命名空间?
  • declare default element namespace "http://maven.apache.org/SETTINGS/1.0.0";
  • 不,否则它会起作用,不是吗?至少在您发布的简单 xpath sn-p 中您没有声明任何内容,那么 XQuery 处理器应该在哪里知道它?您必须在 XQuery 代码中这样做
【解决方案2】:

什么意思:

我想查询 id="thirdparty-releases" 的仓库

因为这对我来说更像是一个专家级的问题......?


BaseX 本身,我相信您知道,它是一个独立的数据库。如果您只需要查询现有数据,甚至不需要使用JDK,尽管BaseX 是一个Java 应用程序,您将需要一个JVM——所以maven 并没有真正进入图片。

它有一个 GUI,很容易上手。

如果您想要从 Java 程序运行命令,那么您可以随时查看 github examples 或在 available 命令上引用 Javadoc

当然,stackoverflow 上有很多BaseX 问题,目前超过三百个,对于 [basex] [java],我看到了近五十个结果。有一个出色的邮件列表,主要开发人员以及列表中的其他所有人都非常有空且乐于助人。

诚然,我不明白你的问题。为什么要将 maven 配置导入 BaseX

如果您只是想在数据库上运行 xpathxquery,我的建议是使用 GUI。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-02
    • 1970-01-01
    • 2017-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-23
    相关资源
    最近更新 更多