Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implementation of XPath function fn:tokenize (for formula linkbase to use) #1277

Merged
merged 5 commits into from
Jul 12, 2024

Conversation

strr
Copy link
Contributor

@strr strr commented Jul 11, 2024

Reason for change

Arelle is missing support for some XPath 2.0 standard functions and there is a good chance that an upcoming taxonomy might use fn:tokenize() so add an implementation of it.

Description of change

Implement fn:tokenize() and add a few tests for it.

Steps to Test

A simple formula linkbase making use of tokenize (zipped purely to get past Github upload filter,)
test-tokenize-formula.zip

python arelleCmdLine.py -v -f test-tokenize-formula.xml

Without this pull request it fails:

[info] loaded in 0.03 secs at 2024-07-11T11:48:35 - C:\b\test-tokenize-formula.xml
[] Formula xpath2 grammar initialized in 0.63 secs -
[err:XPST0017] Variable set AssertionTokenizeAndJoin
Exception: Function named fn:tokenize does not have a custom or built-in implementation. - test-tokenize-formula.xml 14
[err:XPST0017] Variable set AssertionCountTokensZeroMatch
Exception: Function named fn:tokenize does not have a custom or built-in implementation. - test-tokenize-formula.xml 11
[err:XPST0017] Variable set AssertionCountTokens
Exception: Function named fn:tokenize does not have a custom or built-in implementation. - test-tokenize-formula.xml 8
[info] validated in 0.66 secs - C:\b\test-tokenize-formula.xml

With this pull request it succeeds:

[info] loaded in 0.03 secs at 2024-07-11T11:53:45 - C:\b\test-tokenize-formula.xml
[] Formula xpath2 grammar initialized in 1.01 secs -
[message:AssertionTokenizeAndJoin] Turn '  a b  c   ' into 'abc' 'abc'  - test-tokenize-formula.xml 14
[message:AssertionCountTokens] Length of count(fn:tokenize('a-b-c-d-e-f-g', '-')) should be 7 and actually is '7'  - test-tokenize-formula.xml 8
[message:AssertionCountTokensZeroMatch] Length of count(fn:tokenize('a-b-c-d-e-f-g-', '-')) should be 8 and actually is '8'  - test-tokenize-formula.xml 11
[info] validated in 1.05 secs - C:\b\test-tokenize-formula.xml

Alternately, the unit tests can be run:

pytest .\tests\unit_tests\arelle\test_functionfn.py

review:
@Arelle/arelle

@strr strr temporarily deployed to integration-tests July 11, 2024 10:55 — with GitHub Actions Inactive
@strr strr temporarily deployed to integration-tests July 11, 2024 10:55 — with GitHub Actions Inactive
@strr strr temporarily deployed to integration-tests July 11, 2024 10:55 — with GitHub Actions Inactive
@strr strr temporarily deployed to integration-tests July 12, 2024 10:44 — with GitHub Actions Inactive
@strr strr temporarily deployed to integration-tests July 12, 2024 10:44 — with GitHub Actions Inactive
@strr strr temporarily deployed to integration-tests July 12, 2024 10:44 — with GitHub Actions Inactive
@austinmatherne-wk austinmatherne-wk merged commit 5592592 into Arelle:master Jul 12, 2024
90 checks passed
@strr strr deleted the strr/tokenize branch July 12, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Resolved
Development

Successfully merging this pull request may close these issues.

5 participants