Skip to content

Adds convenient methods for xpathEval()#20

Merged
redvers merged 2 commits into
mainfrom
convenience_xpath_methods_and_tests
Jan 12, 2026
Merged

Adds convenient methods for xpathEval()#20
redvers merged 2 commits into
mainfrom
convenience_xpath_methods_and_tests

Conversation

@redvers
Copy link
Copy Markdown
Collaborator

@redvers redvers commented Jan 12, 2026

Adds:

  • xpathEvalNodes(xpath: String val, namespaces: Array[(String val, String val)] = []): Array[Xml2Node] ?
  • xpathEvalString(xpath: String val, namespaces: Array[(String val, String val)] = []): String val ?
  • xpathEvalF64(xpath: String val, namespaces: Array[(String val, String val)] = []): F64 ?
  • xpathEvalBool(xpath: String val, namespaces: Array[(String val, String val)] = []): Bool ?

These functions are clearer in use at the call-site:

Compare:

  match doc.xpathEval("//child")
  | let nodes: Array[Xml2Node] => // etc…
  else
    h.fail("Expected nodeset result for //child")
  end

or

  let nodes: Array[Xml2Node] = (doc.xpathEval("//child") as Array[Xml2Node])

To:

  let nodes: Array[Xml2Node] = doc.xpathEvalNodes("//child")?

Adds:
- xpathEvalNodes(xpath: String val, namespaces: Array[(String val, String val)] = []): Array[Xml2Node] ?
- xpathEvalString(xpath: String val, namespaces: Array[(String val, String val)] = []): String val ?
- xpathEvalF64(xpath: String val, namespaces: Array[(String val, String val)] = []): F64 ?
- xpathEvalBool(xpath: String val, namespaces: Array[(String val, String val)] = []): Bool ?

These functions are clearer in use at the call-site:

Compare:

```pony
  match doc.xpathEval("//child")
  | let nodes: Array[Xml2Node] => // etc…
  else
    h.fail("Expected nodeset result for //child")
  end
```
or
```pony
  let nodes: Array[Xml2Node] = (doc.xpathEval("//child") as Array[Xml2Node])
```

To:

```pony
  let nodes: Array[Xml2Node] = doc.xpathEvalNodes("//child")?
```
@redvers
Copy link
Copy Markdown
Collaborator Author

redvers commented Jan 12, 2026

Hi @redvers,

The changelog - added label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do.

Release notes are added by creating a uniquely named file in the .release-notes directory. We suggest you call the file 20.md to match the number of this pull request.

The basic format of the release notes (using markdown) should be:

## Title

End user description of changes, why it's important,
problems it solves etc.

If a breaking change, make sure to include 1 or more
examples what code would look like prior to this change
and how to update it to work after this change.

Thanks.

@redvers redvers merged commit 5949394 into main Jan 12, 2026
6 checks passed
github-actions Bot pushed a commit that referenced this pull request Jan 12, 2026
github-actions Bot pushed a commit that referenced this pull request Jan 12, 2026
@redvers redvers deleted the convenience_xpath_methods_and_tests branch January 13, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant