OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: XSL

[ Lists Home | Date Index | Thread Index ]
  • From: "Thomas B. Passin" <tpassin@mitretek.org>
  • To: "XML-DEV LIST" <xml-dev@ic.ac.uk>
  • Date: Wed, 3 Nov 1999 11:02:32 -0500




From: Anton Schoultz - ePOS <antons@epos.co.za>


>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 ?


Why not have the servelet just return the transformed html, as long as you are
running a servelet anyway?

Tom Passin


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@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@ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS