Joris Gillis said:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://a/">
<xsl:template match="@a:value">
found
</xsl:template>
</xsl:stylesheet>
I tried that, and it didn't work. What's wrong with my XSLT.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://a/">
<xsl:template match="@a:value">
found
</xsl:template>
</xsl:stylesheet>
node, and that stylesheet doesn't apply templates to attribute nodes, so
no template natching an attribute will be executed.
the default templates for / and elements apply templates to child nodes
(only) not to attribute or namespace nodes. This is why an empty
stylesheet produces all element content (but not attribute content)
add
<xsl:template match="*">
<xsl:apply-templates select="node()|@*"/>
</xsl:template>
David
Ok then won't the following match as a template?
a:child/@a:value
The pattern '@a:value' isn't matched, so the same pattern with an extra
restriction (only 'value' attributes with a 'child' parent) will certainly
not match more.
But you can do this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s="s" xmlns:w="vv" xmlns:abc="abc"
version="1.0" xmlns:a="http://a/">
<xslutput method="xml" indent="yes"/>
<xsl:template match="a:root">
<xsl:apply-templates select="a:child/@a:value"/>
</xsl:template>
<xsl:template match="a:child/@a:value ">
match
</xsl:template>
</xsl:stylesheet>
I'm starting to understand now. XSLT is like a push-model where the
XSL/XSLT processor *must* be told to look for a specific pattern, not
that it's recursively going through the tree structure looking for a
matching
pattern.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.