首页 \ 问答 \ 带有多个名称空间的SQL Server Xml查询(SQL Server Xml query with multiple namespaces)

带有多个名称空间的SQL Server Xml查询(SQL Server Xml query with multiple namespaces)

我在SQL服务器中有一个表,它包含一个Xml列,我无法查询它。 我对XPath知之甚少,无法确定我的查询是错误的,还是因为看起来像是有冲突的命名空间。 这里是一个例子xml:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
            xmlns:a="http://www.w3.org/2005/08/addressing" 
            xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <!-- snip -->
    </s:Header>
    <s:Body>
        <FetchRequest xmlns="http://www.foobar.org/my/schema">
            <Contract xmlns:a="http://www.foobar.org/2014/04/datacontracts"
                      xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <a:RequestedBy>John Doe</a:RequestedBy>
                <a:TransactionId>ABC20140402000201</a:TransactionId>
            </Contract>
        </FetchRequest>
    </s:Body>
</s:Envelope>

我想从xml中检索TransactionId。 我试过的查询是这样的:

SELECT TOP 100
MessageXml,
MessageXml.value('
    declare namespace s="http://www.w3.org/2003/05/soap-envelope";
    declare namespace a="http://www.w3.org/2005/08/addressing";
    (/s:Envelope/s:Body/FetchRequest/Contract/a:TransactionId)[1]', 'varchar(max)')
FROM dbo.Message

我为我的MessageXml.value返回NULL。 如果我删除了s之后的所有内容:Body我似乎得到了一串连接的文本,但只要添加了FetchRequest,我就会在我的结果中返回NULL。

我注意到Contract元素定义了a的名称空间,而Envelope也定义了a的名称空间,但我不确定这是否是个问题。

如何使用XPath查询获取上述xml示例的TransactionId?


I have a table in SQL server that contains an Xml column and I am having trouble querying it. I don't know enough about XPath to determine if my query is wrong, or if it is because of what seems like conflicting namespaces. Here is an example xml:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
            xmlns:a="http://www.w3.org/2005/08/addressing" 
            xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <!-- snip -->
    </s:Header>
    <s:Body>
        <FetchRequest xmlns="http://www.foobar.org/my/schema">
            <Contract xmlns:a="http://www.foobar.org/2014/04/datacontracts"
                      xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <a:RequestedBy>John Doe</a:RequestedBy>
                <a:TransactionId>ABC20140402000201</a:TransactionId>
            </Contract>
        </FetchRequest>
    </s:Body>
</s:Envelope>

I want to retrieve TransactionId from the xml. The query I tried was this:

SELECT TOP 100
MessageXml,
MessageXml.value('
    declare namespace s="http://www.w3.org/2003/05/soap-envelope";
    declare namespace a="http://www.w3.org/2005/08/addressing";
    (/s:Envelope/s:Body/FetchRequest/Contract/a:TransactionId)[1]', 'varchar(max)')
FROM dbo.Message

I am getting back NULL for my MessageXml.value. If I remove everything after s:Body I seem to get a bunch of text that is concatenated, but as soon as I add FetchRequest I get NULL back in my results.

I did notice that the Contract element defines a namespace of a, and the Envelope also defines a namespace of a, but I wasn't sure if that is a problem or not.

How can I retrieve TransactionId using an XPath query given the above xml example?


原文:https://stackoverflow.com/questions/22818591
更新时间:2023-06-07 12:06

最满意答案

它在使用不同的hbase版本后才工作。 我使用的是hbase-0.98.10.1-hadoop1-bin,它与我的hadoop 2.5.2不兼容,因此我将hbase版本更改为hbase-X.XX.XX.X-hadoop2-bin(这与hadoop 2兼容.X)并遵循Apache的安装步骤。 谢谢你们..


It Just Worked after using a different hbase version. I was using hbase-0.98.10.1-hadoop1-bin, which was not compatible with my hadoop 2.5.2, so I changed hbase version to hbase-X.XX.XX.X-hadoop2-bin (which was compatible for hadoop 2.X ) and followed Apache's installation steps. Thank you all..

相关问答

更多
  • riak 华师大的吧- - 下面来简单介绍各个组件的作用: HDFS(Hadoop distribute file system)——Hadoop生态系统的基础组件Hadoop分布式文件系统。它是其他一些工具的基础HDFS的机制是将大量数据分布到计算机集群上,数据一次写入,但可以多次读取用于分析。HDFS让Hadoop可以最大化利用磁盘。 HBase—— 一个构建在HDFS之上的面向列的NoSql数据库,HBase用于对打量数据进行快速读取/写入。HBase将Zookeeper用于自身的管理,以保证其所有组 ...
  • 1.需要zookeeper 2.没碰到过,不过应该问题还是出在配置文件hbase-site.xml上吧,仔细配下。 3.会报错,可以查看日志
  • 它在使用不同的hbase版本后才工作。 我使用的是hbase-0.98.10.1-hadoop1-bin,它与我的hadoop 2.5.2不兼容,因此我将hbase版本更改为hbase-X.XX.XX.X-hadoop2-bin(这与hadoop 2兼容.X)并遵循Apache的安装步骤。 谢谢你们.. It Just Worked after using a different hbase version. I was using hbase-0.98.10.1-hadoop1-bin, which wa ...
  • 你有权访问你的集群管理器ex。 Cloudera经理。 您可以检查zookeeper服务是否正常运行或弹出的错误消息。 您可以通过sudo service zookeeper状态进行检查 或者你也可以通过以下方式telnet zookeeper主机: root @ host:〜#telnet localhost 2181尝试127.0.0.1 ...连接到myhost。 转义字符是'^]'。 统计Zookeeper版本:3.4.3-cdh4.0.1--1,建立时间为06/28/2012 23:59 GMT ...
  • 它不受支持。 在https://happybase.readthedocs.io/en/latest/api.html#connection 主机和端口参数指定要连接的HBase Thrift服务器的主机名和TCP端口。 It's not supported. In https://happybase.readthedocs.io/en/latest/api.html#connection The host and port arguments specify the host name and TCP p ...
  • Java 8中不再支持配置hbase-env.sh指出: #Configure PermSize. Only needed in JDK7. You can safely remove it for JDK8+ hbase配置包括默认情况下在conf/hbase-env.sh文件中设置为128m的conf/hbase-env.sh 。 找出这两行。 export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS -XX:PermSize=128m -XX:MaxPermSize= ...
  • 在hbase-env.sh中查找属性HBASE_MANAGES_ZK并将其设置为false,如果您想对其进行外部管理 In hbase-env.sh look up for property HBASE_MANAGES_ZK and set it to false if you want to manage it externally
  • 对于独立模式,只需按照此HBase指南中提供的步骤操作: http : //hbase.apache.org/book.html#quickstart HBase具有独立模式,可以让初学者轻松上手。 在独立模式下,hbase,hdfs和zk在单个JVM进程中运行。 For standalone mode, just follow the steps provided in this HBase guide:http://hbase.apache.org/book.html#quickstart HBase ...
  • 您需要在hbase-site.xml中配置zookeeper znode。 zookeeper.znode.parent /hbase 不匹配可能是由于默认配置。 您可以使用zkcli验证ZooKeeper中的可用znode。 You need to configure zookeeper znode in hbase-site.xml. zookeep ...
  • 我试图通过客户端0.96连接到HBase 0.94。 根据https://blog.cloudera.com/blog/2013/10/what-are-hbase-znodes/ znode / hbase / root-region-server在0.96 / hbase / meta-region-server中替换, java客户端无法找到。 I had tryied to connect to HBase 0.94 by client 0.96. And acording to https://b ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。