This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

error after attribute


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"/>
    </xsl:element>
</xsl:template>

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:choose>
            <xsl:when test="@ROLE">
                <xsl:value-of select="@ROLE"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="AUTHOR"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:element name="AUTHOR_DATA">
        <xsl:attribute name="ROLE" value="$role"/>
        <xsl:apply-templates select="@AR_ID"/>
        .
        .
    </xsl:element>
</xsl:template>

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.

Dave



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]