You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Schmitz, Jeffrey A" <Je...@boeing.com> on 2007/03/01 15:17:20 UTC

Custom Transformer

 Is there a simple implementation of a Custom Transformer using
AbstractSAXTransformer anywhere?  Would love to see just a Hello World
program, but can't seem to find one.

Thanks,
Jeff

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Custom Transformer

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
OK, got the build to work, I was using double quotes.  I'll have to set it up and try with my transformer.

Jeff 

-----Original Message-----
From: Schmitz, Jeffrey A 
Sent: Thursday, March 01, 2007 1:17 PM
To: users@cocoon.apache.org
Subject: RE: Custom Transformer

Here's what I did to try and run my transformer:

I built and installed my transformer jar into ...\tomcat\common\lib, updated my sitemaps and invoked the transformer using my web browser.  When I invoke it, I get the undefined class error returned from Tomcat as follows (i.e. this shows up in my web browser):

Exception report

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception

root cause

java.lang.NoClassDefFoundError: org/apache/cocoon/caching/CacheableProcessingComponent
	java.lang.ClassLoader.defineClass1(Native Method) ...


I did try using quotation marks to set JAVA_HOME, but the build script still doesn't like it.  I still get the following error back from the "build" command:

Files\Java\jdk1.5.0_07"" was unexpected

Thanks,
Jeff

-----Original Message-----
From: Grzegorz Kossakowski [mailto:grek@tuffmail.com]
Sent: Thursday, March 01, 2007 1:07 PM
To: users@cocoon.apache.org
Subject: Re: Custom Transformer

Schmitz, Jeffrey A napisał(a):
> I think it's pretty close (see below), but I'm getting the following exception when running from Tomcat:
>
> java.lang.NoClassDefFoundError: 
> org/apache/cocoon/caching/CacheableProcessingComponent
>
> I was going to build and install the latest from Cocoon but I can't because the build script doesn't work since my JAVA_HOME variable includes a space (C:\Program files...).
>
> So... How can I get the latest Cocoon stuff built and/or where can I get the missing class/jar from?
>   
 From description above I do not understand completely what you have done leading to this error.

What can I advice to you is enclosing JAVA_HOME path in quotation marks, so it should be like this:
JAVA_HOME="C:\Program files\..."

doing this always solve my problems related to spaces in paths

--
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Custom Transformer

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
Here's what I did to try and run my transformer:

I built and installed my transformer jar into ...\tomcat\common\lib, updated my sitemaps and invoked the transformer using my web browser.  When I invoke it, I get the undefined class error returned from Tomcat as follows (i.e. this shows up in my web browser):

Exception report

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception

root cause

java.lang.NoClassDefFoundError: org/apache/cocoon/caching/CacheableProcessingComponent
	java.lang.ClassLoader.defineClass1(Native Method) ...


I did try using quotation marks to set JAVA_HOME, but the build script still doesn't like it.  I still get the following error back from the "build" command:

Files\Java\jdk1.5.0_07"" was unexpected

Thanks,
Jeff

-----Original Message-----
From: Grzegorz Kossakowski [mailto:grek@tuffmail.com] 
Sent: Thursday, March 01, 2007 1:07 PM
To: users@cocoon.apache.org
Subject: Re: Custom Transformer

Schmitz, Jeffrey A napisał(a):
> I think it's pretty close (see below), but I'm getting the following exception when running from Tomcat:
>
> java.lang.NoClassDefFoundError: 
> org/apache/cocoon/caching/CacheableProcessingComponent
>
> I was going to build and install the latest from Cocoon but I can't because the build script doesn't work since my JAVA_HOME variable includes a space (C:\Program files...).
>
> So... How can I get the latest Cocoon stuff built and/or where can I get the missing class/jar from?
>   
 From description above I do not understand completely what you have done leading to this error.

What can I advice to you is enclosing JAVA_HOME path in quotation marks, so it should be like this:
JAVA_HOME="C:\Program files\..."

doing this always solve my problems related to spaces in paths

--
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Custom Transformer

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
Thanks,
   I got it working.  Seems Windows doesn't care if you do 

SET JAVA_HOME=c:\path\to\java

