I’m sure that this is an extremely basic question but here goes anyway! I have read that the built in template rule for text and attribute nodes in XSLT is
<xsl:template match="text()|@*">
<xsl:value-of select="."/>
</xsl:template>
However for the source document
<?xml version="1.0"?>
<booker>
<award>
<author blah="test">Aravind Adiga</author>
<title>The White Tiger</title>
<year>2008</year>
</award>
</booker>
And XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
</xsl:stylesheet>
I get the following output applying the transform in Visual Studio. Can someone please explain why I don’t see "test" in the output?
Aravind Adiga
The White Tiger
2008
Because the built-in rule for elements does not apply templates to an element’s own attributes, only to it’s child elements. If you want to traverse the attributes in the same way you traverse the child elements (which is probably an artificial task) you need to define your own default: