PDA

View Full Version : Problems making "real" XSL stylesheet and some more



mellin
Mar 12th, 2003, 06:40 PM
In my site, i use news system based on SSI, Perl and flat-file databases, also called Content Management System. Anyways, last night i modified all news files to valid xml, every news article is it's own xml file, like this:

---------------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<header>
<topic>Internet Explorer sucks</topic>
<author>Mikko</author>
<date>12.3.2003 08:25</date>
<related>3</related>
<icon>xml-ico.gif</icon>
<data>
News issue dated 12.3 blah blah blah..
</data>
</header>
---------------------------

These xml files are then parsed with Perl, and placed within XHTML 1.1 page, as presented via CSS. They dont have XSL stylesheet, because it was just way too difficult coding one :D I did try like this:

---------------------------
<?xml-stylesheet type="text/xsl" href="xml-topic.xsl"?>
---------------------------

and in the XSL file, using CSS rules like:

---------------------------
<div style="font-size: 12px;color: #666666;">
---------------------------

but only Internet Explorer (6.0) bothered to show my custom styles, Mozilla did nothing as like the much praised Opera 7.

Aaa-nyways, the real problem is that i cannot place HTML elements like A, UL, LI, P or whatever inside the "data" element on the xml file, 'cause the Perl parser goes nuts.

As a solution i coded all HTML elements inside the news files, to look like this, [BR], [A HREF], [P] and so on. Then when visitor requests some topic, those coded elements are decoded back to normal elements.

It's just pretty slow and memory hogging way, makes the server scream more processor cycles, everytime it parses the scripts.

So any suggestions of making my system more "efficient"? I'm out of ideas.

brothercake
Mar 12th, 2003, 09:03 PM
You have your answer right there - XSL is the answer. Don't give up too easily ;)

Your Netscape 7 problem is probably down to your xsl-stylesheet reference - there's actually no such mime-type as "text/xsl" so if you change it to "text/xml" it should work ...

Opera 7 doesn't support client-side XSLT, which is a shame.

But you can do it server-side, so you deliver parsed XHTML directly to the client. What kind of server are you running?

mellin
Mar 13th, 2003, 09:23 AM
The server where my site is located, is Cobalt Cube running Apache.

I didn't know that Opera 7 would not support client-side XSL, shame really when being so good browser in other ways. Then what browsers do support it fully, Mozilla 1.2.1, how about IE 6.0?

So what, headers are wrong? Have to try that, may be an answer.

Yesterday i borrowed two thick XML concentrated books from local library, over 800 pages of stuff. Have to check them out as well.

brothercake
Mar 18th, 2003, 08:07 PM
client-side XML is supported in mozilla and ie6; ie5 has support, but it's implementation is broken (based on a pre-1.0 XML specification, to be fair)

IMO server-side transformation is the way to go for production use; client-side XML to be saved for the future ... and applications for predictable environments .. or if you just don't care about the restricted browser support.

There are numerous ways of doing XSLT on the server. Most of them are based on Xerces or Xalan (XSLT engines which are available variously in Java, Perl, COM, C++, probably others).

They generally use APIs or language extensions to work with - I personally recommend a language extension, since they give you a process opportunity before and after parsing the data (and because the Apache XSL-API I know of uses file-names as pointer variables, which can be restrictive)

If you're hosted, ask your host. If you run your own server, then you'll have to get down and dirty - http://xml.apache.org/ is a good place to start :)