Forum OpenACS Q&A: ANN: XSLT support added to AOLServer/nsxml

I've added XSLT support to nsxml module. All information is available here: http://acs- misc.sourceforge.net/wiki/index.php?XsltSupportForAolserver

I'll maintain nsxml module so if you have bugfixes, send them to me.

ACS 5 will be XML/XSLT based. This module hopefull will open the door to borrowing good ideas from ACS/Java 5 camp.

Awesome, Yon. Thanks.
Collapse
Posted by Steven Pulito on
Awesome indeed, I second the thanks. I've already begun to use it and it looks like xml/xslt, at least for my purposes, might be able to replace the aD templating system.

I have one question regarding the use of the module.

Is it possible to use the <xsl:include> and <xsl:import> tags with the parser?

Currently I'm

  1. parsing my xml
  2. parsing my xsl (which has an include tag)
  3. applying the xsl to the xml
  4. rendering the resulting document and returning it
It fails to produce the correct output when I use the include, but works fine if I insert the text of the second xsl file directly.

Any ideas?

Collapse
Posted by Yon Derek on
Try xsltproc (part of libxslt distro) and see what it does. If it works and ns_xml doesn't then my code could use improvement in which case send me example files and I'll try to dig in.

If it doesn't then it means that it hasn't been implemented in libxslt itself (which is still in heavy developement stage). For info on libxslt you should go to http://xmlsoft.org/XSLT/. If you have questions about how it works your best bet is to ask on their mailing list. ns_xml is just a wrapper.

Collapse
Posted by Steven Pulito on
I beleive the issue is with the way ns_xml handles the processing.

I have tested with xsltproc and I get the correct output, however when I try to do the same in AOLserver it behaves as if xsltproc would if it failed to retrieve the stylesheet.

I'm going to email Yon the test files, but if anyone else has any ideas I can email the files to them.

Collapse
Posted by Yon Derek on
FYI: Steven sent me his examples and they both worked correctly on my machine so my conclusion is that the problem is specific to Steven's setup (other libxsltlibxml versions?), not ns_xml itself.
Collapse
Posted by Steven Pulito on
Yon - thanks for the taking the effort to look into this.

Your results intrigued me, so I did some more testing on my side.

For reference I have a linux and a solaris system. I originally encountered the problem on solaris. I have libxml 2.3.11 and libxslt 0.12.0 installed on both systems. I installed on both platforms via:

  • ./configure
  • make
  • make install
with no switches.

I will include the test files I used in the following messages.

When I run:
xsltproc people.xsl people.xml
on either platform libxslt goes out and retrieves the imported stylesheet and generates the correct output. However when I try to do the same thing from within AOLserver it works on Linux.

However on the solaris box I get the same output I would have gotten if libxslt failed to find the stylesheet.

Any ideas?

Thanks,
Steve

Collapse
8: people.xsl (response to 1)
Posted by Steven Pulito on

people.xsl

<?xml version="1.0"?>
<!-- RETURN_TYPE:text/html -->
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:saxon="http://icl.com/saxon" 
  exclude-result-prefixes="saxon" 
  version="1.0">

<xsl:import href="http://www.seas.upenn.edu/~stevenp/people_include.xsl"/>
</xsl:transform>

Collapse
9: people.xml (response to 1)
Posted by Steven Pulito on

people.xml

