Subject: Re: [xsl] When to use text()|
From: David Carlisle <davidc@xxxxxxxxx>
Date: Sat, 22 Mar 2014 08:41:54 +0000
The quirkiness of the definition derives not from the definitionitself, because there may well be justification for the existence of a node type that encompasses text with embedded comments. Thats OK.
text nodes are leaves: they never have embedded comments. Your complaint appears to be just a complete misunderstanding of what text() returns (which is never anything with a comment in it). It's OK to misunderstand the language but rather odd to assert that your misunderstanding is due to a failure in the language definition.
Perhaps you'd want it to do what string() does but that's called string() not text():-)
You see there right where the smiley is, is where we differ. I don't see that as anything to smile about. To me thats just thats a smart alec distinction.
The distinction is fundamental to the use of XPath. text() returns a sequence of text nodes, you can ask for their identity, their parent and sibling nodes etc. string() (which appears to be the function you wanted) returns a _string_ which is an atomic value dissociated from any document tree. The distinction between atomic values and nodes pervades all uses of XSLT and XPath.