I just wrote an XSLT that did not work at first.
I had to rename all children of to :
child::node() matches any node that's not an attribute node, namespace node, or document node. That means that it does match processing instructions, comments, and text nodes.
child::* matches only elements.
See section 5.5.3 of the spec:
The pattern node() matches all nodes selected by the expression root(.)//(child-or-top::node()), that is, all element, text, comment, and processing instruction nodes, whether or not they have a parent. It does not match attribute or namespace nodes because the expression does not select nodes using the attribute or namespace axes. It does not match document nodes because for backwards compatibility reasons the child-or-top axis does not match a document node.
Update: Michael's answer inspired the following stylesheet. Use it to test the types of nodes as they're processed:
[
]
Root
Element
Text
Comment
PI
Attribute
Modify what's matched/selected to test other patterns. For example, the following input:
some value
Produces the following output:
Root [
some value
Element A [
some value
Text [
] Element B [
] Text [
] Element C [ some value
Text [ some value
] ] Text [
] Comment [ a comment
] Text [
] Element D [
] Text [
] ] ]
Special thanks to this page for getting me started on the node-type tests. (It's especially fitting that one of Michael's answers from over six years ago appears there, too.)