RE: Using Jivan in a Barracuda App
"Madl Alfred" <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Arno ! Just wanted to ask if you are going to change Jivan to "LGPL". We would like to include Jivan as an XMLC alternative into Enhydra application framework but "GPL" would definitely be a problem for us...and I think also for Barracuda... Greetings. Alfred -----Original Message----- From: Arno Schatz [mailto:[email protected]] Posted At: Montag, 24. November 2003 12:29 Posted To: Barracuda Conversation: [Barracuda] Using Jivan in a Barracuda App Subject: Re: [Barracuda] Using Jivan in a Barracuda App Hi David, Jake, DefaultDOMWriter is really a class from XMLC. As Jake said, it should be called XMLCDOMWriter. Using Jivan to create the DOM and XMLC to serialize it, may result in strange behaviour, since XMLC is trying to correct HTML, while Jivan is not. (Even when outputting, XMLC is calling Tidy for pretty printing and change the DOM as Tidy thinks.) Anyway, this might be the source of the bug. So I went ahead and wrote a JivanDOMWriter, which should be used to output DOM created with Jivan. It also takes advantage of the speed improvement in Jivan serialization, which will speed up you the process by serveral times. I haven't done testing on this class, so I would appreciate if you can give it a try and let me know if this solves your problem. -Arno Jacob Kjome wrote: > Hi David, > > So, when you load up a document with Jivan and modify it directly with > Jivan or via the standard DOM interfaces and then render it with > DefaultDOMWriter, it works fine, but when you use BTemplate you get the > data you expect along with extraneous empty elements as well? Do I have > it straight so far? That's certainly odd. I can't say that I've > experimented much with Jivan and BTemplate. Just with standard DOM > modifications. > > Christian, any idea? Arno, any thoughts here? > > > Jake > > At 03:05 PM 11/22/2003 -0500, you wrote: > >> If I load a document with Jivan and then render it with DefaultDOMWriter >> everything works fine. However, If I use the page to create a BTemplate >> component to customize it using a TemplateModel, then the page does >> not render >> correctly, especially when rendering tables. I end up getting a blank >> <TD></TD> >> between each cell in the table and a blank <TR></TR> between each row. >> >> Can a document loaded with Jivan be used in a BTemplate component? Am >> I doing >> something wrong? Any ideas? >> >> Thanks in advance, >> David Robison >> >> Quoting David R Robison <[email protected]>: >> >> > Thanks for the info... >> > The problem I'm now having is in modifying the loaded HTML file. >> Here is >> > my code: >> > >> > class RenderSitePageHandler extends DefaultBaseEventListener { >> > public void handleViewEvent(ViewEventContext context) >> throws >> > EventException, >> > ServletException, IOException { >> > HttpServletRequest req = context.getRequest(); >> > >> > //get the XMLC object >> > Document page = >> > >> DefaultDOMLoader.getGlobalInstance().getDOM("/WEB-INF/jivan/SitePage.html" ); >> >> > DocumentFactory docFactory = >> DocumentFactory.getInstance(); >> > docFactory.docManFor(page).repair(page); >> > >> > //create a template component and render it >> > Node node = page.getElementById("SiteForm"); >> > BTemplate templateComp = new BTemplate(new >> SiteModel(context)); >> > templateComp.setView(new >> DefaultTemplateView(node)); >> > try {templateComp.render(new >> DefaultViewContext(context));} >> > catch (RenderException re) >> {logger.warn("Render err:"+re);} >> > >> > //now actually render the page >> > new DefaultDOMWriter().write(page, >> context.getResponse()); >> > } >> > } >> > >> > If I comment out the section where I create a template componet then >> the >> > page >> > renders fine. If not, then, when I write out the DOM, I get an empty >> > <td></td> >> > between each cell in my table and an empty <tr></tr> between each row. >> > I'm not >> > adding new rows to the table, just populating a form that uses tables. >> > >> > Any idea? Am I missing something? >> > >> > Thanks in advance, >> > David >> > >> > Quoting Jacob Kjome <[email protected]>: >> > >> > > DefaultDOMWriter uses XMLC to format the DOM. You can create your >> > own >> > > >> > > DOMWriter if you want. This is actually why I wanted to rename >> > > DefaultDOMWriter to XMLCDOMWriter. Calling is "Default" hides its >> > > implementation too much, and the whole point to switch out >> > > implementations >> > > at will anyway, not use a single default one. The DOMLoader is the >> > more >> > > >> > > generic of the 3 interfaces. Anyway, knowing that, you can create >> > your >> > > own >> > > DOMWriter implementation that doesn't use XMLC's DOM formatter. Oh, >> > and >> > > I >> > > forgot, there still is a dependency on XMLC via the >> > > XMLCDeferredParsingDOMFactory instance created by default in the >> > > DefaultDOMLoader. Hmm.... Those should really be separated more. >> > > Maybe >> > > we should add another getGlobalInstance() that takes a DOMFactory as >> > a >> > > >> > > parameter and have the default dom factory loaded up via reflection. >> > >> > > That >> > > way, DefaultDOMLoader would be much more generic. Anyway... >> > > >> > > >> > > Here are some ways to use the JivanDOMFactory.... >> > > >> > > First do... >> > > DefaultDOMLoader loader = DefaultDOMLoader.getGlobalInstance(); >> > > >> > > Then, either use the object repository assember as shown by Thelmo >> > below >> > > >> > > (except change XMLCDeferredParsingDOMFactory to JivanDOMFactory) or >> > use >> > > the >> > > following... >> > > >> > > >> > > JivanDOMFactory jfactory = new JivanDOMFactory(); >> > > jfactory.setServletContext(getServletContext()); >> > > loader.setDefaultDOMFactory(jfactory); >> > > >> > > //note that you can also choose to set the default dom factory to >> > > something >> > > else and use Jivan for a specific fully qualified class name (String) >> > or >> > > >> > > file path such as.... >> > > String docPath = "/WEB-INF/mydocs/myfile.html"; >> > > loader.registerDOMFactory(jfactory, docPath); >> > > >> > > >> > > Then do.... >> > > >> > > Document doc = loader.getDOM(docPath); >> > > >> > > >> > > Of course, you can skip the DOMLoader as you did before, but at that >> > > point, >> > > you might as well just load things as described here... >> > > http://www.jivan.org/parser/samples.html >> > > >> > > You can also look at how JivanDOMFactory is implemented to for an >> > > example >> > > of how to use it directly. >> > > >> > > Hope that clears things up a bit. >> > > >> > > Jake >> > > >> > > At 01:18 PM 11/18/2003 -0500, you wrote: >> > > >Thanks, when I try this without the xmlc.jar file, it complains >> > that >> > > the >> > > >class >> > > > >> > > >org/enhydra/xml/io/DOMFormatter >> > > > >> > > >is not found. Is the xmlc.jar files still required? >> > > > >> > > >david >> > > > >> > > >Thelmo Loisio wrote: >> > > >> >> > > >>On Tue, 2003-11-18 at 17:19, David R Robison wrote: >> > > >> >> > > >>> >> > > >>>Do you have an example of what to set in the object-repository to >> > use >> > > jivan? >> > > >>>David >> > > >>> >> > > >> >> > > >> >> > > >> >From the contrib package here it is snippet from >> > > >>object-repository.xml... >> > > >> >> > > >><object name="$df" >> > > >> > >> >>class="org.enhydra.barracuda.core.util.dom.XMLCDeferredParsingDOMFacto >> ry"> >> > > >> <!-- set the servlet context so that the dom factory can >> > > read >> > > >>web.xml context params --> >> > > >> <method name="setServletContext" arg="$sc"/> >> > > >> </object> >> > > >> >> > > >> <object >> > > class="org.enhydra.barracuda.core.util.dom.DefaultDOMLoader"> >> > > >> <method name="getGlobalInstance" return="$dl"/> >> > > >> </object> >> > > >> >> > > >>... and from java within an handleViewEvent method... >> > > >> >> > > >>Document page = >> > > >>DefaultDOMLoader.getGlobalInstance().getDOM(WaitHTML.class, >> > > >>context.getViewCapabilities().getClientLocale()); >> > > >> >> > > >> >> > > >> >> > > > >> > > > >> > > >-- >> > > > >> > > >David R Robison >> > > >Open Roads Consulting, Inc. >> > > >708 S. Battlefield Blvd., Chesapeake, VA 23322 >> > > >phone: (757) 546-3401 >> > > >e-mail: >> > > >> > >> ><mailto:[email protected]>drrobison@openroadsconsulting >> .com >> > > >web: <http://openroadsconsulting.com>http://openroadsconsulting.com >> > > >> > > _______________________________________________ >> > > Barracuda mailing list >> > > [email protected] >> > > http://barracudamvc.org/lists/listinfo/barracuda >> > > >> > _______________________________________________ >> > Barracuda mailing list >> > [email protected] >> > http://barracudamvc.org/lists/listinfo/barracuda >> > >> _______________________________________________ >> Barracuda mailing list >> [email protected] >> http://barracudamvc.org/lists/listinfo/barracuda > > > _______________________________________________ > Barracuda mailing list > [email protected] > http://barracudamvc.org/lists/listinfo/barracuda > >
smime.p7s
(application/x-pkcs7-signature, 3.1 KB) - not displayed