xml to html

M

Mitch

Hi,

I'm looking for a way to take an xml file and automatically (no human
intervention) create an .html file. I see serveral ways that might
work, but none that exactly meet my needs. The .xml only contains
part of the data so formatting the .xml is not really what I want.

Given that I'm a newbie, excuse any syntax errors.

For example:

<xml>
<record>
<key>bob</key>
<data1>data11</data1>
<data2>data12</data2>
</record>
<record>
<key>key2</key>
<data1>data21</data1>
<data2>data22</data2>
</record>
</xml>

But the .html contains the rest of the page, formatting, additional
data and a key that indicates which data from the xml should be
used.

<html>
....
Some things to know about Bob is, <key=bob, value=data1> and <key=bob,
value=data2>.

which would somehow substitute the values data11 and data12 by keyed
lookup.

What are the best techniques to do this? CSS seems to be about
formatting as well as every other technique I've seen.

thx.
 
A

Armel

Mitch said:
Hi,

I'm looking for a way to take an xml file and automatically (no human
intervention) create an .html file. I see serveral ways that might
work, but none that exactly meet my needs. The .xml only contains
part of the data so formatting the .xml is not really what I want.
[..]
What are the best techniques to do this? CSS seems to be about
formatting as well as every other technique I've seen.
XSLT is probably what you are searching for (you can access data from
several documents: through 'document( )' function, and replacing your 'place
holder', is easy you need to use your tag/element <place-holder/> and match
it with a 'xsl:template').
take some time to read some XSL tutorial and all of that will be clear :)

HIH
Armel
 
P

Peter Flynn

C. M. Sperberg-McQueen wrote:
[...]
CSS is indeed focused on attaching formatting properties to an
existing tree of data, not to transforming that tree or reflecting
data from one place to another. This makes CSS simpler to process,
in some ways, than languages like XSLT, which can perform arbitrary
transformations on data.

One other thing to be aware of is that CSS is unevenly supported by web
browsers, so many things which you might expect to work, won't.

///Peter
 
J

John Redmond

Mitch:

I sympathise with what you are trying to do, but you have to make a
basic decision about what sort of XML file you are setting up in the
first place, in particular:

1. Which tags you are using? XHTML tags are the most obvious;
2. Whether you are structuring your XML in the same way as in XHTML. The
ORDER is the real issue.

If you satisfy these two requirements, I can help you to do it very
easily. Look at my website at www.limpidsoft.com and more particularly
www.limpidsoft.com/lexxia.

But there is a number 3: Lexxia is not yet ready for Windows. For Linux,
I updated the site only yesterday -- and it is ready to go.

Final words: if you cannot satisfy 1. and 2., you really DO need XSLT.
Lexxia helps there, too, and makes it easy to write stylesheets. AND,
believe it or not, Lexxia makes it even easier to build LaTeX and PDF
(see www.limpidsoft.com/latex). And, of course, it's free.

I hope this helps.

John Redmond
Sydney, Australia.
 
J

John Redmond

Mitch:

I sympathise with what you are trying to do, but you have to make a basic
decision about what sort of XML file you are setting up in the first place,
in particular:

1. Which tags you are using? XHTML tags are the most obvious;
2. Whether you are structuring your XML in the same way as in XHTML. The
ORDER is the real issue. From your example, it appears that you have
a
database-like XML source. In that event, you would have to use inline XSLT,
whether it is in Lexxia or anywhere else.

[There is a bizarre twist, though: you CAN wrap any old (valid) XML
document
into XHTML, and you will see every bit of text in a browser, but there
will,
of course, be no formatting. If, however, you write a CSS stylesheet for
each
of your tags, it looks surprisingly good. It allows you to suppress
specific
tags, but no change in sequence. It's all bound to be browser-dependent,
though.]

If you satisfy these two requirements, I can help you to do it very easily.
Look at my website at www.limpidsoft.com and more particularly
www.limpidsoft.com/lexxia.

But there is a number 3: Lexxia is not yet ready for Windows. For Linux, I
updated the site only yesterday -- and it is ready to go.

Final words: if you cannot satisfy 1. and 2., you really DO need XSLT to
do
it cleanly. Lexxia helps there, too, and makes it easy to write
stylesheets.
AND, believe it or not, Lexxia makes it even easier to build LaTeX and PDF
(see www.limpidsoft.com/latex). And, of course, it's free.

I hope this helps.

John Redmond
Sydney, Australia.
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top