You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Donald Ball <ba...@webslingerZ.com> on 2000/06/21 19:00:27 UTC
problem with namespace declarations and XSP
Heya. A buddy of mine was testing out cocoon and came up with this
anomaly. He got an XML page like so:
<?xml version="1.0" ?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="mail.xsl" type="text/xsl"?>
<xsp:page
language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:mail="http://www.webslingerZ.com/archiveMail"
>
<page>
<mail:list>
<mail:message>
<messageId>12345</messageId>
<subject>You're a dink.</subject>
</mail:message>
<mail:message>
<messageId>67890</messageId>
<subject>Work damnit.</subject>
</mail:message>
</mail:list>
</page>
</xsp:page>
The stylesheet in question failed to process the elements in the mail
namespace. I tested out a simpler version by stripping the xslt stuff:
<?xml version="1.0" ?>
<?cocoon-process type="xsp"?>
<xsp:page
language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:mail="http://www.webslingerZ.com/archiveMail"
>
<page>
<mail:list>
<mail:message>
<messageId>12345</messageId>
<subject>You're a dink.</subject>
</mail:message>
<mail:message>
<messageId>67890</messageId>
<subject>Work damnit.</subject>
</mail:message>
</mail:list>
</page>
</xsp:page>
and my result is:
<?xml version="1.0" encoding="UTF-8"?>
<page>
<mail:list>
<mail:message>
<messageId>12345</messageId>
<subject>You're a dink.</subject>
</mail:message>
<mail:message>
<messageId>67890</messageId>
<subject>Work damnit.</subject>
</mail:message>
</mail:list>
</page>
note that the mail namespace declaration is _not_ copied to the result. I
think that's why the XSLT processor isn't rendering the results properly.
Ricardo, got any clues here?
- donald
Re: problem with namespace declarations and XSP
Posted by Ricardo Rocha <ri...@apache.org>.
Donald Ball wrote:
>
> Heya. A buddy of mine was testing out cocoon and came up with this
> anomaly. He got an XML page like so:
>
> <?xml version="1.0" ?>
>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="mail.xsl" type="text/xsl"?>
>
> <xsp:page
> language="java"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core"
> xmlns:mail="http://www.webslingerZ.com/archiveMail"
> >
> <page>
> <mail:list>
> <mail:message>
> <messageId>12345</messageId>
> <subject>You're a dink.</subject>
> </mail:message>
> <mail:message>
> <messageId>67890</messageId>
> <subject>Work damnit.</subject>
> </mail:message>
> </mail:list>
> </page>
> </xsp:page>
>
> The stylesheet in question failed to process the elements in the mail
> namespace. I tested out a simpler version by stripping the xslt stuff:
>
> <?xml version="1.0" ?>
>
> <?cocoon-process type="xsp"?>
>
> <xsp:page
> language="java"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core"
> xmlns:mail="http://www.webslingerZ.com/archiveMail"
> >
> <page>
> <mail:list>
> <mail:message>
> <messageId>12345</messageId>
> <subject>You're a dink.</subject>
> </mail:message>
> <mail:message>
> <messageId>67890</messageId>
> <subject>Work damnit.</subject>
> </mail:message>
> </mail:list>
> </page>
> </xsp:page>
>
> and my result is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <page>
> <mail:list>
> <mail:message>
> <messageId>12345</messageId>
> <subject>You're a dink.</subject>
> </mail:message>
> <mail:message>
> <messageId>67890</messageId>
> <subject>Work damnit.</subject>
> </mail:message>
> </mail:list>
> </page>
>
> note that the mail namespace declaration is _not_ copied to the result. I
> think that's why the XSLT processor isn't rendering the results properly.
> Ricardo, got any clues here?
Namespace handling in XSP for Cocoon1 is still incomplete but a fix is
coming soon (please, see my next posting).
For now, the following hack works: replicate the namespace declarations
you want to preserve on output in the "user" root element, using the
"xsp:" attribute prefix:
<?xml version="1.0" ?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="mail.xsl" type="text/xsl"?>
<xsp:page
language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:mail="http://www.webslingerZ.com/archiveMail"
>
<!-- To be preserved on output, namespace "mail" must
be replicated here -->
<page xsp:mail="http://www.webslingerZ.com/archiveMail">
<mail:list>
<mail:message>
<messageId>12345</messageId>
<subject>You're a dink.</subject>
</mail:message>
<mail:message>
<messageId>67890</messageId>
<subject>Work damnit.</subject>
</mail:message>
</mail:list>
</page>
</xsp:page>
This undocumented feature is kludgy, I know. Please note that
this (and all other namespace problems I'm aware of) have been
fixed in XSP for Cocoon2.
Please see my next posting for a discussion of XSP fixes
and new features.
Ricardo