from the command line.  It takes whatever you have set JAVA_HOME to in your System Control Panel.  In fact, I had to set it in the Control panel, and then reboot to get the build script to use the new path.

Someone might want to think about updating the install.txt document, as is, it doesn't work as written (at least not for me).  

OK, no I'll see if I can run my new transformer.

Thanks,
Jeff

-----Original Message-----
From: Grzegorz Kossakowski [mailto:grek@tuffmail.com] 
Sent: Thursday, March 01, 2007 2:01 PM
To: users@cocoon.apache.org
Subject: Re: Custom Transformer

Schmitz, Jeffrey A napisał(a):
> Sorry to be a pain, but the build still isn't working.
>
> What exactly does the JAVA_HOME need to be set to?  I'm setting it to:
>
> 'C:\Program Files\Java\jdk1.5.0_07'
>
> But it says it can't find tools.jar, or the javac compiler.  The 
> folder does exist, and tools.jar is in JAVA_HOME/lib and javac is in 
> JAVA_HOME/bin
>
>   
Oups, it always helped me under linux, not windows. I've confused things more than needed, sorry.
I've just tried svn checkout of 2.1.x and run:

G:\cocoon-2.1.x>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0

G:\cocoon-2.1.x>build
Buildfile: build.xml

prepare:
====================================================================
                 Apache Cocoon 2.1.11-dev [1999-2007] ====================================================================
 Building with Apache Ant version 1.6.5 compiled on June 2 2005
--------------------------------------------------------------------
 Using build file G:\cocoon-2.1.x\build.xml
--------------------------------------------------------------------
 Compiler options:
   - debug ......... [on]
   - optimize ...... [on]
   - deprecation ... [off]
====================================================================

compile-core:
Compiling jdk 1.4 core classes

[...]
BUILD SUCCESSFUL
Total time: 2 minutes 41 seconds

So it works as is, without any special adjustments. I cannot help you much with this issue as it's tightly related to your environment .
You should have started any work with having Cocoon's build working as it's crucial, really.

--
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: org.apache.cocoon.caching is missing from build

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Schmitz, Jeffrey A napisał(a):
> OK, it built, no errors, but still no caching package.  I downloaded cocoon-2.1.10 just a couple days ago.  Perhaps there is a problem with the build file? 
>   
Try "build clean" before "build" and see if it helps. If still no 
success, get completely fresh source checkout and try the same.
It really must be something wrong with your environment...

PS. Please refrain from sending "intermediate" e-mails. They create 
unnecessary traffic. Try to dig into issue on your own and post when you 
are sure you have no options left.

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: org.apache.cocoon.caching is missing from build

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
OK, it built, no errors, but still no caching package.  I downloaded cocoon-2.1.10 just a couple days ago.  Perhaps there is a problem with the build file? 

-----Original Message-----
From: Schmitz, Jeffrey A 
Sent: Thursday, March 01, 2007 3:13 PM
To: users@cocoon.apache.org
Subject: RE: org.apache.cocoon.caching is missing from build

Yes, the src\java\org\apache\cocoon\caching directory is there.  I'll build again and lookout for any intermediate errors.

Thanks,
Jeff 

-----Original Message-----
From: Grzegorz Kossakowski [mailto:grek@tuffmail.com]
Sent: Thursday, March 01, 2007 3:08 PM
To: users@cocoon.apache.org
Subject: Re: org.apache.cocoon.caching is missing from build

Schmitz, Jeffrey A napisał(a):
> I'm still back where I was, tomcat can't find the org/apache/cocoon/caching/CacheableProcessingComponent class.
>
> When I look in .../cocoon/WEB-INF/classes/org/apache/cocoon I see several packages:
>
> Acting
> Components
> Faces
> Forms
> Ojb
> Samples
>
> But I don't see caching.  I'm thinking I need this "caching" package, but I don't know where to get it.  I just did a build of cocoon-2.1.10, but it didn't show up as part of the build.   Any ideas?
>
>   
You should have this directory:
build\cocoon\classes\org\apache\cocoon\caching

but first check if you have this directory:
src\java\org\apache\cocoon\caching

It's really weird. There is no way to exclude this package from the build so I assume that your source checkout is somehow broken.

