user2145365
user2145365

Reputation: 5

XSLT why is this not selecting what I want but selecting the entire xml?

I am trying to make a simple selection just for a test, but it doesn't seem to work. Here is the sml: http://pastebin.com/cwEcVEiL

And here is my xslt style:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:tei="http://www.tei-c.org/ns/1.0"
    exclude-result-prefixes="xs"
    version="2.0">
    <xsl:template match="/tei:TEI/tei:text/tei:body">
       TEST
    </xsl:template>
</xsl:stylesheet>

With this style it just selects the entire xml document but if I type match="/", then I outputs TEST once, as expected.

What is the problem?

Upvotes: 0

Views: 39

Answers (1)

StuartLC
StuartLC

Reputation: 107277

For elements which aren't matched by any template at all, XSLT will apply built in default templates.

Unless you want this default behaviour, you should override these, e.g. :

<xsl:template match="/">
   <xsl:apply-templates select="/tei:TEI/tei:text/tei:body" />
</xsl:template>

<xsl:template match="tei:body">
   TEST
</xsl:template>

Upvotes: 2

Related Questions