[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]


  • From: "Thomas B. Passin" <tpassin@m...>
  • To: "XML-DEV LIST" <xml-dev@i...>
  • Date: Wed, 3 Nov 1999 11:02:32 -0500

servelet for xml

From: Anton Schoultz - ePOS <antons@e...>

>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">
> <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>
>Let's say we have a DTD available on the web server
>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
><?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>
>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@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo@i... the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.