[
https://issues.apache.org/jira/browse/XALANJ-1451?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16679599#comment-16679599
]
Antonio Ospite commented on XALANJ-1451:
----------------------------------------
Hi,
I still get this warning with xalan 2.7.2.
It looks like it happens when {{<xsl:attribute>}} is not the first child of an
element.
Compare the following snippets where an element is copied adding a new
attribute.
This one, which puts the new attribute *after* the existing ones, gives the
warning "_Attribute 'new_attr' outside of element._":
{code:xml}
<xsl:template match="element">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="new_attr">new_value</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
{code}
This one, which puts the new attribute *before* the existing ones, does not
give the warning:
{code:xml}
<xsl:template match="element">
<xsl:copy>
<xsl:attribute name="new_attr">new_value</xsl:attribute>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
{code}
Should the first variant valid too?
JFYI Saxon does not give any warning for the first variant.
Ciao,
Antonio
> getting warning Attribute is outside of element where a template precedes the
> attribute
> ---------------------------------------------------------------------------------------
>
> Key: XALANJ-1451
> URL: https://issues.apache.org/jira/browse/XALANJ-1451
> Project: XalanJ2
> Issue Type: Bug
> Security Level: No security risk; visible to anyone(Ordinary problems in
> Xalan projects. Anybody can view the issue.)
> Components: XSLTC
> Affects Versions: 2.5Dx
> Environment: Operating System: Windows NT/2K
> Platform: PC
> Reporter: Timothy E. Cronin
>
> given the following Stylesheet as a Source
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="/">
> <FONT>
> <xsl:apply-templates select="/Properties/Group[@Name='Data
> Properties']/Datum[@Name='Font']/Font"/>
> <xsl:attribute name="color"><xsl:if test="Datum[@Name='QuantityShort']
> <0">Red</xsl:if></xsl:attribute>
> <xsl:value-of select="Datum[@Name='QuantityOnOrder']"/>
> </FONT>
> </xsl:template>
> <xsl:template match="Font">
> <xsl:attribute name="face"><xsl:value-of
> select="@Family"/></xsl:attribute>
> <xsl:attribute name="color"><xsl:value-of
> select="@Color"/></xsl:attribute>
> <xsl:attribute name="style">font-size:<xsl:value-of select="@Size"/>;
> font-
> style:<xsl:value-of select="@Style"/>;font-weight:<xsl:value-of
> select="@Weight"/>;</xsl:attribute>
> </xsl:template>
> </xsl:stylesheet>
> I get a transformation warning saying that "Attribute color is outside of
> element" when calling
> org.apache.xalan.xsltc.trax.TransformerFactoryImpl.newTemplates(Source source)
> the error is refering to this line:
> <xsl:attribute name="color"><xsl:if test="Datum[@Name='QuantityShort']
> <0">Red</xsl:if></xsl:attribute>
> the problem is within the font section
> <FONT>
> <xsl:apply-templates select="/Properties/Group[@Name='Data
> Properties']/Datum[@Name='Font']/Font"/>
> <xsl:attribute name="color"><xsl:if test="Datum[@Name='QuantityShort']
> <0">Red</xsl:if></xsl:attribute>
> <xsl:value-of select="Datum[@Name='QuantityOnOrder']"/>
> </FONT>
> the xsl:apply-templates is refering to <xsl:template match="Font"> that only
> sets font attributes.
> the attribute after the template is also ignored.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]