Dave is correct. Look under default-web-app/examples/xsl. I have tried the
following:
test.jsp contains much the same as the data.xml example, but of course is a
jsp which produces text/xml output. Servlet chaining sends this to the
XSLservlet.
test.jsp
------------------------------------------------
<%@ page language="java" contentType=text/xml %>
<?xml-stylesheet href="test.xsl" type="text/xsl"?>
<doc>
<heading>
junk
</heading>
<sales>
<division id="North">
<a href="abc.html">abc</a>
<revenue>10</revenue>
<growth>9</growth>
<bonus>7</bonus>
</division>
<division id="South">
<a href="def.html">def</a>
<revenue>4</revenue>
<growth>3</growth>
<bonus>4</bonus>
</division>
<division id="West">
<a href="ghi.html">ghi</a>
<revenue>6</revenue>
<growth>-1.5</growth>
<bonus>2</bonus>
</division>
</sales>
<footing/>
</doc>
------------------------------------------------
the test.xsl is modified from data.xsl:
------------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:include href="heading.xsl"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title>Sales Results by Division</title>
</head>
<body>
<center>
<xsl:apply-templates/>
</center>
</body>
</html>
</xsl:template>
<!--
<xsl:template name="heading" match="heading">
<h1>
<xsl:apply-templates/>
</h1>
</xsl:template>
-->
<xsl:template match="footing">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="sales">
<table border="1">
<tr>
<th>Division</th>
<th>Link</th>
<th>Revenue</th>
<th>Growth</th>
<th>Bonus</th>
</tr>
<xsl:for-each select="division">
<!-- order the result by revenue -->
<xsl:sort select="revenue"
data-type="number"
order="descending"/>
<tr>
<td align="right">
<em><xsl:value-of select="@id"/></em>
</td>
<td align="right">
<xsl:copy-of select="a"/>
</td>
<td align="right">
<xsl:value-of select="revenue"/>
</td>
<td align="right">
<!-- highlight negative growth in red -->
<xsl:if test="growth < 0">
<xsl:attribute name="style">
<xsl:text>color:red</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="growth"/>
</td>
<td align="right">
<xsl:value-of select="bonus"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
------------------------------------------------
I tried to moving the heading template to an 'included' xsl file, but this
does not seem to work. All files are located in the same directory. Am I
missing something?
heading.xsl
------------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:template name="heading" match="heading">
<h1>
Default Page Title
</h1>
</xsl:template>
</xsl:template>
</xsl:stylesheet>
------------------------------------------------
Regards,
Earl
At 10:20 7/19/00 +1000, Dave Smith wrote:
>As I see it (and I haven't tested this) then if you write a jsp or servlet
>that has repsonse type text/xml then it gets chained to the XSL servlet that
>does the transform using the specified stylesheet. This behaviour is defined
>in the global-web-application.xml and should therefore apply to all web
>apps.
>
>An example header in the XML would be
>
><?xml version="1.0"?>
><!DOCTYPE doc SYSTEM "doc.dtd">
><?xml-stylesheet href="doc.xsl" type="text/xsl"?>
>
>so the doc.xsl would be applied to the XML output.
>
>Dave Smith
>Senior Team Leader
>Aristocrat Technologies Australia Pty Ltd
>
>mailto:[EMAIL PROTECTED]
>
>
>-----Original Message-----
>From: Kevin Duffey [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, 19 July 2000 9:09
>To: Orion-Interest
>Subject: RE: how to set up xsl transform
>
>
>Hi,
>
>I too would love to get a simple demo (if its possible) on how to set up an
>XSLT engine, and pass XML + XSL to the engine to get a String of HTML back.
>How exactly does this work, and what engine, servlets, etc are used to do
>it. Lastly..is it really hard to get working or is this a pretty simple
>task?
>
>Thanks.
>
> > How can I setup xsl+xml = html transforming in orion
> > not in the default-web-app directory.
> >
> > Thanks.
> >
> > Jernej
> >
Earl S. Marwil, Ph.D. / Senior Scientist / SCIENTECH, Inc.
____ __o / TEL: (208) 525-3717 / 1690 International Way
____ -\<, .... / FAX: (208) 529-4721 / Idaho Falls, ID 83402
....0/ 0______ / net: [EMAIL PROTECTED]