I want to write an XSL template that matches attributes instead of nodes,
I would think that having something like this:
<xsl:template match="@href | @conref | @conrefend">
<xsl:message select="."/>
</xsl:template>
would match any of those 3 attribute names and print to console the value of the attribute as the scope is the attribute itself and not a node.
But my testing has proven me wrong and I'm only able to match nodes that contain any of those attributes like this:
<xsl:template match="*[@href or @conref or @conrefend]">
<xsl:message select="if(not(@href))
then
if(not(@conref))
then @conrefend
else @conref
else @href"/>
</xsl:template>
The problem with that approach is that if there happens to exist a node that has more than one of those attributes then only one gets processed and I need to process them all.
Any ideas of why the first approach doesn't work?
EDIT1: Full xslt:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@conref|@conrefend|@href">
<xsl:message select="."/>
</xsl:template>
</xsl:stylesheet>
Test XML:
<links>
<image conref="COPY-GUID/*+-862416}39-37CD-4CF7-A7AA-F09F4A763944" />
</links>
Right now the XSLT is not matching anything.