Is the DOM functionality going to be duplicated between OpenXML and
Xerces? Why not just have a single codebase for these things? (Licensing
issues?) Usable HTML parsers are very hard to come by (ICEsoft has the
only one I know of that deals well with bad html) and quite difficult to
implement properly (or so it seems).
court
Assaf Arkin wrote:
> I think it's good enough and certainly seems to be complaint with the
> specs.
>
> arkin
>
> (HTML parser will be coming, just as soon as I finish some DSML stuff)
>
> Court Demas wrote:
> >
> > I've hacked up an implementation of the HTMLDocument.write() and
> > writeln() methods. It's cheese but functional. I'm wondering if it
> > would be interesting to have this added or if somebody is already
> > working on implementing it the Right Way.
> >
> > The idea is to just build up a string of what was written. When the
> > close() method is called the added string is parsed into a DOM
> > document and then the individual nodes of the document
> > (Document.getBody().getChildNodes()) are appended one-by-one to the
> > Document.
> >
> >
> > private PrintWriter m_printWriter;
> > private StringWriter m_stringWriter;
> >
> > public void open()
> > {
> > if( m_printWriter == null )
> > {
> > m_stringWriter = new StringWriter();
> > m_printWriter = new PrintWriter( m_stringWriter );
> > }
> > }
> >
> > public void close()
> > {
> > if( m_stringWriter != null )
> > {
> > // this call does most of the work but is simple - it just
> >
> > // parses the string into a new DOM document and returns
> > the child
> > // elements of the body
> > NodeList newNodes = DOMStuff.createElementsFromText(
> > m_stringWriter.toString() );
> > for( int i=0; i<newNodes.getLength(); i++ )
> > {
> > getBody().appendChild( newNodes.item( i ) );
> > }
> > m_stringWriter = null;
> > m_printWriter = null;
> > }
> > }
> >
> > public void write( String p_text )
> > {
> > m_printWriter.print( p_text );
> > }
> >
> > public void writeln( String p_text )
> > {
> > m_printWriter.println( p_text );
> > }
> >
> >
> > Comments?
> >
> > court
> >