> > 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:include-expr>
</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.getSimpleItems())");)));
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.
I include fragments of the original sources:
Table.xsp:
...
<simple-items edit="true" curSel="2">
<xsp:logic>
ModelManager mm = new ModelManager();
mm.chmarshal(mm.getSimpleItems(), this.contentHandler);
</xsp:logic>
</simple-items>
..
ModelManager.java:
...
public void chmarshal (Collection col, org.xml.sax.ContentHandler
_docHandler){
Marshaller marshaller = marshaller = new Marshaller(new
org.apache.cocoon.xml.DocumentHandlerAdapter(_docHandler));
Iterator it = col.iterator();
while (it.hasNext()){
Object obj = it.next();
marshaller.marshal(obj);
}
}
...
I include two distinct possibilities to call the page once only processing
the xsp the other one including transformation with a stylesheet.
a) only processing the xsp
Sitemap entry:
<map:match pattern="ti" >
<map:generate type="serverpages" src="Table.xsp"/>
<map:transform type="cinclude"/>
<map:serialize type="xml"/>
</map:match>
Result in web browser:
<?xml version="1.0" encoding="UTF-8"?>
<simple-items edit="true" curSel="2" xmlns:xsp="http://apache.org/xsp"
xmlns:util="http://apache.org/xsp/util/2.0"
xmlns:cinclude="http://apache.org/cocoon/include/1.0">
<?xml version="1.0" encoding="UTF-8"?>
<simple-item weight="111"
id="1"><name>one</name><weight-msg/><id-msg/><name-msg/></simple-item>
<?xml version="1.0" encoding="UTF-8"?>
<simple-item weight="22"
id="2"><name>two</name><weight-msg/><id-msg/><name-msg/></simple-item>
<?xml version="1.0" encoding="UTF-8"?>
<simple-item weight="33"
id="3"><name>three</name><weight-msg/><id-msg/><name-msg/></simple-item>
Note that "<?xml version="1.0" encoding="UTF-8"?>" is inserted before each
marshalled object. If I include the output statically to an xml page my
Stylesheet complains about that and refuses transformation.
b)including transformation with a stylesheet
Site map entry:
<map:match pattern="tbl.htm">
<map:generate type="serverpages" src="Table.xsp"/>
<map:transform type="cinclude"/>
<map:transform src="Table.xsl"/>
<map:serialize type="html"/>
</map:match>
output from cocoon's logfile:
ERROR (2002-04-10) 22:04.38:129 [sitemap.generator.velocity] (/pcsb/)
HttpProcessor[8080][0]/VelocityGenerator: ResourceManager : unable to find
resource 'VM_global_library.vm' in any resource loader.
ERROR (2002-04-10) 22:04.38:189 [sitemap.generator.velocity] (/pcsb/)
HttpProcessor[8080][0]/VelocityGenerator: ResourceManager : unable to find
resource 'VM_global_library.vm' in any resource loader.
ERROR (2002-04-10) 22:04.38:239 [sitemap.generator.xmldb] (/pcsb/)
HttpProcessor[8080][0]/XMLDBGenerator: There was a problem setting up the
connection
ERROR (2002-04-10) 22:04.38:239 [sitemap.generator.xmldb] (/pcsb/)
HttpProcessor[8080][0]/XMLDBGenerator: Make sure that your driver is available
ERROR (2002-04-10) 22:04.38:249 [sitemap.generator.xmldb] (/pcsb/)
HttpProcessor[8080][0]/XMLDBGenerator: There was a problem setting up the
connection
ERROR (2002-04-10) 22:04.38:249 [sitemap.generator.xmldb] (/pcsb/)
HttpProcessor[8080][0]/XMLDBGenerator: Make sure that your driver is available
ERROR (2002-04-10) 22:04.38:270 [sitemap.generator.xmldbcollection]
(/pcsb/) HttpProcessor[8080][0]/XMLDBCollectionGenerator: There was a problem
setting up the connection
ERROR (2002-04-10) 22:04.38:270 [sitemap.generator.xmldbcollection]
(/pcsb/) HttpProcessor[8080][0]/XMLDBCollectionGenerator: Make sure that your
driver is available
ERROR (2002-04-10) 22:04.38:280 [sitemap.generator.xmldbcollection]
(/pcsb/) HttpProcessor[8080][0]/XMLDBCollectionGenerator: There was a problem
setting up the connection
ERROR (2002-04-10) 22:04.38:280 [sitemap.generator.xmldbcollection]
(/pcsb/) HttpProcessor[8080][0]/XMLDBCollectionGenerator: Make sure that your
driver is available
FATAL_E (2002-04-10) 22:05.26:960 [core.xslt-processor]
(/pcsb/table/tbl.htm) HttpProcessor[8080][0]/TraxErrorHandler: Error in
TraxTransformer:
javax.xml.transform.TransformerException: java.lang.NullPointerException
javax.xml.transform.TransformerException: java.lang.NullPointerException
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1230)
at
org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3139)
at java.lang.Thread.run(Thread.java:484)
Note: without cinclude there is no exception. Unfortunately I need cinclude
for a more complex dynamic stylesheet.
In both cases (with or without cinclude) the stylestheed doesn't process any
of the marshalled items.
Any ideas?
Harald
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net
---------------------------------------------------------------------
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]>