Closed frank-steimke closed 8 months ago
The XPath data model doesn't require a document node to have a single element child. You can have none, a text document, or one, or several. You an serialize it too. It's even possible to get an XML parser to re-injest it if you arrange for it to be an external parsed entity in another document.
I often think it's better and easier to define a top-level element, but in this case, it didn't seem necessary and it just introduces new error conditions. For example, what if the top-level element isn't named tmp:templates
?
The v:templates
mechanism seems sufficiently narrow and specialized that it was okay to do it this way.
Thanks for the explanation. This is one for "Today i have learned...".
In section 6.1.1. in the XQuery and XPath Data Model 3.1 i see the difference between the Infoset document information item and the XPath Document Node.
Greeting, Frank
I think it would be nice to explain this fact. Maybe more users expect a single root element for a valid document node. I have made PR #481 .
This is not an issue, but a Question.
The
$v:templates
is defined as document-node().The Description says "Any templates provided in $v:templates will be used preferentially to whatever builtin templates exist.". That means i can have a sequence of templates as content. I have created two custom templates and use them successfully. The structure is like this:
But i wonder: is this really a valid document-node()? It does not have a single root Element, but consists of two document fragments. It does work, but i dont understand why ... i would expect the XSLT processor to complain.
The modules/templates.xml file from the xslTNG Distribution uses
tmp:templates
as root Element for templates. Is this also possible for custom templates in a separate file?After all, wouldn't it be better to define
$v:templates as element()*
or$v:templates as element(tmp:templates)
?Kind regards, Frank