[英]Xquery How to check the value of a element with an attribute
I am really getting mad because I just don't know how to solve this X-Path/ X-Query problem我真的很生气,因为我只是不知道如何解决这个 X-Path/X-Query 问题
I have a Lido-File.我有一个丽都档案。 Let assume this:让我们假设:
<lido:actorInRole>
<lido:actor lido:type="Person">
<lido:actorID lido:type="d-nb.info" lido:source="http://d-nb.info/gnd/116001313">116001313</lido:actorID>
<lido:actorID lido:type="uuid">2ca86edd-6113-4133-a86e-dd61135133ae</lido:actorID>
<lido:nameActorSet>
<lido:appellationValue lido:pref="preferred">Abel, Alfred</lido:appellationValue>
</lido:nameActorSet>
<lido:vitalDatesActor>
<lido:earliestDate>1879</lido:earliestDate>
<lido:latestDate>1937</lido:latestDate>
</lido:vitalDatesActor>
<lido:genderActor>männlich</lido:genderActor>
</lido:actor>
<lido:actor lido:type="Person">
<lido:actorID lido:type="d-nb.info" lido:source="http://d-nb.info/gnd/118501402">118501402</lido:actorID>
<lido:actorID lido:type="uuid">2e00b761-d766-47c5-80b7-61d76607c58d</lido:actorID>
<lido:nameActorSet>
<lido:appellationValue lido:pref="preferred">Albers, Hans</lido:appellationValue>
</lido:nameActorSet>
<lido:vitalDatesActor>
<lido:earliestDate>1891</lido:earliestDate>
<lido:latestDate>1960</lido:latestDate>
</lido:vitalDatesActor>
<lido:genderActor>männlich</lido:genderActor>
</lido:actor>
</lido:actorInRole>
I am using a index.qxl where I am asking for the value of //lido:actorID[@lido:type="uuid"]
我正在使用 index.qxl 我要求//lido:actorID[@lido:type="uuid"]
的值
So i want to iterate through the these elements and check if the number of the number of //lido:actorID[@lido:type="uuid"]
is 2ca86edd-6113-4133-a86e-dd61135133ae
or something else.所以我想遍历这些元素并检查//lido:actorID[@lido:type="uuid"]
的数量是否为2ca86edd-6113-4133-a86e-dd61135133ae
或其他。
like "is the content of the object lido:actor withe the attribut lido:type containing the value 'uuid' 2ca86edd-6113-4133-a86e-dd61135133ae or not?. if yes, then give me the ancestor of this object. if not, do nothing"像“object lido:actor 的内容是否包含属性lido:type 包含值'uuid' 2ca86edd-6113-4133-a86e-dd61135133ae? , 没做什么”
How can I achieve this?!我怎样才能做到这一点?!
Again.再次。 I DONT WANT THE VALUE OF lido:type..!!我不想要lido的价值:type..!! I want the content of the whole element.我想要整个元素的内容。 The ID Number!!身份证号码!! And let this checked via an if-else which is nested in a for loop.并通过嵌套在 for 循环中的 if-else 进行检查。
Please I really need help!!!请问我真的需要帮助!!!
Assuming that you want to select the node假设你要 select 节点
<lido:actor lido:type="Person">...
you can use the following XPath-1.0 expression您可以使用以下 XPath-1.0 表达式
//lido:actor[lido:actorID[@lido:type='uuid']='2ca86edd-6113-4133-a86e-dd61135133ae']
It should give you the lido:actor
node which has a child <actorID>
with a lido:type
attribute with the desired value .它应该为您提供具有子<actorID>
的lido lido:actor
节点,该子节点具有具有所需值的lido lido:type
属性。
You can use this XPath-1.0 expression in an <xsl:if test='...'>
or a template's match rule.您可以在<xsl:if test='...'>
或模板的匹配规则中使用此 XPath-1.0 表达式。 In both cases the content of the matched node can be retrieved with <xsl:copy-of select="." />
在这两种情况下,都可以使用<xsl:copy-of select="." />
检索匹配节点的内容。 <xsl:copy-of select="." />
. <xsl:copy-of select="." />
.
thanks so far with the answer!到目前为止,感谢您的回答!
It's still not working.它仍然无法正常工作。
I have a new file calles "personeninfo.xql"我有一个名为“personeninfo.xql”的新文件
here the code:这里的代码:
xquery version "3.1";
declare namespace lido = "http://www.lido-schema.org";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "html5";
declare option output:media-type "text/html";
let $data := collection("/db/apps/eli/data")
let $id := request:get-parameter("e",())
let $actorID: = $data//lido:actor[@lido:type="Person"]//lido:actorID[@lido:type="uuid"]/text()
return
<html>
<head>
<title>Übersicht Weber-Korpus</title>
<link rel="stylesheet" href="resources/bootstrap.min.css"/>
</head>
<body>
<div class="container" id="main-container">
<div>
<h1>Steckbrief </h1>
</div>
{ for $a in $actorID
where //lido:actor[lido:actorID[@lido:type='uuid']/text()=$id]
return <li>{$a/ancestor::lido:actorInRole//lido:appellationValue[@lido:pref="preferred"]}</li>
}
</div>
</body>
</html>
I don't kno why it is not working.我不知道为什么它不起作用。 The e-parameter is correctly been given with from the index.xql from which I link to the personeninfo.xql从我链接到 personeninfo.xql 的 index.xql 中正确给出了 e 参数
Here the URL:这里是 URL:
http://localhost:8080/exist/apps/eli/personeninfo.xql?e=2ca86edd-6113-4133-a86e-dd61135133ae
You can see, that the ID is in e.可以看到,ID 在 e 中。
But why is not working?: I really need help :( It's driving me mad!但是为什么不工作?:我真的需要帮助:(这让我发疯!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.