Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml xQuery对具有名称空间的数据进行查询?_Xml_Namespaces_Xquery_Xml Namespaces - Fatal编程技术网

Xml xQuery对具有名称空间的数据进行查询?

Xml xQuery对具有名称空间的数据进行查询?,xml,namespaces,xquery,xml-namespaces,Xml,Namespaces,Xquery,Xml Namespaces,新手可以向你们这些有经验的人寻求帮助吗:如何从包含名称空间的XML文件中列出/测试值,例如subtitle或desc(“示例中的gsx:onoff”) 我的xQuery没有返回结果?无论像我这样的新手尝试什么,回报都是徒劳的 尝试了数百万种查询,如: declare namespace gs="http://www.w3.org/2005/Atom"; declare namespace gsx="http://www.w3.org/2005/Ato

新手可以向你们这些有经验的人寻求帮助吗:如何从包含名称空间的XML文件中列出/测试值,例如subtitle或desc(“示例中的gsx:onoff”)

我的xQuery没有返回结果?无论像我这样的新手尝试什么,回报都是徒劳的

尝试了数百万种查询,如:

    declare namespace gs="http://www.w3.org/2005/Atom";
    declare namespace gsx="http://www.w3.org/2005/Atom";
XML来源:


https://spreadsheets.google.com/feeds/list/12ZuLAwWcuNmWWiS5bP0oThWjs66emSrJpw2LFly8bPg/1/public/values
2020-12-15T17:13:14.537Z

https://spreadsheets.google.com/feeds/list/12ZuLAwWcuNmWWiS5bP0oThWjs66emSrJpw2LFly8bPg/1/public/values/cokwr
2020-12-15T17:13:14.537Z
世界其他地区:2
字幕:欢迎参加2020 CXL专家会议,标题:2020 CXL专家会议,页脚:12月18日星期五09:45–21:00(CET),12月19日星期六09:00–15:00(CET),赞助商:blank.png,所有赞助商:all-HALF.png,poruka:欢迎参加2020 CXL专家会议。第一天从09:40开始到21:00结束(CET),第二天从09:00开始到15:00结束(CET)。计划休息时间(CET)为第1天13:00–13:45和16:45–17:00,第2天10:20–10:30、11:50–12:20和13:30–13:50。在www. cxLeExtsMeTeTeg和在VisualFoundVis.Org的Foundation基金会上了解更多的会议。
对
欢迎来到
2020年CXL专家会议
12月18日星期五09:45–21:00(CET),12月19日星期六09:00–15:00(CET)
blank.png

让我们看看这是否是您想要的:

declare namespace gsx="http://schemas.google.com/spreadsheets/2006/extended";
declare namespace gs="http://www.w3.org/2005/Atom";
let $entries := //gs:entry
 
 for $entry in $entries
    let $onoff := $entry/gsx:onoff,
    $count := count($onoff)
