> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > Hello, > > ad 1: > > Vadim, as you suggested it finally works with this expression - > thanks!: > <util:include- > expr><util:expr><xsp:expr>mm.marshal(mm.getSimpleItems())</xsp:expr></ut il:exp > r></util:include-expr> > > ad 2: > > The contentHandler used in 2 b) is a TraxTransformer instance. Is it > possible that in this case the resulting intermediate XML contains the '<?xml > version="1.0" encoding="UTF-8"?>' expression before the actual marshalled xml? > Could this be the reason for the javax.xml.transform.TransformerException: > java.lang.NullPointerException?
No. The cause should be extra startDocument()/endDocument() pair which could be eliminated by using included XML consumer (see bottom of the email). Vadim > So far I did not cope it to apply a stylesheet correctly to the marshalled > xml. The stylesheet works correctly for option 1: > > Regards, > > Harald > > > > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > > > > > > > 1. Include Object as String: > > > > > > > > > > > > > > > <xsp:page > > > > > language="java" > > > > > xmlns:xsp="http://apache.org/xsp" > > > > > xmlns:cinclude="http://apache.org/cocoon/include/1.0" > > > > > xmlns:util="http://apache.org/xsp/util/2.0" > > > > > > > > > > > <some-items anAttr="aVal"> > > > > > <util:include-expr> > > > > > > > > > <xsp:expr>model.getAnItemAsString()</xsp:expr> > > > > > </util:include-expr> > > > > > </some-items> > > > > > </some-items> > > > > > </xsp:page> > > > > > > > > > > The page does not compile. The method .getAnItemAsString is not > > even > > > > > executed. > > > > > > > > This will compile if you put everything on one line, no text nodes > > in > > > > the util:include-expr element: > > > > > > > > > > <util:include-expr><xsp:expr>model.getAnItemAsString()</xsp:expr></util: > > > > include-expr> > > > > > > > > Also, I would not recommend you this anyway because of re-parsing > > > > performance penalty. > > > > > > As follows I include my original sources and the corresponding output: > > > (They slightly differ formally from the above mentioned example) > > > > > > > > > Table.xsp: > > > > > > <?xml version="1.0" encoding="ISO-8859-1"?> > > > <xsp:page > > > language="java" > > > xmlns:xsp="http://apache.org/xsp" > > > xmlns:cinclude="http://apache.org/cocoon/include/1.0" > > > xmlns:util="http://apache.org/xsp/util/2.0" > > > > > > > > > > <xsp:structure> > > > <xsp:include>web.ModelManager</xsp:include> > > > </xsp:structure> > > > > > > > > > <simple-items edit="true" curSel="2"> > > > <xsp:logic> > > > ModelManager mm = new > > > ModelManager(); > > > <util:include- > > > > > expr><util:expr>mm.marshal(mm.getSimpleItems())</util:expr></util:includ > > e- > > > expr> > > > > You need <xsp:expr>mm.marshal(mm.getSimpleItems())</xsp:expr> here to > > treat Java as Java but not as text. (See above!!!) > > > > (not sure about util:expr, try with it and without it, but xsp:expr is > > must) > > > > Vadim > > > > > </xsp:logic> > > > </simple-items> > > > </xsp:page> > > > > > > resulting web-page: > > > > > > > > > org.apache.cocoon.ProcessingException: Language Exception: > > > org.apache.cocoon.components.language.LanguageException: Error > > compiling > > > Table_xsp: Line 136, > > > column 111: ')' expected. Line 0, column 0: 1 error > > > > > > > > > created Table_xsp.java: > > > > > > try { > > > newParser = (org.apache.cocoon.components.parser.Parser) > > > this.manager.lookup( > > > > > > org.apache.cocoon.components.parser.Parser.ROLE); > > > InputSource __is = new InputSource( > > > new > > > > > StringReader(String.valueOf(this.characters("mm.marshal(mm.getSimpleItem > > s())") > > > ;))); > > > > > > > > > XSPUtil.include(__is, this.contentHandler, newParser); > > > } catch (Exception e) { > > > getLogger().error("Could not include page", e); > > > } > > > finally { if (newParser != null) > > > this.manager.release((Component) newParser); > > > } } > > > As you can see there is a ";" in between a java statement: > > > '...s())");)));' > > > > > > Is there any other error in my page? > > > > > > > > > > > 2. > > > > > Use Castor's marshalling capabilities: > > > > > > > > > > <some-items anAttr="aVal"> > > > > > <xsp:logic> > > > > > model.marshal(this.contentHandler); > > > > > </xsp:logic> > > > > > </some-items> > > > > > > > > This sounds perfect. > > > > > > > > > > > > > Within the method I pass the contentHandler (wrapped into > > > > > DocumentHandlerAdapter) to castor's marshaller before I > > > > > perfom mashal(obj). > > > > > > > > > > As A result the cinclude transformer (which I need) > > > > > complains about a > > > > > Nullpointer exception. > > > > > > > > Make sure that model.marshal() does not call startDocument() and > > > > endDocument() on the contentHandler. If it does, you should > > > > strip these > > > > calls by wrapping contentHandler into the IncludeXMLConsumer. > > > > > > > > This should work. Or we have a bug. > > > ... --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faqs.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>