[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

error after attribute

Subject: error after attribute
From: "Dave Gomboc" <dave@xxxxxxxxxxxxxx>
Date: Thu, 14 Jun 2001 09:06:07 -0600
xsl attribute error
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.