Include the namespace, or put in a wildcard; eg

let $debate-nr := $debate-id//*:match/*:group[@nr="1"]/text()
     let $item-nr := $debate-id//*:match/*:group[@nr="2"]/text()

I'm mobile at the moment, but think that's right (: untested and off the
cuff, in other words :).

Best,
Bridger


On Thu, Feb 10, 2022, 12:30 PM Ben Engbers <ben.engb...@be-logical.nl>
wrote:

> Hi,
>
> This query produces the following result:
>
> let $debates := collection("Parliament")
> for $debate-item in $debates
>    let $item-file := $debate-item/officiele-publicatie//meta/@content
>    let $debate-id := fn:analyze-string(
>      $debate-item/officiele-publicatie//meta/@content,
> "(\d{8}-\d*)-(\d*)")
>    return ($debate-id)
>
> =>
>
> <analyze-string-result xmlns="http://www.w3.org/2005/xpath-functions";>
>    <non-match>https://zoek.officielebekendmakingen.nl/h-tk-</non-match>
>    <match>
>      <group nr="1">20202021-102</group>-<group nr="2">1</group>
>    </match>
>    <non-match>/metadata.xml</non-match>
> </analyze-string-result>
> ...
>
> I am trying to extract the values from group 1 and 2 but this query
> returns 0 results:
>
> let $debates := collection("Parliament")
> for $debate-item in $debates
>    let $item-file := $debate-item/officiele-publicatie//meta/@content
>    let $debate-id := fn:analyze-string(
>      $debate-item/officiele-publicatie//meta/@content, "(\d{8}-\d*)-(\d*)")
>
>      let $debate-nr := $debate-id//match/group[@nr="1"]/text()
>      let $item-nr := $debate-id//match/group[@nr="2"]/text()
>
>    return ($debate-nr, $item-nr)
>
> My guess is that analyze-string inserts new elements in the query and
> that that is the reason why this does not work.
>
> How can I extract debate-nr and item-nr from $debate-id?
>
> Ben Engbers
>

Reply via email to