--
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: org.apache.cocoon.caching is missing from build

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
Yes, the src\java\org\apache\cocoon\caching directory is there.  I'll build again and lookout for any intermediate errors.

Thanks,
Jeff 

-----Original Message-----
From: Grzegorz Kossakowski [mailto:grek@tuffmail.com] 
Sent: Thursday, March 01, 2007 3:08 PM
To: users@cocoon.apache.org
Subject: Re: org.apache.cocoon.caching is missing from build

Schmitz, Jeffrey A napisał(a):
> I'm still back where I was, tomcat can't find the org/apache/cocoon/caching/CacheableProcessingComponent class.
>
> When I look in .../cocoon/WEB-INF/classes/org/apache/cocoon I see several packages:
>
> Acting
> Components
> Faces
> Forms
> Ojb
> Samples
>
> But I don't see caching.  I'm thinking I need this "caching" package, but I don't know where to get it.  I just did a build of cocoon-2.1.10, but it didn't show up as part of the build.   Any ideas?
>
>   
You should have this directory:
build\cocoon\classes\org\apache\cocoon\caching

but first check if you have this directory:
src\java\org\apache\cocoon\caching

It's really weird. There is no way to exclude this package from the build so I assume that your source checkout is somehow broken.

--
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: org.apache.cocoon.caching is missing from build

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Schmitz, Jeffrey A napisał(a):
> I'm still back where I was, tomcat can't find the org/apache/cocoon/caching/CacheableProcessingComponent class.
>
> When I look in .../cocoon/WEB-INF/classes/org/apache/cocoon I see several packages:
>
> Acting
> Components
> Faces
> Forms
> Ojb
> Samples
>
> But I don't see caching.  I'm thinking I need this "caching" package, but I don't know where to get it.  I just did a build of cocoon-2.1.10, but it didn't show up as part of the build.   Any ideas?
>
>   
You should have this directory:
build\cocoon\classes\org\apache\cocoon\caching

but first check if you have this directory:
src\java\org\apache\cocoon\caching

It's really weird. There is no way to exclude this package from the 
build so I assume that your source checkout is somehow broken.

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


org.apache.cocoon.caching is missing from build

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
I'm still back where I was, tomcat can't find the org/apache/cocoon/caching/CacheableProcessingComponent class.

When I look in .../cocoon/WEB-INF/classes/org/apache/cocoon I see several packages:

Acting
Components
Faces
Forms
Ojb
Samples

But I don't see caching.  I'm thinking I need this "caching" package, but I don't know where to get it.  I just did a build of cocoon-2.1.10, but it didn't show up as part of the build.   Any ideas?

Thanks,
Jeff

-----Original Message-----
From: Grzegorz Kossakowski [mailto:grek@tuffmail.com] 
Sent: Thursday, March 01, 2007 2:01 PM
To: users@cocoon.apache.org
Subject: Re: Custom Transformer

Schmitz, Jeffrey A napisał(a):
> Sorry to be a pain, but the build still isn't working.
>
> What exactly does the JAVA_HOME need to be set to?  I'm setting it to:
>
> 'C:\Program Files\Java\jdk1.5.0_07'
>
> But it says it can't find tools.jar, or the javac compiler.  The 
> folder does exist, and tools.jar is in JAVA_HOME/lib and javac is in 
> JAVA_HOME/bin
>
>   
Oups, it always helped me under linux, not windows. I've confused things more than needed, sorry.
I've just tried svn checkout of 2.1.x and run:

G:\cocoon-2.1.x>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0

G:\cocoon-2.1.x>build
Buildfile: build.xml

prepare:
====================================================================
                 Apache Cocoon 2.1.11-dev [1999-2007] ====================================================================
 Building with Apache Ant version 1.6.5 compiled on June 2 2005
--------------------------------------------------------------------
 Using build file G:\cocoon-2.1.x\build.xml
--------------------------------------------------------------------
 Compiler options:
   - debug ......... [on]
   - optimize ...... [on]
   - deprecation ... [off]
====================================================================

compile-core:
Compiling jdk 1.4 core classes

[...]
BUILD SUCCESSFUL
Total time: 2 minutes 41 seconds

