xspec: Testing a function/template that returns an attribute with x:expect/@test
Hi,
Testing a function or a named template that returns an attribute seems to generate incorrect XSL code. See the attached example: test.zip.
<x:expect label="Should work but doesn't" test=". = 'value'"/>
Using @test
with an XPath expression that returns a boolean value (where .
here is an attribute node) causes the generated XSL to fail with the following error:
XTDE0420: Cannot create an attribute node (class) whose parent is a document node.
I managed to make the test work by using <x:variable>
to create the expected result, and comparing it to the template result with @select
:
<x:variable name="tmp.result">
<_null class="value"/>
</x:variable>
<x:expect label="Works OK" select="$tmp.result/@class"/>
Is there another way to test such a template or is this a bug?
Is the use of <x:variable>
safe and/or recommended, since it is not in the RNG schema?
Thanks. Axel
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (12 by maintainers)
Commits related to this issue
- Fix #59 (x:expect/@test terminates when function or template returns attribute) (#317) — committed to xspec/xspec by AirQuick 5 years ago
- Test for #59 use case 2 on XQuery (#430) — committed to xspec/xspec by AirQuick 5 years ago
- XQuery: Fix #355 #357 #358 #360 (broken report) and run test for #59 (attribute test) (#498) — committed to xspec/xspec by AirQuick 5 years ago
Though there is a workaround, I think this is a bug. I have a possible fix. Will submit it in a few days. If the fix is not feasible, then the behavior should be documented, I think. So let me update the label and the milestone.
Another workaround (without worrying about
x:variable
) would be