You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Gregor Fischer <fi...@informatik.uni-wuerzburg.de> on 2001/09/13 22:39:10 UTC
[C2] TraxTransformer / FragmentExtractor - Issue
Hi,
I posted a mail about a problem using the combination of the TraxTransformer
and the FragmentExtractor on this list a while ago.
Now I finally tracked it down.
It's a problem of the combination. When an element starts without being
associated with a namespace, the uri parameter to startElement() is an
empty String if called e.g. by FileGenerator. If called after the
TraxTransformer it is NULL, what triggers a NPE and causes the pipeline
to be aborted.
Here is an example for the changes made by the TraxTransformer (when using
a simple "copy-everything" stylesheet):
---cut---
[startDocument]
-[startElement] uri=,local=root,raw=root
+[startElement] uri=null,local=root,raw=root
[characters]
---cut---
Concluions:
- I append a patch to FragmentExtractor, that avoids a NPE to be thrown.
- Although this problem is solved with the patch alone, the TraxTransformer
(respectivly the underlying xalan (?)) should be modified to return an
empty string instead of NULL, to provide a more consistent calling
pattern (or is the value NULL to be expected in such a case ?).
I'd be happy if the patch would be incorporated.
---cut---
diff -u -r1.3.2.2 FragmentExtractorTransformer.java
--- src/org/apache/cocoon/transformation/FragmentExtractorTransformer.java 2001/08/20 14:07:34 1.3.2.2
+++ src/org/apache/cocoon/transformation/FragmentExtractorTransformer.java 2001/09/13 20:23:18
@@ -163,7 +163,7 @@
*/
public void startElement(String uri, String loc, String raw, Attributes a)
throws SAXException {
- if ( uri.equals(this.EXTRACT_URI) && loc.equals(this.EXTRACT_ELEMENT) ) {
+ if ( this.EXTRACT_URI.equals(uri) && this.EXTRACT_ELEMENT.equals(loc) ) {
extractLevel++;
imageID++;
getLogger().debug("FragmentExtractorTransformer extractLevel now " + extractLevel + ".");
---cut---
Greg
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
RE: [C2] TraxTransformer / FragmentExtractor - Issue
Posted by Vadim Gritsenko <vg...@yahoo.com>.
Thanks, patch applied.
I'm not sure is it Xalan issue or not, but I do remeber I had similar issue somewhere...
Vadim
> -----Original Message-----
> From: Gregor Fischer [mailto:fischer@informatik.uni-wuerzburg.de]
> Sent: Thursday, September 13, 2001 4:39 PM
> To: cocoon-dev@xml.apache.org
> Subject: [C2] TraxTransformer / FragmentExtractor - Issue
>
>
>
> Hi,
>
> I posted a mail about a problem using the combination of the TraxTransformer
> and the FragmentExtractor on this list a while ago.
> Now I finally tracked it down.
>
> It's a problem of the combination. When an element starts without being
> associated with a namespace, the uri parameter to startElement() is an
> empty String if called e.g. by FileGenerator. If called after the
> TraxTransformer it is NULL, what triggers a NPE and causes the pipeline
> to be aborted.
>
> Here is an example for the changes made by the TraxTransformer (when using
> a simple "copy-everything" stylesheet):
>
> ---cut---
> [startDocument]
> -[startElement] uri=,local=root,raw=root
> +[startElement] uri=null,local=root,raw=root
> [characters]
> ---cut---
>
> Concluions:
> - I append a patch to FragmentExtractor, that avoids a NPE to be thrown.
> - Although this problem is solved with the patch alone, the TraxTransformer
> (respectivly the underlying xalan (?)) should be modified to return an
> empty string instead of NULL, to provide a more consistent calling
> pattern (or is the value NULL to be expected in such a case ?).
>
>
> I'd be happy if the patch would be incorporated.
>
> ---cut---
> diff -u -r1.3.2.2 FragmentExtractorTransformer.java
> --- src/org/apache/cocoon/transformation/FragmentExtractorTransformer.java 2001/08/20 14:07:34 1.3.2.2
> +++ src/org/apache/cocoon/transformation/FragmentExtractorTransformer.java 2001/09/13 20:23:18
> @@ -163,7 +163,7 @@
> */
> public void startElement(String uri, String loc, String raw, Attributes a)
> throws SAXException {
> - if ( uri.equals(this.EXTRACT_URI) && loc.equals(this.EXTRACT_ELEMENT) ) {
> + if ( this.EXTRACT_URI.equals(uri) && this.EXTRACT_ELEMENT.equals(loc) ) {
> extractLevel++;
> imageID++;
> getLogger().debug("FragmentExtractorTransformer extractLevel now " + extractLevel + ".");
> ---cut---
>
>
> Greg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org