author  Michael Kay <mike@saxonica.com> 
Mon, 18 Sep 2017 23:31:36 +0100  
changeset 1760  748a74a64be2 
parent 1722  9068cdd364c3 
permissions  rwrr 
1722
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

1 
<xsl:stylesheet version="2.0" 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

2 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

3 

9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

4 
<xsl:variable name="atomic" select="93"/> 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

5 

9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

6 
<! A match pattern in the form of a variable reference will only match nodes > 
1760
748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

7 

748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

8 
<! Analysis (MHK 20170915). The semantics of this pattern are that it will match an item N if: 
748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

9 

748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

10 
N is a node, and the result of evaluating the expression root(.)//($atomic) with a singleton focus 
748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

11 
based on N is a sequence that includes the node N. 
748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

12 

748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

13 
Now, if N is a node, the result of this expression will be a sequence consisting of multiple occurrences 
748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

14 
of the integer 93. This sequence does not include N, therefore the pattern does not match. There is no 
748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

15 
dynamic error, and no type error, so no rule in the specification is violated and the most the processor 
748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

16 
can do is to issue a warning. 
748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

17 
> 
748a74a64be2
match="$atomic" where the variable is bound to an atomic value
Michael Kay <mike@saxonica.com>
parents:
1722
diff
changeset

18 

1722
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

19 
<xsl:template match="$atomic"> 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

20 
<wrong/> 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

21 
</xsl:template> 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

22 

9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

23 
<xsl:mode onnomatch="deepskip"/> 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

24 

9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

25 
<xsl:template name="xsl:initialtemplate"> 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

26 
<out> 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

27 
<xsl:applytemplates select="93" /> 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

28 
</out> 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

29 
</xsl:template> 
9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

30 

9068cdd364c3
Test match="$var" where $var is atomic
Michael Kay <mike@saxonica.com>
parents:
diff
changeset

31 
</xsl:stylesheet> 