You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Sonja Löhr <so...@arcor.de> on 2005/10/09 12:36:49 UTC

annoying senseless warnings

Hi!
I'm using the xalan-j implementation packaged with tomcat 5.5.9 - sorry,
I didn't search all logs to obtain the version.

I have templates like the following, embedding an <xsl:attribute> inside
an <xsl:copy>:

<xsl:template match="map/area">
	<xsl:copy>
		<xsl:apply-templates select="@coords"/>
		<xsl:apply-templates select="@shape"/>
		<xsl:attribute name="href">
<xsl:value-of select="$country_url"/>?c=<xsl:value-of select="@id"/>
		</xsl:attribute>
	</xsl:copy>
</xsl:template>

With each area element I get the following warning:

Compilerwarnungen:
  file:///var/www/japplicoon/sungo/xslt/noreferer/regionList.xsl: line
60: Attribut 'href' befindet sich nicht in einem Element.

That is: "attribute 'href' is not inside an element"

Of course it is, after copying, and everything works fine, but my log is
full of these useless warnings. Is this fixed in a later version (which
one?) or is there really something strange with my code?

Thank you!
sonja



-- 
Sonja Löhr <so...@arcor.de>


Re: annoying senseless warnings

Posted by Sonja Löhr <so...@arcor.de>.
Thanks, David.
The two apply-templates copy the two attributes (through a general
copying template matching "@*|node"). I will replace them with
<xsl:copy-of> or, as you say, just change the order of the elements
inside xsl:copy. 
Just for technical interest: Since the output is fine, xalan seems to
not be able to predict that the result of the two apply-templates will
be just attributes?
Thanks again!
sonja



Am Sonntag, den 09.10.2005, 10:27 -0400 schrieb
david_marston@us.ibm.com:
> Sonja Löhr <so...@arcor.de> writes:
> <xsl:template match="map/area">
>     <xsl:copy>
>         <xsl:apply-templates select="@coords"/>
>         <xsl:apply-templates select="@shape"/>
>         <xsl:attribute name="href">
>             <xsl:value-of select="$country_url"/>etc.
>         </xsl:attribute>
>     </xsl:copy>
> </xsl:template>
> >With each area element I get the following warning:
> >That is: "attribute 'href' is not inside an element"
> 
> The two apply-templates for @coords and @shape must only construct 
> attributes or namespace
> declarations, because nodes of those two types must be constructed within 
> an element before
> any text nodes, comments, child elements, or processing instructions.
> 
> Since the order of the attributes is irrelevant, I suggest putting the 
> xsl:attribute instruction before
> the  two apply-templates. Even so, you should review the templates that 
> would be invoked by the
> two apply-templates to ensure that they finish constructing attributes 
> before the other kinds of
> nodes.
> .................David Marston
-- 
Sonja Löhr <so...@arcor.de>


Re: annoying senseless warnings

Posted by da...@us.ibm.com.
Sonja Löhr <so...@arcor.de> writes:
<xsl:template match="map/area">
    <xsl:copy>
        <xsl:apply-templates select="@coords"/>
        <xsl:apply-templates select="@shape"/>
        <xsl:attribute name="href">
            <xsl:value-of select="$country_url"/>etc.
        </xsl:attribute>
    </xsl:copy>
</xsl:template>
>With each area element I get the following warning:
>That is: "attribute 'href' is not inside an element"

The two apply-templates for @coords and @shape must only construct 
attributes or namespace
declarations, because nodes of those two types must be constructed within 
an element before
any text nodes, comments, child elements, or processing instructions.

Since the order of the attributes is irrelevant, I suggest putting the 
xsl:attribute instruction before
the  two apply-templates. Even so, you should review the templates that 
would be invoked by the
two apply-templates to ensure that they finish constructing attributes 
before the other kinds of
nodes.
.................David Marston