Reputation: 1873
As far as I know the XPath expression "/" should set the node context to the child axis of the root node. Here is the xml:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<test-case name="test-case-1">
<object-under-test category="template" name="text-align"/>
<parameters>
<input name="text">text</input>
<input name="min-lenght">8</input>
<input name="align">left</input>
<output name="result"/>
</parameters>
<criteria>
<criterion class="equal" to="'text '"/>
</criteria>
</test-case>
</xsl:stylesheet>
And this is the xsl:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<test>
<xsl:apply-templates/>
</test>
</xsl:template>
</xsl:stylesheet>
What is the default match pattern for <xsl:apply-templates>
?
Why I get as an output the values of all tags?
This is the output:
<?xml version="1.0" encoding="UTF-8"?>
<test>text 8 left</test>
Upvotes: 0
Views: 61
Reputation: 117018
As far as I know the XPath expression "/" should set the node context to the child axis of the root node.
No, it sets the context to the /
root node itself.
What is the default match pattern for
<xsl:apply-templates>
?
"In the absence of a select
attribute, the xsl:apply-templates
instruction processes all of the children of the current node."
http://www.w3.org/TR/xslt/#section-Applying-Template-Rules
Why I get as an output the values of all tags?
It's because of the built-in template rules that are applied when your stylesheet does not have a template that matches the nodes you have applied templates to. In a nutshell, the built-in templates copy all descendant text nodes to the output.
Upvotes: 4