xsl-list
[Top] [All Lists]

Re: [xsl] Error when switching to java 1.5

2006-10-24 11:38:00
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
attributes.

Note that if I use this identity template:

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

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()}"
namespace="{namespace-uri()}">
   <xsl:value-of select="." />
  </xsl:attribute>
</xsl:template>

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




--- Mukul Gandhi <gandhi(_dot_)mukul(_at_)gmail(_dot_)com> 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(_at_)yahoo(_dot_)com> 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


--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>