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