So it works as is, without any special adjustments. I cannot help you much with this issue as it's tightly related to your environment .
You should have started any work with having Cocoon's build working as it's crucial, really.

--
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Custom Transformer

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Schmitz, Jeffrey A napisał(a):
> Sorry to be a pain, but the build still isn't working.
>
> What exactly does the JAVA_HOME need to be set to?  I'm setting it to:
>
> 'C:\Program Files\Java\jdk1.5.0_07'
>
> But it says it can't find tools.jar, or the javac compiler.  The folder does exist, and tools.jar is in JAVA_HOME/lib and javac is in JAVA_HOME/bin 
>
>   
Oups, it always helped me under linux, not windows. I've confused things 
more than needed, sorry.
I've just tried svn checkout of 2.1.x and run:

G:\cocoon-2.1.x>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0

G:\cocoon-2.1.x>build
Buildfile: build.xml

prepare:
====================================================================
                 Apache Cocoon 2.1.11-dev [1999-2007]
====================================================================
 Building with Apache Ant version 1.6.5 compiled on June 2 2005
--------------------------------------------------------------------
 Using build file G:\cocoon-2.1.x\build.xml
--------------------------------------------------------------------
 Compiler options:
   - debug ......... [on]
   - optimize ...... [on]
   - deprecation ... [off]
====================================================================

compile-core:
Compiling jdk 1.4 core classes

[...]
BUILD SUCCESSFUL
Total time: 2 minutes 41 seconds

So it works as is, without any special adjustments. I cannot help you 
much with this issue as it's tightly related to your environment .
You should have started any work with having Cocoon's build working as 
it's crucial, really.

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Custom Transformer

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
Sorry to be a pain, but the build still isn't working.

What exactly does the JAVA_HOME need to be set to?  I'm setting it to:

'C:\Program Files\Java\jdk1.5.0_07'

But it says it can't find tools.jar, or the javac compiler.  The folder does exist, and tools.jar is in JAVA_HOME/lib and javac is in JAVA_HOME/bin 

Thanks,
Jeff

-----Original Message-----
From: Grzegorz Kossakowski [mailto:grek@tuffmail.com] 
Sent: Thursday, March 01, 2007 1:07 PM
To: users@cocoon.apache.org
Subject: Re: Custom Transformer

Schmitz, Jeffrey A napisał(a):
> I think it's pretty close (see below), but I'm getting the following exception when running from Tomcat:
>
> java.lang.NoClassDefFoundError: 
> org/apache/cocoon/caching/CacheableProcessingComponent
>
> I was going to build and install the latest from Cocoon but I can't because the build script doesn't work since my JAVA_HOME variable includes a space (C:\Program files...).
>
> So... How can I get the latest Cocoon stuff built and/or where can I get the missing class/jar from?
>   
 From description above I do not understand completely what you have done leading to this error.

What can I advice to you is enclosing JAVA_HOME path in quotation marks, so it should be like this:
JAVA_HOME="C:\Program files\..."

doing this always solve my problems related to spaces in paths

--
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Custom Transformer

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Schmitz, Jeffrey A napisał(a):
> I think it's pretty close (see below), but I'm getting the following exception when running from Tomcat:
>
> java.lang.NoClassDefFoundError: org/apache/cocoon/caching/CacheableProcessingComponent
>
> I was going to build and install the latest from Cocoon but I can't because the build script doesn't work since my JAVA_HOME variable includes a space (C:\Program files...).
>
> So... How can I get the latest Cocoon stuff built and/or where can I get the missing class/jar from?
>   
 From description above I do not understand completely what you have 
done leading to this error.

What can I advice to you is enclosing JAVA_HOME path in quotation marks, 
so it should be like this:
JAVA_HOME="C:\Program files\..."

doing this always solve my problems related to spaces in paths

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Custom Transformer

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
I think it's pretty close (see below), but I'm getting the following exception when running from Tomcat:

java.lang.NoClassDefFoundError: org/apache/cocoon/caching/CacheableProcessingComponent

I was going to build and install the latest from Cocoon but I can't because the build script doesn't work since my JAVA_HOME variable includes a space (C:\Program files...).

So... How can I get the latest Cocoon stuff built and/or where can I get the missing class/jar from?

Thanks,
Jeff

