Juliano A. Felipe
Juliano A. Felipe

Reputation: 584

XSL error "An attribute whose value must be a QName had the value '300x300'"

I get this error when trying to name an attribute with the image dimensions (300x300, 420x420, etc).

When I generate the same elements beginning with a letter, everything goes allright.

Here's what I got:

<xsl:for-each select="additionalImages/image">
    <xsl:if test="additional_image_dimensions != ''">
        <xsl:element name="{additional_image_dimensions}">
            <xsl:value-of select="additionalUrl"/>
        </xsl:element>
    </xsl:if>
</xsl:for-each>

I already tried to concatenate nothing to the string {concat('', additional_image_dimensions)}

Here's what I want:

<300x300>url</300x300>

Ps.: When I try to put a letter on the beginning, it works:

<x30x30>url</x30x30>
<x300x300>url</x300x300>

How can I generate a dynamic element named like <300x300>url</300x300>?

Upvotes: 0

Views: 945

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 116993

How can I generate a dynamic element named like <300x300>url</300x300>?

You can't: an element name cannot begin with a digit: http://www.w3.org/TR/REC-xml/#NT-NameStartChar

Upvotes: 3

Related Questions