node.xsl (n:attr#1): added

master
Mike Gerwitz 2016-03-25 21:59:22 -04:00
parent 057cdbb683
commit 2967463cdb
No known key found for this signature in database
GPG Key ID: F22BB8158EE30EAB
2 changed files with 38 additions and 11 deletions

View File

@ -156,6 +156,16 @@
</function>
<!--
Construct an attribute named @var{qname} with an empty value.
-->
<function name="n:attr" as="attribute()">
<param name="qname" as="xs:QName" />
<sequence select="n:attr( $qname, '' )" />
</function>
<!--
Create a text node with the given @var{text}. The @var{text} will be
output verbatim without any whitespace processing.

View File

@ -172,19 +172,36 @@
<scenario label="A new attribute">
<!-- to test this, the attribute needs an element parent -->
<call function="n:element">
<param name="qname" select="$test-qname-a" />
<param name="attrs"
select="n:attr( $test-qname-b, 'foo' )" />
<param name="child-nodes" select="()" />
</call>
<scenario label="with a value">
<!-- to test this, the attribute needs an element parent -->
<call function="n:element">
<param name="qname" select="$test-qname-a" />
<param name="attrs"
select="n:attr( $test-qname-b, 'foo' )" />
</call>
<expect label="has given QName"
test="node-name( $x:result/@* ) = $test-qname-b" />
<expect label="has given QName"
test="node-name( $x:result/@* ) = $test-qname-b" />
<expect label="has given value"
test="$x:result/@* = 'foo'" />
<expect label="has given value"
test="$x:result/@* = 'foo'" />
</scenario>
<scenario label="with no value">
<!-- to test this, the attribute needs an element parent -->
<call function="n:element">
<param name="qname" select="$test-qname-a" />
<param name="attrs"
select="n:attr( $test-qname-c )" />
</call>
<expect label="has given QName"
test="node-name( $x:result/@* ) = $test-qname-c" />
<expect label="has empty value"
test="$x:result/@* = ''" />
</scenario>
</scenario>