-----Original Message-----
From: Grzegorz Kossakowski [mailto:grek@tuffmail.com] 
Sent: Thursday, March 01, 2007 10:36 AM
To: users@cocoon.apache.org
Subject: Re: Custom Transformer

Schmitz, Jeffrey A napisał(a):
> Thanks!
>
> So something like this (did I get the SaxBuffer stuff right?):
>
> public class Mytrans extends AbstractTransformer implements
> 		CacheableProcessingComponent {
>
>     XMLConsumer tempConsumer;
>     SaxBuffer mySaxConsumer = new SaxBuffer();
>     String content;
>
>     public void setup(SourceResolver resolver, Map objectModel, String src,
> 			Parameters params) throws ProcessingException, SAXException,
> 			IOException {
>
> 	tempConsumer = xmlConsumer;
> 	xmlConsumer = mySaxConsumer;
>
>    }
>
>
> 	public void endDocument() throws SAXException {
> 		
> 		super.endDocument();
> 		content = mySaxConsumer.toString();
> 		xmlConsumer = tempConsumer;
> 		
> 		content = myTransform(content);
> 		
> 		StringXMLizable xmlStr = new StringXMLizable(content);
>
> 		xmlStr.toSAX(contentHandler);
> 		  
> 	}
>
>  }
>   
I've never used SaxBuffer so I can't tell you if you use it correctly but I believe so. You should set your own consumer calling setConsumer method (take look on it to see why).
The rest seems to look ok. The best way is to try it and eventually debug.

--
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Custom Transformer

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
Sounds like I'm at least in the ballpark, I'll take a look at setConsumer.

Thanks for your help, would have taken me a LONG time looking all this up.

Jeff 

-----Original Message-----
From: Grzegorz Kossakowski [mailto:grek@tuffmail.com] 
Sent: Thursday, March 01, 2007 10:36 AM
To: users@cocoon.apache.org
Subject: Re: Custom Transformer

Schmitz, Jeffrey A napisał(a):
> Thanks!
>
> So something like this (did I get the SaxBuffer stuff right?):
>
> public class Mytrans extends AbstractTransformer implements
> 		CacheableProcessingComponent {
>
>     XMLConsumer tempConsumer;
>     SaxBuffer mySaxConsumer = new SaxBuffer();
>     String content;
>
>     public void setup(SourceResolver resolver, Map objectModel, String src,
> 			Parameters params) throws ProcessingException, SAXException,
> 			IOException {
>
> 	tempConsumer = xmlConsumer;
> 	xmlConsumer = mySaxConsumer;
>
>    }
>
>
> 	public void endDocument() throws SAXException {
> 		
> 		super.endDocument();
> 		content = mySaxConsumer.toString();
> 		xmlConsumer = tempConsumer;
> 		
> 		content = myTransform(content);
> 		
> 		StringXMLizable xmlStr = new StringXMLizable(content);
>
> 		xmlStr.toSAX(contentHandler);
> 		  
> 	}
>
>  }
>   
I've never used SaxBuffer so I can't tell you if you use it correctly but I believe so. You should set your own consumer calling setConsumer method (take look on it to see why).
The rest seems to look ok. The best way is to try it and eventually debug.

--
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Custom Transformer

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Schmitz, Jeffrey A napisał(a):
> Thanks!
>
> So something like this (did I get the SaxBuffer stuff right?):
>
> public class Mytrans extends AbstractTransformer implements
> 		CacheableProcessingComponent {
>
>     XMLConsumer tempConsumer;
>     SaxBuffer mySaxConsumer = new SaxBuffer();
>     String content;
>
>     public void setup(SourceResolver resolver, Map objectModel, String src,
> 			Parameters params) throws ProcessingException, SAXException,
> 			IOException {
>
> 	tempConsumer = xmlConsumer;
> 	xmlConsumer = mySaxConsumer;
>
>    }
>
>
> 	public void endDocument() throws SAXException {
> 		
> 		super.endDocument();
> 		content = mySaxConsumer.toString();
> 		xmlConsumer = tempConsumer;
> 		
> 		content = myTransform(content);
> 		
> 		StringXMLizable xmlStr = new StringXMLizable(content);
>
> 		xmlStr.toSAX(contentHandler);
> 		  
> 	}
>
>  }
>   
I've never used SaxBuffer so I can't tell you if you use it correctly 
but I believe so. You should set your own consumer calling setConsumer 
method (take look on it to see why).
The rest seems to look ok. The best way is to try it and eventually debug.

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Custom Transformer

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
Thanks!

