You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Per Kreipke <pe...@onclave.com> on 2002/07/30 19:59:12 UTC

Error handling in xsp:element...

If I do the following in an XSP, the CInclude transformer doesn't recognize
the cinclude:include element because it has no namespace associated with it.

<xsp:element name="cinclude:include">
  <xsp:attribute name="src"><xsp:expr>strURL</xsp:expr></xsp:attribute>
</xsp:element>


I had to change it to be:

<xsp:element name="cinclude:include" prefix="cinclude"
uri="http://apache.org/cocoon/include/1.0">
  <xsp:attribute name="src"><xsp:expr>strURL</xsp:expr></xsp:attribute>
</xsp:element>


In the second example, the condition where I forget to include both @prefix
and @uri, I get an error. But in the first example, there's no error even
though cinclude:include is an invalid XML element name without a namespace.

xsp.xsl would need an extra check.

Per


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


RE: Error handling in xsp:element...

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Per Kreipke [mailto:per@onclave.com]
> 
> > > If I do the following in an XSP, the CInclude transformer doesn't
> > > recognize
> > > the cinclude:include element because it has no namespace
> > > associated with it.
> > >
> > > <xsp:element name="cinclude:include">
> >
> > This is incorrect.
> 
> Of course. I thought it might take it from the a parent XSP element
> but it doesn't.
> 
> > >   <xsp:attribute
> > > name="src"><xsp:expr>strURL</xsp:expr></xsp:attribute>
> > > </xsp:element>
> > >
> > >
> > > I had to change it to be:
> > >
> > > <xsp:element name="cinclude:include" prefix="cinclude"
> > > uri="http://apache.org/cocoon/include/1.0">
> >
> > This is also not ok. Should be:
> >
> > <xsp:element name="include" prefix="cinclude"
> > uri="http://apache.org/cocoon/include/1.0">
> 
> Yep, you're right of course, copy/paste sloppiness.
> 
> > >   <xsp:attribute
> > > name="src"><xsp:expr>strURL</xsp:expr></xsp:attribute>
> > > </xsp:element>
> > >
> > >
> > > In the second example, the condition where I forget to include 
> > > both @prefix
> > > and @uri, I get an error. But in the first example, there's 
> > > no error even
> > > though cinclude:include is an invalid XML element name without 
> > > a namespace.
> > >
> > > xsp.xsl would need an extra check.
> >
> > It will not be efficient to do this, because this check must be made
at
> > run time, and every time. I guess you have not considered that this
is
> > possible:

Forgot to add @name:

> > <xsp:element prefix="cinclude"
> > uri="http://apache.org/cocoon/include/1.0">
> >   <xsp:param name="name"><xsp:logic>"incl" +
"ude"</xsp:logic></xsp:param>
> > </xsp:element>
> [aside: is <xsp:param> a real thing?]

Now it's real.


> I see you're point. But I'm willing to let that case go for efficiency
as
> long as we protect the beginner from naiive mistakes like
> name="cinclude:include". Just testing for ':' within @name would help
> prevent highlight their error instead of doing nothing at all.

Ok.

> It turns out that the CIncludeTransformer (correctly) skips the
element
> completely (because the namespace URI isn't applied to the element)
but when
> you examine the XML, it's not at all apparent, especially if you've
added
> the cinclude namespace at the top. Instead, the cinclude:include
element
> continues to appear in the output, no matter what you do to the
sitemap,
> mistakenly thinking that the transformer isn't being executed.

:)

Vadim


> Per


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


RE: Error handling in xsp:element...

Posted by Per Kreipke <pe...@onclave.com>.
> > If I do the following in an XSP, the CInclude transformer doesn't
> recognize
> > the cinclude:include element because it has no namespace associated
> with it.
> >
> > <xsp:element name="cinclude:include">
>
> This is incorrect.

Of course. I thought it might take it from the a parent XSP element but it
doesn't.

> >   <xsp:attribute
> name="src"><xsp:expr>strURL</xsp:expr></xsp:attribute>
> > </xsp:element>
> >
> >
> > I had to change it to be:
> >
> > <xsp:element name="cinclude:include" prefix="cinclude"
> > uri="http://apache.org/cocoon/include/1.0">
>
> This is also not ok. Should be:
>
> <xsp:element name="include" prefix="cinclude"
> uri="http://apache.org/cocoon/include/1.0">

Yep, you're right of course, copy/paste sloppiness.

> >   <xsp:attribute
> name="src"><xsp:expr>strURL</xsp:expr></xsp:attribute>
> > </xsp:element>
> >
> >
> > In the second example, the condition where I forget to include both
> @prefix
> > and @uri, I get an error. But in the first example, there's no error
> even
> > though cinclude:include is an invalid XML element name without a
> namespace.
> >
> > xsp.xsl would need an extra check.
>
> It will not be efficient to do this, because this check must be made at
> run time, and every time. I guess you have not considered that this is
> possible:
>
> <xsp:element prefix="cinclude"
> uri="http://apache.org/cocoon/include/1.0">
>   <xsp:param><xsp:logic>"incl" + "ude"</xsp:logic></xsp:param>
> </xsp:element>
[aside: is <xsp:param> a real thing?]

I see you're point. But I'm willing to let that case go for efficiency as
long as we protect the beginner from naiive mistakes like
name="cinclude:include". Just testing for ':' within @name would help
prevent highlight their error instead of doing nothing at all.

It turns out that the CIncludeTransformer (correctly) skips the element
completely (because the namespace URI isn't applied to the element) but when
you examine the XML, it's not at all apparent, especially if you've added
the cinclude namespace at the top. Instead, the cinclude:include element
continues to appear in the output, no matter what you do to the sitemap,
mistakenly thinking that the transformer isn't being executed.

Per


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


RE: Error handling in xsp:element...

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Per Kreipke [mailto:per@onclave.com]
> 
> If I do the following in an XSP, the CInclude transformer doesn't
recognize
> the cinclude:include element because it has no namespace associated
with it.
> 
> <xsp:element name="cinclude:include">

This is incorrect.


>   <xsp:attribute
name="src"><xsp:expr>strURL</xsp:expr></xsp:attribute>
> </xsp:element>
> 
> 
> I had to change it to be:
> 
> <xsp:element name="cinclude:include" prefix="cinclude"
> uri="http://apache.org/cocoon/include/1.0">

This is also not ok. Should be:

<xsp:element name="include" prefix="cinclude"
uri="http://apache.org/cocoon/include/1.0">


>   <xsp:attribute
name="src"><xsp:expr>strURL</xsp:expr></xsp:attribute>
> </xsp:element>
> 
> 
> In the second example, the condition where I forget to include both
@prefix
> and @uri, I get an error. But in the first example, there's no error
even
> though cinclude:include is an invalid XML element name without a
namespace.
> 
> xsp.xsl would need an extra check.

It will not be efficient to do this, because this check must be made at
run time, and every time. I guess you have not considered that this is
possible:

<xsp:element prefix="cinclude"
uri="http://apache.org/cocoon/include/1.0">
  <xsp:param><xsp:logic>"incl" + "ude"</xsp:logic></xsp:param>
</xsp:element>

Vadim


> Per



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>