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

M

mike

regards:

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


thank you
best wishes
 
S

Shmuel (Seymour J.) Metz

on 10/13/2004 said:
Is it possible to use java XML api to translate
a HTML document into a XHTML document(mobile profile)

Yes, but the easiest way to do it is probably via XSLT.

--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to (e-mail address removed)
 
M

Martin Honnen

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.
 
J

Joris Gillis

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
:)
 
N

Nick Kew

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.
 
J

Joris Gillis

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
 
A

Andy Dingley

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
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top