So something like this (did I get the SaxBuffer stuff right?):

public class Mytrans extends AbstractTransformer implements
		CacheableProcessingComponent {

    XMLConsumer tempConsumer;
    SaxBuffer mySaxConsumer = new SaxBuffer();
    String content;

    public void setup(SourceResolver resolver, Map objectModel, String src,
			Parameters params) throws ProcessingException, SAXException,
			IOException {

	tempConsumer = xmlConsumer;
	xmlConsumer = mySaxConsumer;

   }


	public void endDocument() throws SAXException {
		
		super.endDocument();
		content = mySaxConsumer.toString();
		xmlConsumer = tempConsumer;
		
		content = myTransform(content);
		
		StringXMLizable xmlStr = new StringXMLizable(content);

		xmlStr.toSAX(contentHandler);
		  
	}

 }

-----Original Message-----
From: Grzegorz Kossakowski [mailto:grek@tuffmail.com] 
Sent: Thursday, March 01, 2007 9:22 AM
To: users@cocoon.apache.org
Subject: Re: Custom Transformer

Schmitz, Jeffrey A napisał(a):
> OK (you asked for it), basically I have some xml that needs to be massaged first by a simple xslt before being fed into my transformer, and then once my transformer is done, I need to result to be massaged again with another xslt.
>
> My transformer relies on some predefined and specific transformer libraries that I have no control over, so the xml has to be massaged to fit into the format required by these libraries.  If I can just build a string with the incoming xml (from the first xslt), I can then feed this string of xml into the custom transform libraries (as long as the xml contained in the string is structured correctly). So basically, here is what I need my custom tranformer to do:
>
> 1. Accept SAX events and build a string of the incoming xml 2. Perform 
> transform on the received xml string 3. Output the resulting xml in 
> the form of more Sax events for the next tranformer/serializer in line.  i.e. something like this:
>
>       String message = doMyCustomTransform(incomingXMLString);
>       
>       //Create a reader for turning a string into an InputSource
>       XMLReader xmlreader = XMLReaderFactory.createXMLReader();
>
>       //Set the content handler into the XMLReader class.
>       xmlreader.setContentHandler(contentHandler);
>
>       //Now feed the source into the xml reader, which will turn around and
>       //invoke the proper handlers in the contentHandler based on the
>       //string. 
>       InputSource source = new InputSource(new StringReader(message));
>       xmlreader.parse(source);
>   
I think it's overkill to use reader here. You should use StringXMLizable[1] instead. Basically you have to do this:
extend AbstractTransformer and in setup() remember it's current value of xmlConsumer and replace by instance of SaxBuffer[2].
SaxBuffer will record all events and you can serialize them into String. 
Do your transformations and create StringXMLizable instance and call toSAX method with original xmlConsumer as parameter.
You should do this in overloaded endDocument() methods but do not forget to call super method otherwise your SaxBuffer would be incomplete.

Hope that helps.
>
> I've pretty much got steps 2 and 3 worked out.  I just need the step 1 part.
>
> Need anymore details?
>   
No. I really like answering this kind of questions: precise, showing preparation and effort involved before asking for anything.

[1]
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/xml/StringXMLizable.html
[2]
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/xml/SaxBuffer.html

