You'll probably get lots of replies on this, and I'm no XSLT guru by any means,
but I have some words.

1. When you write your XSLT sheets, you can specify a few output helper methods:

 <xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>


2. You determine in your XSLT what rules and replacements happen to the input
data.  If you input XML and you want to output HTML or WML or Java (BTW, this is
how JRun creates servlets from JSPs: JSP parsed to-->XML-->apply XSLT--> get
Java) or whatever, you match up expected input XML elements in your XSLT, and
specify template data that you want to replace the XML element (at least this is
the easy way to do it):

Here's a section of XSLT where I am matching against incoming RSS XML elements
(<channel>, <title>, and <item>) and outputting an HTML table of that data:

<xsl:template match="channel">

  <table border="1" cellpadding="2" cellspacing="0">
    <tr bgcolor="#aa0000">
      <td>
        <b>
          <font size="+1" color="#ffffff">
            <xsl:value-of select="title"/>
          </font>
        </b>
      </td>
    </tr>

    <tr>
     <td>
        <xsl:apply-templates select="item"/>
      </td>
    </tr>
  </table>
</xsl:template>

Usually you use these XSLT engines by instantiating an instance of the engine or
an interface to it, and passing XML, XSL, and an instance of an OutputStream to
one or many constructors/methods.  The engine takes the two input sources, does
its magic, and spits out the output to the out stream of your choice.

I used Xerces to write a custom tag for a JSP book I co-wrote that's coming out
in a month or so.  The tag looks like this on a JSP, for example:

<synd:rdf rdfURL="http://www.slashdot.org/slashdot.rdf"
          xslURI="xml/rdf092.xsl"/>

It's slowed by the initial request for the RDF page, but if you have all your
XML and XSL local or in a database, this stuff goes much quicker (but doing
syndication will always require someone/something to hit the Web for updates).
The code is very simple and just uses the Xerces APIs to do the processing.

You could also include the dynamic XML output of one JSP into another JSP or
servlet, which could then call XSLT engine APIs and a stylesheet to convert the
XML to another type of data.

My main beef about Xerces is that it's 1.5 MB.  That's way too big if all you
want is a fast, light XSLT engine.  But its' free and it's got features and it
works well and its very easy to use.  James Clark has a lightweight XSLT
processor:

http://jclark.com/xml/xt.html

Here are some other pointers:

Producing HTML tables with XSLT
http://www.cogsci.ed.ac.uk/~dmck/xslt-tutorial.html

List of Books, articles and papers:
http://www.oasis-open.org/cover/xsl.html#articles

See in particular the free online stuff from the "XSLT Programmer's Reference,"
By Michael Kay.  Lots of free code and examples you can download.  I've also
found the Cocoon XSL examples from xml.apache.org to be helpful.

Scott Stirling
West Newton, MA


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Duffey, Kevin
Sent: Wednesday, October 11, 2000 3:57 PM
To: Orion-Interest
Subject: RE: XSLT processors


I would be interested in knowing how to even use an XSLT engine! I know I can
get JSP to output XML with a header, but how do I actually pass the XML to the
XSLT engine, and how do I specify I want HTML or WML output? Is it a servlet,
and you just call upon it somehow from a JSP page or when a request is made,
inside you grab the page using a URL connection to get XML output from the JSP
page, then pass it on to an XSLT engine somehow? I guess I should buy a book on
this topic..but I was hoping it would be easy enough to figure out.

Thanks.



Reply via email to