Re: [xmlc] building XHTML documents on the fly

Jacob Kjome <[email protected]> Tue, 29 Mar 2005 23:43:29 -0600
Newsgroups gmane.comp.java.enhydra.xmlc
Message-ID <[email protected]>
One more link...
http://www.cafeconleche.org/slides/sd2004west/xom/XOM_makes_XML_Easier.html


Jake

At 11:20 PM 3/29/2005 -0600, you wrote:
 >
 >I'd use XOM for straight XML stuff.  Very well thought out API by the XML
 >guru Elliotte Rusty Harold.
 >http://www.cafeconleche.org/XOM/
 >http://www.cafeconleche.org/XOM/designprinciples.xhtml
 >
 >In fact, if you are using XHTML, you could use XOM, albeit not with the
 >normal HTML or XHTML DOM API's specific to HTML/XHTML
 >elements.  Additionally, once you create the document using XOM, you can
 >use the XOM to DOM converter to get a document compatible with DOM parsers.
 >
 >If you have an existing document to reference, you can create a new empty
 >one by....
 >
 >
 >DOMImplementation domImpl = document.getImplementation();
 >
 >//HTML DOM doesn't store doctype, so check for that when figuring out the
 >document element
 >String documentElement = document.getDocType() != null ?
 >document.getDoctype().getName() : "html";
 >
 >DocumentType docType = document.getDocType() != null ?
 >domImpl.createDocumentType(documentElement,
 >document.getDoctype().getPublicId(), document.getDoctype().getSystemId()) :
 >null;
 >
 >String namespaceURI = document.getDocType() != null ?
 >"http://some/uri/location/if/necesssary" : "";
 >
 >//Of course, you can cast Document to whatever sub-Document interface you
 >think the document is
 >Document doc = domImpl.createDocument(namespaceURI, documentElement, 
docType);
 >
 >
 >Otherwise, look at the JAXP or DOM3 bootstrapping with
 >DOMImplementationRegistry
 >
 >
 >Jake
 >
 >At 04:22 PM 3/29/2005 -0800, you wrote:
 > >Perhaps a lightweight easy-to-use DOM framework like dom4j is what
 > >you're looking for.
 > >I used it today to throw together a fast web service that serves up an
 > >xml document.
 > >
 > >-Justin
 > >
 > >
 > >On Tue, 29 Mar 2005 13:22:43 -0800, Matthew Hixson
 > ><[email protected]> wrote:
 > >> On Mar 29, 2005, at 1:02 PM, Jacob Kjome wrote:
 > >>
 > >> >
 > >> > Maybe I'm missing something, but you could create an empty document
 > >> > via the DOM
 > >> > and append any elements you want to it.
 > >>
 > >> Are there any examples on how to do this?
 > >>
 > >> > Then, as you say, do a view-source,
 > >> > copy that to an HTML document, and then compile that with XMLC.  Keep
 > >> > in mind
 > >> > what XMLC is all about.  It gives you the ability to have compile-time
 > >> > bindings
 > >> > to your document.  If you don't require that, then XMLC becomes less
 > >> > useful and
 > >> > the basic DOM is all you need.
 > >>
 > >> Yes, I know.  What I've started to notice is that some servlets,
 > >> especially if they're just a proof of concept or rough prototype, don't
 > >> have that requirement to start with.  The requirement is more along the
 > >> lines of "determine whether or not Foo will work."  At some point after
 > >> the early development phases have been completed the requirement of
 > >> compile time binding to an HTML file usually manifests itself, but not
 > >> always.  In the cases where that requirement never arises I can save
 > >> myself the hassle of creating the .html file and the ongoing HTML
 > >> recompilation.
 > >>    -M@
 > >>
 > >>
 > >> > Quoting Matthew Hixson <[email protected]>:
 > >> >
 > >> >> Does anyone have a way of just creating an XHTML document using XMLC
 > >> >> without having to compile an .html file?  What I'd like to do is
 > >> >> programatically put together a page like so:
 > >> >>
 > >> >> XHTMLTableCellElement cell = factory.createTableCell();
 > >> >> XHTMLTableRowElement row = factory.createTableRow();
 > >> >> row.append(cell);
 > >> >> XHTMLTableElement table = factory.createTable();
 > >> >> table.append(row);
 > >> >> HTMLObject page = factory.createHTMLObject();
 > >> >> page.append(table);
 > >> >>
 > >> >> Is there a way to do this with XMLC currently?  If not, I wonder if it
 > >> >> would work to create an HTML page with every HTML component in it,
 > >> >> compile that into a massive XMLC object, and use it as a factory by
 > >> >> importing the nodes you want from it.
 > >> >>    The reason I'd like to do this is that I think it would reduce the
 > >> >> prototyping stages of a lot of web development I do because it would
 > >> >> eliminate the need to create an HTML file and compile it every time I
 > >> >> make a change to it.  I go through this prototyping stage of
 > >> >> development quite a few times before getting the HTML the way I want
 > >> >> it
 > >> >> and going to the effort of making it look good.
 > >> >>    If I were to do this I could then just view the source in my
 > >> >> browser
 > >> >> and save it as an .html file and add the id attributes where they're
 > >> >> needed.  Yes, I'd have to change my code to get the XHTML components
 > >> >> from the compiled HTML, but I think this would be worth it.
 > >> >>    Thoughts?
 > >> >>     -M@
 > >> >>
 > >> >>
 > >> >>
 > >> >
 > >> >
 > >> >
 > >> >
 > >> >
 > >> > --
 > >> > You receive this message as a subscriber of the [email protected]
 > >> > mailing list.
 > >> > To unsubscribe: mailto:[email protected]
 > >> > For general help: mailto:[email protected]?subject=help
 > >> > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
 > >>
 > >>
 > >>
 > >> --
 > >> You receive this message as a subscriber of the [email protected] 
mailing
 > >list.
 > >> To unsubscribe: mailto:[email protected]
 > >> For general help: mailto:[email protected]?subject=help
 > >> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
 > >>
 > >>
 > >>
 > >
 > >
 > >--
 > >You receive this message as a subscriber of the [email protected] mailing
 > >list.
 > >To unsubscribe: mailto:[email protected]
 > >For general help: mailto:[email protected]?subject=help
 > >ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
 >
 >
 >
 >
 >--
 >You receive this message as a subscriber of the [email protected] mailing
 >list.
 >To unsubscribe: mailto:[email protected]
 >For general help: mailto:[email protected]?subject=help
 >ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
message.footer (text/plain, 269 B)
--
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws