Add R:is-record predicate

* src/record.xsl (R:is-record): added
* test/record.xspec: add tests for R:is-record
master
Mike Gerwitz 2016-03-27 23:12:48 -04:00
parent 7196a2f0c6
commit a921741f09
No known key found for this signature in database
GPG Key ID: F22BB8158EE30EAB
2 changed files with 47 additions and 0 deletions

View File

@ -517,6 +517,18 @@
@subsection Type Predicates
-->
<!--
Determine whether the given @var{item} is a record.
-->
<function name="R:is-record" as="xs:boolean">
<param name="item" as="item()" />
<sequence select="$item instance of element()
and exists( $item/_R:types )" />
</function>
<!--
Predicate to determine whether @var{record} or any of its supertypes is of
type @var{type}.

View File

@ -281,6 +281,41 @@
</scenario>
<scenario label="R:is-record">
<scenario label="given a record">
<call function="R:is-record">
<param name="Record"
select="R:make-record-header( 0 )" />
</call>
<expect label="returns true()"
test="$x:result = true()" />
</scenario>
<scenario label="given a non-record element">
<call function="R:is-record">
<param name="Record"
select="n:element( QName( '', 'foo' ) )" />
</call>
<expect label="returns false()"
test="$x:result = false()" />
</scenario>
<scenario label="given a non-record atomic">
<call function="R:is-record">
<param name="Record"
select="5" />
</call>
<expect label="returns false()"
test="$x:result = false()" />
</scenario>
</scenario>
<scenario label="R:is-compatible">
<scenario label="with super- and sub-types of same slot count">
<call function="R:is-compatible">