XSL
Lars George
lgeorge at gmx.net
Wed Nov 3 20:33:16 GMT 1999
Hi Anton,
I do the same thing but on the server-side. Have a look at IBM's Alphaworks
site into the source of the XMLEnabler. This is a servlet that does the same
thing. It even gives you a chance to decide which XSL you use for which user
agent (browser). Therefore you can transform your data on the server and
serve it to all available browsers out there just by providing different XSL
stylesheets. I find that rather amazing, and it is simple too!
HTH,
Lars George
Woodgate Research Pty Ltd
Brisbane, Australia
> -----Original Message-----
> From: owner-xml-dev at ic.ac.uk [mailto:owner-xml-dev at ic.ac.uk]On Behalf Of
> Anton Schoultz - ePOS
> Sent: Wednesday, 3 November 1999 21:41
> To: XML-DEV LIST
> Subject: XSL
>
>
> Hi all,
> Yet another idiot question..
> I have found lots of info on XML, and lots on XSL, but very little on
> combining them!
>
> Hypothetical case; let's say that I have a servlet (eg Java) runing which
> accepts an HTTP POST/GET to query a product catalogue. The
> servlet queries a
> database and then generates an XML document such as this..
>
>
> <?xml version="1.0"?>
> <!DOCTYPE ProdList SYSTEM "http://www.acme.com/dtd/ProdList.dtd">
> <ProdList>
> <hdr date="19991201">
> <title>Catalogue as of 1st December</title>
> </hdr>
> <prod code="101" short="keyboard" price="50.00">Qwerky keyboard</prod>
> <prod code="MS1" short="Mouse" price="5.00">Mickey Mouse</prod>
> <prod code="CRT2" short="Monitor" price="100.00">Monitor Lizard</prod>
> </ProdList>
>
>
> Let's say we have a DTD available on the web server
> "www.acme.com/dtd/ProdList.dtd"
> which looks like this..
>
> <!ELEMENT ProdList ( hdr, prod* ) >
> <!-- header specifies effective date -->
> <!ELEMENT hdr ( title? ) >
> <!ATTLIST hdr
> date CDATA #IMPLIED
> >
> <!ELEMENT title (#PCDATA)* >
> <!-- each product has a code, short-descripiton and a price. -->
> <!-- the data holds full description -->
> <!ELEMENT prod (#PCDATA)* >
> <!ATTLIST prod
> code CDATA #REQUIRED
> short CDATA #IMPLIED
> price CDATA #IMPLIED
> >
> >
>
> Let's say that a style sheet is also available on www.acme... to ouput the
> catalogue as an HTML table, looks like this ... (which probably
> has lots of
> errors!)
>
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org.TR/WD-xsl">
> <xsl:template match="/">
> <HTML>
> <HEAD>
> <TITLE>
> <xsl:for-each select="hdr">
> <xsl:value-of select="."/>
> </xsl:for-each>
> </TITLE>
> </HEAD>
> <BODY BGCOLOR="#808080">
> <H1>Product List</H1>
> <TABLE BORDER="1" WIDTH="400">
> <TR>
> <TH>Stock Code</TH>
> <TH>Short Description</TH>
> <TH>Long Description</TH>
> <TH>Unit Price</TH>
> </TR>
> <xsl:for-each select="ProdList/prod">
> <TR>
> <TD> <xsl:value-of select="@code"/> </TD>
> <TD> <xsl:value-of select="@short"/> </TD>
> <TD> <xsl:value-of select="."/> </TD>
> <TD> <xsl:value-of select="@price"/> </TD>
> </TR>
> </xsl:for-each>
> </TABLE>
> </BODY>
> </HTML>
> </xsl:template>
> </xsl:stylesheet>
>
>
>
> How should the servlet change it's ouput (text/xml?) so that the
> browser (eg
> IE5) will pick-up the XSL and format the xml output into the desired HTML
> table ?
> What changes are required to the above files ?
>
> Regards
>
> Anton Schoultz
> e-mail: mailto:antons at ePOS.co.za
> Office: +27 11 807-9400 Ext. 205
>
>
> xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
> Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on
> CD-ROM/ISBN 981-02-3594-1
> To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
> unsubscribe xml-dev
> To subscribe to the digests, mailto:majordomo at ic.ac.uk the
> following message;
> subscribe xml-dev-digest
> List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
>
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev
mailing list