XPath 通过多个 ID 输出整个 XML

XPath make output of whole XML by multiple ID's

 <bookstore>
   <book>
      <title lang="en" id="1">Harry Potter</title>
      <price>29.99</price>
    </book>
    
    <book>
      <title lang="en" id="2">Learning XML</title>
      <price>39.95</price>
    </book>
 </bookstore>
<photostore>
 <photo>
      <title lang="en" id="3">Learning XPATH</title>
      <price>1.00</price>
    </photo>
</photostore>

我试图实现的是 XPath 显示 id=1 和 id=3

的所有内容(包括 parents 和锚点)

输出应该是:

     <bookstore>
    <book>
      <title lang="en" id="1">Harry Potter</title>
      <price>29.99</price>
    </book>
 </bookstore>
<photostore>
 <photo>
      <title lang="en" id="3">Learning XPATH</title>
      <price>1.00</price>
    </photo>
</photostore>

我正在使用 BaseX 9.5.1 Beta

XQuery

declare context item := document {
<bookstore>
    <book>
        <title lang="en" id="1">Harry Potter</title>
        <price>29.99</price>
    </book>
    <book>
        <title lang="en" id="2">Learning XML</title>
        <price>39.95</price>
    </book>
    <photostore>
        <photo>
            <title lang="en" id="3">Learning XPATH</title>
            <price>1.00</price>
        </photo>
    </photostore>
</bookstore>  
};

<bookstore>
{
  for $x in ./bookstore/*[descendant::*/@id=("1","3")]
  return $x
}
</bookstore>

输出

<bookstore>
  <book>
    <title lang="en" id="1">Harry Potter</title>
    <price>29.99</price>
  </book>
  <photostore>
    <photo>
      <title lang="en" id="3">Learning XPATH</title>
      <price>1.00</price>
    </photo>
  </photostore>
</bookstore>