[xsl] error after attribute

Subject: [xsl] error after attribute
From: "Dave Gomboc" <dave@xxxxxxxxxxxxxx>
Date: Thu, 14 Jun 2001 09:06:07 -0600
I have the template

<xsl:template match="AUTHOR_ROLE">
    <xsl:variable name="author_entry" select="key('authors', @A_ID[1]"/>
    <xsl:element name="AUTHOR_DATA">
        <xsl:apply-templates select="@ROLE"/>
        <xsl:apply-templates select="@AR_ID"/>
        <xsl:apply-templates select="$author_entry/@STANDARD_NAME"/>
        <xsl:apply-templates select="@PUBLISHED_AS_NAME"/>
        <xsl:apply-templates select="@LINK_TYPE"/>

This executes and produces the desired results, except:

Sometimes, the original data does not have "@ROLE" specified.  But I do
want it to go to a default value in this case, instead of it simply
being omitted.  So I changed it to

<xsl:template match="AUTHOR_ROLE">
    <xsl:variable name="author_entry" ... />
    <xsl:variable name="role">
            <xsl:when test="@ROLE">
                <xsl:value-of select="@ROLE"/>
                <xsl:value-of select="AUTHOR"/>
    <xsl:element name="AUTHOR_DATA">
        <xsl:attribute name="ROLE" value="$role"/>
        <xsl:apply-templates select="@AR_ID"/>

With Saxon 6.3, I'm getting the error

Error at xsl:attribute on line [the line with <xsl:attribute ... />] of
file [this file]:
  Attribute value is not allowed on this element
Transformation failed

If I use a literal result element (<AUTHOR_DATA
ROLE="{$role}">...</AUTHOR_DATA>) then things work well.  XSLT
Programmer's Reference indicates that xsl:attribute children of
xsl:element must be before other children, but I'm doing that, so I
don't understand why I get the error.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread