Xquery:如何从REF / ID中提取信息

时间:2016-11-09 13:44:23

标签: xml xquery xml-editor

在我的xml中,我有许多ID和REF属性。

简化:

<library>
 <book ID="123">
   <author ref="33"></author>
   <Info>Vulpes Vulpes, Canis Lupus</info>
   <about>Programming</about>
 </book>

 <author ID="33">
  <firstname>John</firstname>
  <lastname>McLovin</lastname>
 </author>
</library>

所以我想使用Xquery使用book下的REF属性来提取有关作者的信息。

for $x in library/book 
where $x/about = "programming"
return data ($x/library/book/author/@ref)

使用这种方法,我提取重新编号33.但我想要ref =“33”指向的数据,它位于ID =“33”下。我希望将firstname和lastname作为结果。

这可能吗?如果不是这样,怎么可能?

1 个答案:

答案 0 :(得分:0)

Fatal error: Uncaught exception 'Google_Service_Exception' with message '{ "error": { "errors": [ { "domain": "global", "reason": "authError", "message": "Invalid Credentials", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Invalid Credentials" } } ' in /home/foo/public_html/vendor/google/apiclient/src/Google/Http/REST.php:118 Stack trace: #0 /home/foo/public_html/vendor/google/apiclient/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 [internal function]: Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2 /home/foo/public_html/vendor/google/apiclient/src/Google/Task/Runner.php(181): call_user_func_array(Array, Array) #3 /home/foo/public_html/vendor/google/apiclient/src/Google/Http/REST.php(58): Google_Task_Runner->run() #4 /home/foo/public_html/vendor/google/apiclient/src/Goo in /home/foxo/public_html/vendor/google/apiclient/src/Google/Http/REST.php on line 118