Simple (?) question

T

Tony G

Hi -

My experience with XML is limitted although I understand the basics,
and I just recently for the first time created an XML document from a
database query and styled it successfully with CSS.
I have the DTD and the XML included in one document, and the style
sheet is linked to.

(I would cut and paste the text here - but the damn server is down due
to the general incompetence of our network team and I have not backed
the database up locally . . . ).

The XML displays in the browser just fine (much to my delight and
amazement).

So far so good, but I now want to display the styled data in an html
document, and I don't know a simple way to do that. Do I have to write
a DTD that defines both the HTML and the unique XML that I intend to
style??? Can I include two DTD definitions (one for the HTML and one
for the XML) for one document??

It seems like this is doing too much work for such a seemingly common
application. Can someone please help??
 
M

Martin Honnen

Tony said:
So far so good, but I now want to display the styled data in an html
document, and I don't know a simple way to do that. Do I have to write
a DTD that defines both the HTML and the unique XML that I intend to
style??? Can I include two DTD definitions (one for the HTML and one
for the XML) for one document??

To render a HTML document or an XML document the browser needs a
stylesheet but not DTD (well for a HTML document there is not
necessarily a need for a stylesheet at all) so I am not sure why you ask
about the DTD if you want to render your XML data.
As for including the XML data in an HTML document does an HTML iframe
not work for you e.g.
<iframe src="whatever.xml" width="100%" height="300"></iframe>
?

Other approaches are possible but might be browser dependent unless you
solve anything on the server e.g. with ASP or PHP you convert/transform
your XML into some HTML (a list or a table for instance) and simply
include it in the main HTML document which you send to the browser.
 
T

Tony G

Thanks . . .

I just realized that the DTD was redundant w/ CSS styling. But can I
just then eliminate the DTD and put the <?xml version="1.0"
encoding="ISO-8859-1"?> &
<?xml-stylesheet type="text/css" href="stylesheet.css"?> directly into
the <body> of the html document?

(I would have done this by now if the damn server would come up!!!>

Or, without the need for a DTD, is it the opposite? Maybe I can just
put the <html> etc between the <?xml. . . tags.

What is the "normal" practise?

Thx

Tony
 
M

Martin Honnen

Tony G wrote:

I just realized that the DTD was redundant w/ CSS styling. But can I
just then eliminate the DTD and put the <?xml version="1.0"
encoding="ISO-8859-1"?> &
<?xml-stylesheet type="text/css" href="stylesheet.css"?> directly into
the <body> of the html document?

(I would have done this by now if the damn server would come up!!!>

Or, without the need for a DTD, is it the opposite? Maybe I can just
put the <html> etc between the <?xml. . . tags.

As I said your best bet is do use server side processing in the
language/framework of your choice (e.g. ASP or PHP or JSP for instance)
to build a complete HTML document with your XML data transformed and
included as appropriate HTML (e.g. a list or table).
That way you can choose a document type like HTML 4 and a Content-Type
like text/html that is well understood and rendered by older and newer
and potential future browsers whereas rendering of XML styled with CSS
has poor support and any techniques or attempts to combine HTML and XML
have even poorer support.

Unless you only need to support a particular browser like Mozilla for
instance which has good support for XML styled with CSS and support for
compound documents with elements from different namespaces I don't think
there is any way to simply combine your HTML and XML. With Mozilla you
could use an XHTML document served as application/xhtml+xml or
application/xml where you combine XHTML with your XML and use CSS to
style both.
 
R

RC

Tony said:
So far so good, but I now want to display the styled data in an html
document, and I don't know a simple way to do that. Do I have to write
a DTD that defines both the HTML and the unique XML that I intend to
style??? Can I include two DTD definitions (one for the HTML and one
for the XML) for one document??

Not quite understand what you need.

CSS for XML file is


<?xml-stylesheet type="text/css" href="your_filete.css" ?>

CSS for HTML file is

<html><head><title>Your HTML Title</title>

<STYLE TYPE="text/css">
@import url(your_file.css);
</STYLE>

Or

<LINK REL="stylesheet" TYPE="text/css" HREF="your_file.css" />

</head><boby>
....
</body></html>
 

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,999
Messages
2,570,247
Members
46,844
Latest member
JudyGvh32

Latest Threads

Top