Hi, I'm here again!
For example.
The XML page
<?xml version="1.0"?>
<DATA>
<NAMES>
<NAME>Name1</NAME>
<NAME>Name2</NAME>
<NAME>Name3</NAME>
<NAME>Name4</NAME>
<NAME>Name5</NAME>
<NAME>Name6</NAME>
</NAMES>
<DATES>
<DATE>Date1</DATE>
<DATE>Date2</DATE>
<DATE>Date3</DATE>
<DATE>Date4</DATE>
<DATE>Date5</DATE>
<DATE>Date6</DATE>
</DATES>
</DATA>
The XSL page
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="2" bgcolor="yellow">
<xsl:for-each select="DATA/NAMES/NAME" order-by="+ NAME">
<tr>
<td><xsl:value-of select="NAME"/></td>
</tr>
</xsl:for-each>
</table>
<table border="2" bgcolor="blue">
<xsl:for-each select="DATA/NAMES/DATE" order-by="+ DATE">
<tr>
<td><xsl:value-of select="DATE"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Then you have to applay the xsl style page to the XML page
The java code
//Probably you need these imports
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*;
[....................]
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
try {
File stylesheet = new File("MyXMLFile");
File datafile = new File("MyXSLFIle");
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(datafile);
// Use a Transformer for output
TransformerFactory tFactory = TransformerFactory.newInstance();
StreamSource stylesource = new StreamSource(stylesheet);
Transformer transformer = tFactory.newTransformer(stylesource);
DOMSource source = new DOMSource(document);
//Binds the standar out stream as stream result
StreamResult result = new StreamResult(System.out);
transformer.transform(source, result);
} catch (Exception exc) {
System.out.println ("ERROR");
}
//regards
-----Mensaje original-----
De: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]En nombre de
Goulas, Theodor
Enviado el: jueves, 23 de agosto de 2001 15:21
Para: [EMAIL PROTECTED]
Asunto: Re: Preventing Servlet perform some action. Advice needed!
Hi Alberto,
> I will try to send you an example tomorrow if you want. I've just finished
> for today!
That would be nice. Thank you! I have a solution with html but your solution
is
very interesting and more elegant.
I'll wait thank you again.
See you
-Theo
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html