A HTML document into a XHTML document(wap2.0 mobile profile)

Mike (6)

Usenet Archive
Joined
Apr 27, 2004
Messages
61
Reaction score
0
regards:

Is it possible to use java XML api to translate
a HTML document into a XHTML document(mobile profile)

thank you
best wishes
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
mike said:
Is it possible to use java XML api to translate
a HTML document into a XHTML document(mobile profile)

I have recently read an announcement for
http://mercury.ccil.org/~cowan/XML/tagsoup/
I don't have any experience with that software myself but if it works as announced then you can use a SAX API to parse HTML tagsoup and then use SAX events to produce the desired output. There is also TSaxon named on that page as part of the package that allows you to transform HTML to XML so all you would need is to write an XSLT 1.0 stylesheet transforming the HTML as needed to XHTML.
 

Joris Gillis

Usenet Archive
Joined
Sep 28, 2004
Messages
355
Reaction score
0
Yes, but the easiest way to do it is probably via XSLT.

I would rather say it is impossible with XSLT.
Html is, per definition not an XML language, and thus cannot possibly be transformed with xslt, which requires valid XML input. If the html would be valid XML, you would call it XHTML, not html.

Transformation of XHTML to html is off course possible (but not desirable :)
 

Nick Kew

Usenet Archive
Joined
Jul 21, 2000
Messages
292
Reaction score
0
XSLT is a complex, slow solution. I'd be surprised if it's the easiest way. I'm not up-to-date on JAVA APIs, but with C or C++ it's much easier than that, and I'd expect NekoHTML to offer a good solution in Java.
I would rather say it is impossible with XSLT.
Html is, per definition not an XML language, and thus cannot possibly be transformed with xslt, which requires valid XML input. If the html would

Nonsense. XSLT starts with a DOM tree, which can equally well represent an HTML or an XHTML document. As soon as you've parsed the HTML to DOM, your XSLT parser can pretend it was XML all along (and if you apply the identity transform, you've just converted to XHTML).

But by the time you've generated the DOM, you've already done more work than you needed to. SAX is just as easy.
 

Joris Gillis

Usenet Archive
Joined
Sep 28, 2004
Messages
355
Reaction score
0
Nonsense. XSLT starts with a DOM tree, which can equally well represent an HTML or an XHTML document. As soon as you've parsed the HTML to DOM, your XSLT parser can pretend it was XML all along (and if you apply the identity transform, you've just converted to XHTML).

It seems I've always been terribly mistaking.
The word 'DOM' doesn't even occur in the XSLT 1.0 nor the XSL1.0 specification. But now I found what you're saying is indeed stated (in the XSLT2.0 working draft).

Thanks for the correction
 

Andy Dingley

Usenet Archive
Joined
Feb 23, 2000
Messages
3,303
Reaction score
0
Is it possible to use java XML api to translate
a HTML document into a XHTML document(mobile profile)

No.

You have two problems; translating HTML (not always well-formed XML) into something manageable, then translating this intermediate format to XHTML-MP.

I suggest you download a copy of Tidy (from HTML-Kit), then read the source code and the comments. Converting HTML to XHTML reliably is a hard problem, in the awkward cases.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top