Forum Moderators: phranque

Message Too Old, No Replies

Wading in the jungle of XSL and Apache

         

FransE

4:46 pm on Jun 30, 2004 (gmt 0)

10+ Year Member




Hello all,

On my web site I have XML files with the following declarations:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="kua.xsl"?>
<kua xmlns:xsi="http.//www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="kua.xsd">

The XSL sheet(kua.xsl) is in the same directory as the xml file.
The problem is the stylesheet is not invoked and the plain XML file is returned. What I want, obviously, is the xml file to be parsed and the generated content(html) to instead be sent to the client.

Why does this not work?

1. Is the XML declaration somehow wrong?
2. What special modules/apache-settings/whatever do I need to make XSL parsing work, if it's not supported by default?
3. If the XSL file have errors, could that be the cause? (it's at least well-formed)

Any suggestions, hints to documentation, is highly appreciated.

Cheers,

Frans

gergoe

7:45 pm on Jun 30, 2004 (gmt 0)

10+ Year Member



The reason why the xml file is not being parsed with the stylesheet might be that you don't have any xml parser installed on your machine, or your browser does not support it.
With Apache only it is not possible to make xml translation on the server side, you need to invoke php at least, or any other server-sided scripting language. If you're familiar with php, then check out the xslt functions [php.net] which does what you want. Once you have some xml-xslt compiler on your server, then either use that script by using the query-string, or together with mod_rewrite you can make the translation transparent to the browser.

About your questions
1.) It seems to be correct, what you can try is to define a fully qualified url for the href attribute, like [domain.com...]
2.) No, there's no support in Apache (and I think none of the current webservers does it) for server-sided xml translations, but you can make your own engine quite easily - as I explained it above
3.) If the xsl file is not well formed, then the parser would give you an error, but if you made other faults in the code (typo in the element names for example, or wrong element names on the wrong places etc), then it will just won't work, but still, in that case you can see the difference, because if an element does not have a corresponding <template match="element_name"/> in the xsl file, then the built-in templates are used, which simply prints the *content* of the element, for example in the case of the following:


<myelement something="anything">test</myelement>

...only the "test" text will be displayed.