--
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Custom Transformer

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Schmitz, Jeffrey A napisał(a):
> OK (you asked for it), basically I have some xml that needs to be massaged first by a simple xslt before being fed into my transformer, and then once my transformer is done, I need to result to be massaged again with another xslt.
>
> My transformer relies on some predefined and specific transformer libraries that I have no control over, so the xml has to be massaged to fit into the format required by these libraries.  If I can just build a string with the incoming xml (from the first xslt), I can then feed this string of xml into the custom transform libraries (as long as the xml contained in the string is structured correctly). So basically, here is what I need my custom tranformer to do:
>
> 1. Accept SAX events and build a string of the incoming xml
> 2. Perform transform on the received xml string
> 3. Output the resulting xml in the form of more Sax events for the next tranformer/serializer in line.  i.e. something like this:
>
>       String message = doMyCustomTransform(incomingXMLString);
>       
>       //Create a reader for turning a string into an InputSource
>       XMLReader xmlreader = XMLReaderFactory.createXMLReader();
>
>       //Set the content handler into the XMLReader class.
>       xmlreader.setContentHandler(contentHandler);
>
>       //Now feed the source into the xml reader, which will turn around and
>       //invoke the proper handlers in the contentHandler based on the
>       //string. 
>       InputSource source = new InputSource(new StringReader(message));
>       xmlreader.parse(source);
>   
I think it's overkill to use reader here. You should use 
StringXMLizable[1] instead. Basically you have to do this:
extend AbstractTransformer and in setup() remember it's current value of 
xmlConsumer and replace by instance of SaxBuffer[2].
SaxBuffer will record all events and you can serialize them into String. 
Do your transformations and create StringXMLizable instance and call 
toSAX method with original xmlConsumer as parameter.
You should do this in overloaded endDocument() methods but do not forget 
to call super method otherwise your SaxBuffer would be incomplete.

Hope that helps.
>
> I've pretty much got steps 2 and 3 worked out.  I just need the step 1 part.
>
> Need anymore details?
>   
No. I really like answering this kind of questions: precise, showing 
preparation and effort involved before asking for anything.

[1] 
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/xml/StringXMLizable.html
[2] 
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/xml/SaxBuffer.html

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Custom Transformer

Posted by "Schmitz, Jeffrey A" <Je...@boeing.com>.
OK (you asked for it), basically I have some xml that needs to be massaged first by a simple xslt before being fed into my transformer, and then once my transformer is done, I need to result to be massaged again with another xslt.

My transformer relies on some predefined and specific transformer libraries that I have no control over, so the xml has to be massaged to fit into the format required by these libraries.  If I can just build a string with the incoming xml (from the first xslt), I can then feed this string of xml into the custom transform libraries (as long as the xml contained in the string is structured correctly). So basically, here is what I need my custom tranformer to do:

1. Accept SAX events and build a string of the incoming xml
2. Perform transform on the received xml string
3. Output the resulting xml in the form of more Sax events for the next tranformer/serializer in line.  i.e. something like this:

      String message = doMyCustomTransform(incomingXMLString);
      
      //Create a reader for turning a string into an InputSource
      XMLReader xmlreader = XMLReaderFactory.createXMLReader();

      //Set the content handler into the XMLReader class.
      xmlreader.setContentHandler(contentHandler);

      //Now feed the source into the xml reader, which will turn around and
      //invoke the proper handlers in the contentHandler based on the
      //string. 
      InputSource source = new InputSource(new StringReader(message));
      xmlreader.parse(source);


I've pretty much got steps 2 and 3 worked out.  I just need the step 1 part.

Need anymore details?

Thanks,
Jeff 

-----Original Message-----
From: Grzegorz Kossakowski [mailto:grek@tuffmail.com] 
Sent: Thursday, March 01, 2007 8:29 AM
To: users@cocoon.apache.org
Subject: Re: Custom Transformer

Schmitz, Jeffrey A napisał(a):
>  Is there a simple implementation of a Custom Transformer using 
> AbstractSAXTransformer anywhere?  Would love to see just a Hello World 
> program, but can't seem to find one.
>   
The most simple transformer I can think of is StripNamespacesTransformer[1].

It would be much better if you could come up with some details of your own transformer you want to write so we could give you some clues.

[1]
https://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/StripNameSpacesTransformer.java?view=markup

--
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Custom Transformer

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Schmitz, Jeffrey A napisał(a):
>  Is there a simple implementation of a Custom Transformer using
> AbstractSAXTransformer anywhere?  Would love to see just a Hello World
> program, but can't seem to find one.
>   
The most simple transformer I can think of is StripNamespacesTransformer[1].

It would be much better if you could come up with some details of your 
own transformer you want to write so we could give you some clues.

[1] 
https://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/StripNameSpacesTransformer.java?view=markup

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org