return <datarow><icon> {data($entries//gs:entry/gsx:onoff)} </icon> <hasdata>{ if ($count > 1) then 1 else 0 }</hasdata><whatdata>{ if ($onoff = "yes") then 1 else data($entries/gsx:onoff) }</whatdata> </datarow>
声明名称空间gsx=”http://schemas.google.com/spreadsheets/2006/extended";
声明命名空间gs=”http://www.w3.org/2005/Atom";
let$entries:=//gs:entry
对于$entries中的$entries
设$onoff:=$entry/gsx:onoff,
$count:=计数($onoff)
返回{data($entries//gs:entry/gsx:onoff)}{if($count>1)则返回1个else 0}{if($onoff=“yes”)则返回1个else数据($entries/gsx:onoff)}
编辑:

针对您的评论(为了简化,我去掉了
节点):

let$entries:=//gs:entry[.//gsx:onoff[text()=“yes”]]
对于$entries中的$entries
让$onoff:=$entry/gsx:onoff[text()=“yes”]
返回1{$entry}

请不要将代码作为图像发布。将相关代码粘贴为文本。谢谢,但我不确定如何实现与图像相同的可读性(粘贴XML会弄乱数据,甚至使用“代码”标记)。不管怎样,您可以帮助解决这个问题吗?如果您不能包含整个源XML,那么至少添加带有名称空间声明的位。特别是默认名称空间。投票关闭,因为没有足够的信息来回答这个问题(我们需要查看XML)。好的,添加了关键部分,希望这有助于更好地理解这个问题Hanks Jack,这是一个巨大的进步!谢谢!在此链接上,您将看到查询结果。。。如何在数据行中仅选择并列出那些将“是”值设置为“是”的节点?看看编辑,看看这是否就是你想要的。谢谢你杰克在这方面的帮助!非常接近,只需要列出每个节点的所有子节点的内容。这就是现在的查询和结果:我不确定您使用的是什么,但当我在适当的xml数据库中使用它时(在我的例子中是BaseX,但您可以使用Zorba、ExistDB甚至MarkLogic),我得到了所需的输出—每个
节点满足标准的完整xml。
    for $x in //gs:entry
    let $onoff := $x/gsx:onoff
    return <datarow><icon> {data($x//gs:entry/gsx:onoff)} </icon> <hasdata>{ if ($count > 1) then 1 else 0 }</hasdata><whatdata>{ if ($onoff = "yes") then 1 else data($x/gsx:onoff) }</whatdata> </datarow>
    //gs:entry/gsx:onoff
<?xml version='1.0' encoding='UTF-8'?>
<feed
    xmlns='http://www.w3.org/2005/Atom'
    xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
    xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended'>
    <id>https://spreadsheets.google.com/feeds/list/12ZuLAwWcuNmWWiS5bP0oThWjs66emSrJpw2LFly8bPg/1/public/values</id>
    <updated>2020-12-15T17:13:14.537Z</updated>
<entry>
        <id>https://spreadsheets.google.com/feeds/list/12ZuLAwWcuNmWWiS5bP0oThWjs66emSrJpw2LFly8bPg/1/public/values/cokwr</id>
        <updated>2020-12-15T17:13:14.537Z</updated>
        <category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/>
        <title type='text'>Row: 2</title>
        <content type='text'>subtitle: Welcome to the, titles: 2020 CXL Experts’ Meeting, footer: Friday, December 18, 09:45–21:00 (CET), Saturday, December 19, 09:00–15:00 (CET), sponsor: blank.png, allsponsors: all-HALF.png, poruka: Welcome to the CXL Experts’ Meeting 2020.    Day 1 starts at 09:40 and ends at 21:00 (CET) and Day 2 starts at 09:00 and ends at 15:00 (CET).    Scheduled breaks (CET) are on Day 1: 13:00–13:45 and 16:45–17:00 and on Day 2, these are 10:20–10:30, 11:50–12:20 and 13:30–13:50.    Learn more about the meeting at www.cxlexpertsmeeting.com and the Light for Sight foundation at www.lightforsight.org.</content>
        <link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/12ZuLAwWcuNmWWiS5bP0oThWjs66emSrJpw2LFly8bPg/1/public/values/cokwr'/>
        <gsx:onoff>yes</gsx:onoff>
        <gsx:subtitle>Welcome to the</gsx:subtitle>
        <gsx:titles>2020 CXL Experts’ Meeting</gsx:titles>
        <gsx:desc></gsx:desc>
        <gsx:footer>Friday, December 18, 09:45–21:00 (CET), Saturday, December 19, 09:00–15:00 (CET)</gsx:footer>
        <gsx:sponsor>blank.png</gsx:sponsor>
</entry>
declare namespace gsx="http://schemas.google.com/spreadsheets/2006/extended";
declare namespace gs="http://www.w3.org/2005/Atom";
let $entries := //gs:entry
 
 for $entry in $entries
    let $onoff := $entry/gsx:onoff,
    $count := count($onoff)
return <datarow><icon> {data($entries//gs:entry/gsx:onoff)} </icon> <hasdata>{ if ($count > 1) then 1 else 0 }</hasdata><whatdata>{ if ($onoff = "yes") then 1 else data($entries/gsx:onoff) }</whatdata> </datarow>
let $entries := //gs:entry[.//gsx:onoff[text()="yes"]] 
 for $entry in $entries
    let $onoff := $entry/gsx:onoff[text()="yes"]    
return <datarow><hasdata>1</hasdata><whatdata>{$entry}</whatdata> </datarow>