You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Anna Afonchenko <an...@ubaccess.com> on 2005/01/09 11:35:28 UTC

TransformerException Invalid element name

Hello all.

I have an xsl stylesheet that has the following template:

<xsl:template match="node()[not(name()='br' or name()='area' or name()='img' or local-name()='meta' or name()='link' or name()='input' or name()='hr')][normalize-space(.)=''][not(descendant::node())]">
<xsl:element name="{name()}">
<xsl:copy-of select="@*"/>
<xsl:text> </xsl:text>
</xsl:element>
</xsl:template>

It expands all closed tags in html.

This stylesheet is applied in the cocoon pipeline and produces the correct output.
BUT a lot of errors are output into the core.log of cocoon WEB-INF.
All errors are like this:
Error in TraxTransformer: file:/C:/tomcat/jakarta-tomcat-5.0.27/webapps/cocoon/renderings/stylesheets/expandTags.xsl; Line 13; Column -1; 
; SystemID: file:/C:/tomcat/jakarta-tomcat-5.0.27/webapps/cocoon/renderings/stylesheets/expandTags.xsl; Line#: 13; Column#: -1
javax.xml.transform.TransformerException: Invalid element name: 

The line causing the error is <xsl:element name="{name()}"> from the template above.

The problem is that this pipeline is used very often, and then the log file becomes very big - 30-40 Mb.

Is there any way to prevent the error to be written to the logs?
Or maybe the way I write xsl is invalid?

Thanks you very much for help.

Anna

Re: TransformerException Invalid element name

Posted by Joerg Heinicke <jo...@gmx.de>.
On 09.01.2005 11:35, Anna Afonchenko wrote:
> Hello all.
> 
> I have an xsl stylesheet that has the following template:
> 
> <xsl:template match="node()[not(name()='br' or name()='area' or name()='img' or local-name()='meta' or name()='link' or name()='input' or name()='hr')][normalize-space(.)=''][not(descendant::node())]">
> <xsl:element name="{name()}">
> <xsl:copy-of select="@*"/>
> <xsl:text> </xsl:text>
> </xsl:element>
> </xsl:template>
> 
> It expands all closed tags in html.

If it expands all closed tags, why *not*(name()='br')? Shouldn't it be 
the other way around "node()[name()='br']" etc.?

> This stylesheet is applied in the cocoon pipeline and produces the correct output.
> BUT a lot of errors are output into the core.log of cocoon WEB-INF.
> All errors are like this:
> Error in TraxTransformer: file:/C:/tomcat/jakarta-tomcat-5.0.27/webapps/cocoon/renderings/stylesheets/expandTags.xsl; Line 13; Column -1; 
> ; SystemID: file:/C:/tomcat/jakarta-tomcat-5.0.27/webapps/cocoon/renderings/stylesheets/expandTags.xsl; Line#: 13; Column#: -1
> javax.xml.transform.TransformerException: Invalid element name: 
> 
> The line causing the error is <xsl:element name="{name()}"> from the template above.
> 
> The problem is that this pipeline is used very often, and then the log file becomes very big - 30-40 Mb.
> 
> Is there any way to prevent the error to be written to the logs?
> Or maybe the way I write xsl is invalid?

You are matching on node(), not just elements. So a text node or comment 
node would also be matched. They have no name() and <xsl:element 
name="{name()}"/> fails.

I would write the expression as
"*[not(node())][self::br|self::area|self::img|self::meta|self::link|self::input|self::hr]"

Instead of descendant axis you can test the child axis, here shortened 
to node() instead of child::node(). If you test on child or 
descendant::node() you don't need the test for normalize-space(). There 
can not be any text that would not be matched by 
child/descendant::node(). And using the self axis the expression becomes 
much shorter and is namespace-aware - if you want that at all. For the 
not() mentioned above I don't know if I have an error in reasoning.

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org