[xsl] Getting the value of an attribute

Subject: [xsl] Getting the value of an attribute
From: "Bradley, Peter" <pbradley@xxxxxxxxxx>
Date: Mon, 29 Sep 2008 16:41:17 +0100
I suspect this may be a very silly question.  If so, my apologies.

If I have this source document (fragment):

?xml version="1.0" encoding="UTF-8"?>
<error>
    <body>
        <timestamp>11/26/2007 5:43:41 PM</timestamp>
        <message>HandlingInstanceID:
3385d1e7-6173-44b8-93a6-ba82bdf462ad
            <Exception>
...
                <additionalInfo>
                    <info name="MachineName" value="Test"/>
                    <info name="TimeStamp" value="11/26/20007 5:43:41
PM"/>
                    <info name="FullName"
value="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
                    <info name="AppDomainName"
value="/LM/W3SVC/165639889/Root-1-128115363895000000"/>
                    <info name="ThreadIdentity" value=""/>
                    <info name="WindowsIdentity" value="NT
AUTHORITY\NETWORK SERVICE"/>
                </additionalInfo>
            </Exception>
        </message>
...
    </body>
</error>

Why does this stylesheet (fragment):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
...
    <xsl:template match="body/message">
        <Msg>
            <Error>
                <xsl:attribute name="appDomainName">
                    <xsl:value-of
select="Exception/additionalInfo/info[@name='AppDomainName']/@name"/>
                </xsl:attribute>
...
            </Error>
        </Msg>
    </xsl:template>
</xsl:stylesheet>

not give me the value of the AppDomainName attribute in the
appDomainName attribute of <Error> below:

<Msg>
    <Error appDomainName="AppDomainName "/>
</Msg>
...

I have the feeling that this should be obvious to me, but it has been a
busy day, so if anyone would be kind enough to put me out of my misery,
I would be eternally grateful.

Thanks


Peter

Current Thread