XML and XHTML

J

Jonas

Which is the difference between XML and XHTML?
Does XHTML could be converted to another format as PDF? Or do I have
to use XML?
 
J

Johannes Koch

Jonas said:
Which is the difference between XML and XHTML?

May I ask you a similar counter question? What is the difference between
an apple and fruit?

XHTML is an XML-based language, a vocabulary that uses XML syntax rules.
Does XHTML could be converted to another format as PDF?

Yes
 
M

Martin Honnen

Jonas said:
Which is the difference between XML and XHTML?

XHTML is an XML application, like for instance MathML or SVG or XSLT or
XSL-FO too. Only XHTML is often served as text/html meaning it is not
processed by an XML parser but by the HTML tag soup parsers browsers have.
 
P

Pavel Lepin

Jonas said:
Which is the difference between XML and XHTML?

As Joseph Kesselman likes to say, XML is almost pure syntax.
Simplifying a bit, XML specifies how to write documents
representing hierarchies, but does not ascribe any specific
semantics to the resulting trees. That is left to the XML
applications--that is, to document formats using XML as a
basis (such as XHTML, RSS, DocBook or XML-RPC).

For example:

<foo>
<bar quux="xyzzy">
Made by Fred
</bar>
</foo>

....is a well-formed XML document describing a tree that
could be visualised as follows:

element foo
|
`-element bar
|
`-attribute quux
| |
| `-attribute value xyzzy
|
`-text Made by Fred

However, XML itself does not specify what all those elements
and attributes are supposed to mean: that is left to the
people who opt to use XML as a basic syntax for their
documents. Continuing with the example, a group of
developers might specify an XML-FOOBAR document format for
describing various foobars in their foobar-processing
software, agreeing that the root element of an XML-FOOBAR
document should always be named 'foo' and should always
contain one and only one element child named 'bar', that
could have an optional quux attribute for describing the
foobar's quuxicity, with allowed attribute values
being 'xyzzy' and 'yzzyx'. The 'bar' element may only have
text nodes as its children that should be treated as
human-readable notes about the foobar being described.

In this case, the document above becomes a valid XML-FOOBAR
document, describing a foobar with xyzzy quuxicity,
seemingly made by someone called Fred.

Now, XHTML is precisely that--an XML application using XML
basic syntax to describe hypertext documents. The XHTML
standard specifies the meanings of the various elements and
attributes, their possible combinations, as well as gives
guidelines to authors of XHTML UA's as to how to convey
those meanings and combinations of meanings to the
end-user.

To give a somewhat strained linguistic analogy, XML is a
language, while XHTML is a set of rules for writing sonnets
in said language.
Does XHTML could be converted to another format as PDF?

Anything could be, I suppose. You might want to read about
XSL-FO. Apache FOP is reportedly a good enough
implementation distributed under Open Source,
GNU-incompatible license.
Or do I have to use XML?

I hope further explanations on why this question doesn't
make much sense as formulated are unnecessary.
 
J

Jonas

I questioned about that because I'm building a blog publishing system
where the blogger can choose the markup language to publish (XHTML 1.0
Strict, XHTML 1.1, etc). Then my idea is save the posts in two
different fields:

* One that can be converted to whatever markup language (XHTML 1.1,
XHTML 1.0, etc), or PDF, or print view.

* The another, where is stores his/her choosen markup language.

So I would to know, which markup language would be best to convert to
another markup formats or PDF?
 
J

Joseph Kesselman

Jonas said:
So I would to know, which markup language would be best to convert to
another markup formats or PDF?

Brief answer: Whichever language(s) come with XSLT stylesheets to render
them into those formats, or into XSL-FO which can be rendered into PDFs
using off-the-shelf tools. Docbook is one obvious possiblity but may be
overkill for your simple blog application.

Longer answer: Generally, abstract/conceptual/semantic languages (those
which describe the content of the document rather than the details of
its formatting) are preferable for this purpose. Letting the stylesheet
deal with applying a consistant rendering avoids digging yourself into a
hole where the details of one rendering get in the way of producing another.
 
J

Jonas

Brief answer: Whichever language(s) come with XSLT stylesheets to render
them into those formats, or into XSL-FO which can be rendered into PDFs
using off-the-shelf tools. Docbook is one obvious possiblity but may be
overkill for your simple blog application.

Longer answer: Generally, abstract/conceptual/semantic languages (those
which describe the content of the document rather than the details of
its formatting) are preferable for this purpose. Letting the stylesheet
deal with applying a consistant rendering avoids digging yourself into a
hole where the details of one rendering get in the way of producing another.

Thanks! I will use reStructuredText
 

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

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top