<?xml version="1.0" ?> 
<!-- REQUEST:0 -->
<PEOPLE> 
<PERSON> 
<NAME>Mark Wilson</NAME> 
<ADDRESS>911 Somewhere Circle, Canberra, Australia</ADDRESS> 
<TEL>(++612) 12345</TEL> 
<FAX>(++612) 12345</FAX> 
<EMAIL>Mark.Wilson@somewhere.com</EMAIL> 
</PERSON> 
<PERSON> 
<NAME>Tracey Wilson</NAME> 
<ADDRESS>121 Zootle Road, Cape Town, South Africa</ADDRESS> 
<TEL>(++2721) 531 9090</TEL> 
<FAX>(++2721) 531 9090</FAX> 
<EMAIL>Tracey.Wilson@somewhere.com</EMAIL> 
</PERSON> 
<PERSON> 
<NAME>Jodie Foster</NAME> 
<ADDRESS>30 Animal Road, New York, USA</ADDRESS> 
<TEL>(++1) 3000 12345</TEL> 
<FAX>(++1) 3000 12345</FAX> 
<EMAIL>Jodie.Foster@somewhere.com</EMAIL> 
</PERSON> 
<PERSON> 
<NAME>Lorrin Maughan</NAME> 
<ADDRESS>1143 Winners Lane, London, UK</ADDRESS> 
<TEL>(++94) 17 12345</TEL> 
<FAX>(++94) 17 12345</FAX> 
<EMAIL>Lorrin.Maughan@somewhere.com</EMAIL> 
</PERSON> 
<PERSON> 
<NAME>Steve Rachel</NAME> 
<ADDRESS>90210 Beverly Hills, California, USA</ADDRESS> 
<TEL>(++1) 2000 12345</TEL> 
<FAX>(++1) 2000 12345</FAX> 
<EMAIL>Steve.Rachel@somewhere.com</EMAIL> 
</PERSON> 
</PEOPLE>
Collapse
10: people_include.xsl (response to 1)
Posted by Steven Pulito on

people_include.xsl

<?xml version="1.0"?>
<!-- RETURN_TYPE:text/html -->
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               xmlns:saxon="http://icl.com/saxon"
               exclude-result-prefixes="saxon"
               version="1.0">
<xsl:template match="/">
<HTML>
<BODY>
<TABLE BORDER="2">
        <TR>
                <TD>Name</TD>
                <TD>Address</TD>
                <TD>Tel</TD>
                <TD>Fax</TD>
                <TD>Email</TD>
        </TR>
        <xsl:for-each select="PEOPLE/PERSON">
        <TR>
                <TD><xsl:value-of select="NAME"/></TD>
                <TD><xsl:value-of select="ADDRESS"/></TD>
                <TD><xsl:value-of select="TEL"/></TD>
                <TD><xsl:value-of select="FAX"/></TD>
                <TD><xsl:value-of select="EMAIL"/></TD>
        </TR>
        </xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:transform>
Collapse
Posted by C. R. Oldham on
Yon Derek:
ACS 5 will be XML/XSLT based.

Steven Pulito:
xml/xslt, at least for my purposes, might be able to replace the aD templating system

Yon and Steven, would you be willing to discuss these statements a little bit? I'm having a hard time wrapping my head around these concepts. As we are in the design phase of some new web applications, I'd like to try for an XML/XSL/XSLT approach if I can, but one of the things I like about the aD templating system is that I have a ghost of a chance to teach my HTML people how to use the tags. XSLT looks so *complicated*...am I missing something?

OTOH, it looks like there will be lots of tools for supporting XML+XSLT...

--cro

The general architecture of the ACS5 presentation system is that all pages are first produced in an intermediate XML representation which is transformed to HTML using XSLT. This makes the 'templating' system very powerful, thanks to the formating powers of XSLT.

The downside is that most HTML designers get a bit pale when you show them an XSL stylesheet for the first time. We are well aware of that problem and are working on a JSP based system that simplifies the writing of XSL stylesheets considerably, so that the styling feels more natural to a designer that is used to the imperative nature of most templating systems like ATS.

For more information on how ACS is going to use XML/XSLT you should check out the documentation on the ACS5 Presentation System, in particular Bill Schneider's excellent introuction on XML and XSLT in the ACS.

And, as always, you should post any feedback, comments, questions or criticism to the ACS Core Platform bboard, where most of the ACS5 development discussion takes place.

http://acs-misc.sourceforge.net/wiki/index.php?XsltSupportForAolserver doesn't exist. Actually the acs-misc wiki seems to be a blank slate. Has the documentation for XSLT via ns_xml moved?
Collapse
Posted by Yon Derek on
Sorry about that. It looks like the wiki destroyed itself. I'm not kidding, the damn thing just re-installed itself and erased all the pages I've created.

Note to self: don't use PhpWiki in the feature.

Unfortunately everything (including xslt support) that was made through wiki is gone but most of it is in this article anyway: http://www.fifthgate.org/articles/aolserver/xml/ns_xml_doc.html