Using Java XML API

September 1, 2008

Post has been moved to our New Blog. http://blog.webscale.co.in/?p=51

Entry Filed under: Basic. Tags: .

4 Comments Add your own

  • 1. Christopher Sahnwaldt  |  September 2, 2008 at 6:01 pm

    To parse HTML that may not be well-formed XML, try http://htmlcleaner.sourceforge.net

    Reply
  • 2. fazalgupta  |  November 6, 2008 at 6:52 am

    One interesting thing i found with html output method was the issue with self closing tags. E.g. for a tag like which is a self closing tag, trying to generate the HTML String using html output method leaves such tags open breaking the actual well formed structure. I am not sure if this is a reported bug in Xalan but I am still figuring out why this happens.

    Also as such Outputkeys Class the method parameter documentation states that xhtml can be used as a method if implemented by spefic providers. Following is the java doc

    Other non-namespaced values may be used, such as “xhtml”, but, if accepted, the handling of such values is implementation defined. If any of the method values are not accepted and are not namespace qualified, then {@link javax.xml.transform.Transformer#setOutputProperty}
    or {@link javax.xml.transform.Transformer#setOutputProperties} will
    throw a {@link java.lang.IllegalArgumentException}.

    But when I tried this with Xalan, the xhtml output method though not supported (checked by debugging in the code), it never throws an exception..

    I think the people implementing XML APIs need to become more consistent to make life easier for people like us.

    In this context comment given by Christopher Sahnwaldt is relevant as we may need to make well formed the html string generated.

    Reply
  • 3. Toan.Vu  |  July 16, 2009 at 4:29 am

    You add
    at the top of html page.

    Reply
  • 4. Matt McGinty  |  August 11, 2009 at 4:12 pm

    Thanks for the information.
    But I don’t quite follow your example code which includes doc1Node and doc2Node.
    It does not actually make use of doc2Node.
    So I’m not sure that it would work as written.

    I am currently dealing with the “WRONG_DOCUMENT_ERR” issue using Xalan 2.7.1 so could you please clarify the sample code?

    Thanks.

    Matt

    Reply

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


New Blog

We Have moved to http://blog.webscale.co.in

Blog Stats

Top Posts

Feeds