Re: [xsl] Error when switching to java 1.5

Subject: Re: [xsl] Error when switching to java 1.5
From: footh <footh@xxxxxxxxx>
Date: Tue, 24 Oct 2006 11:37:31 -0700 (PDT)
Thanks for the reply.

I am using Xalan 2.7 which implements XSLT 1.0.

The idea behind the identity template is to just
repeat the source XML.  So, that is my desired result.
 In this case, I have HTML mixed in with custom XML. 
The custom XML gets transformed with specific
templates while the HTML should just be copied over.

I've experimented a little on the results.  It turns
out that the error occurs when the processor first
hits an attribute inside an HTML tag.  What I did was
change the problematic "apply-templates" tag to this:

<xsl:apply-templates select="@id|node()" />

Then used a simple source XML doc:

<div id="someid">hello</div>

And, I received the error.  But if I took out the "id"
attribute then I did not receive the error.  Of
course, if I changed it to another attribute, then I
wouldn't receive an error, but the attribute would not
be copied to the result.

So, clearly, something is going wrong with coping over

Note that if I use this identity template:

<xsl:template match="@*|node()">
    <xsl:apply-templates select="@*|node()"/>

Everything works fine.  BUT, this template does not
remove namespaces (which causes the result to not
conform to valid XHTML).

So, if anyone can suggest another way to have an
identity template that removes namespaces, that would
be great.  For reference, here is the identity
template combo I'm using that is problematic (on the
second template):

<xsl:template match="@*">
  <xsl:attribute name="{name()}"
   <xsl:value-of select="." />

<xsl:template match="*">
  <xsl:element name="{name()}"
   <xsl:apply-templates select="@*|node()" />

--- Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:

> Can you please tell, what is your source XML and the
> desired output?
> Which XSLT processor and its version are you using?
> Are you using XSLT
> 1.0 or XSLT 2.0?
> This information will help us to solve the problem.
> On 10/21/06, footh <footh@xxxxxxxxx> wrote:
> > I am using an identity template that removes
> > namespaces in a Cocoon application that runs under
> > Tomcat.  Previously, I was using Java 1.4.2 but
> once I
> > switched to Java 1.5 I receive a null pointer
> > TransformerException.  Following is the identity
> > template that matches all nodes.  The error occurs
> on
> > the "apply-templates" tag.  On the "select"
> attribute,
> > the presence of the "@*" symbol causes the error. 
> If
> > I remove it, everything is fine.  However, then
> > attributes of nodes are not rendered.  Has anyone
> > encountered this problem before?  Any suggestions?
> >
> >  <xsl:template match="*">
> >   <xsl:element name="{name()}"
> > namespace="{namespace-uri()}">
> >     <xsl:apply-templates select="@*|node()" />
> >   </xsl:element>
> >  </xsl:template>
> -- 
> Regards,
> Mukul Gandhi

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

Current Thread