带有多个名称空间的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
最满意答案
它在使用不同的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..
相关问答
更多-
哪个不是Hadoop 的核心组件 hbase hive zookeeper riak[2022-04-10]
riak 华师大的吧- - 下面来简单介绍各个组件的作用: HDFS(Hadoop distribute file system)——Hadoop生态系统的基础组件Hadoop分布式文件系统。它是其他一些工具的基础HDFS的机制是将大量数据分布到计算机集群上,数据一次写入,但可以多次读取用于分析。HDFS让Hadoop可以最大化利用磁盘。 HBase—— 一个构建在HDFS之上的面向列的NoSql数据库,HBase用于对打量数据进行快速读取/写入。HBase将Zookeeper用于自身的管理,以保证其所有组 ... -
hadoop+hbase+zookeeper的问题。不好意思,没分了。[2024-01-26]
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 ...
-
在HappyBase HBase客户端中设置Zookeeper节点(znode)设置(Set Zookeeper Node (znode) setting in HappyBase HBase client)[2023-11-16]
它不受支持。 在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和Zookeeper(Hbase and Zookeeper)[2023-07-19]
您需要在hbase-site.xml中配置zookeeper znode。zookeeper.znode.parent /hbase zookeep ... -
HBase:/ hbase / meta-region-server节点不存在(HBase: /hbase/meta-region-server node does not exist)[2022-08-06]
我试图通过客户端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 ...