aspose file tools*
The moose likes XML and Related Technologies and the fly likes guestbook as an example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "guestbook as an example" Watch "guestbook as an example" New topic
Author

guestbook as an example

payal sharma
Ranch Hand

Joined: Oct 04, 2000
Posts: 57
Suppose I have xml like this

Then I want to create a xsl which display only subject as hyperlink . when clicked this take the value of that message id and display message.
I am new to xml and I want to know whether I should use xsl or use parser and dom with jsp.
When a new record is entered then it should take the last value of messageID from xml file and and increment it for new one.
It is a type of guestbook.
I have downloaded xerces and running its examples.
But I want to know what I follow to complete this small task.
thanks in advance
payal sharma
payal sharma
Ranch Hand

Joined: Oct 04, 2000
Posts: 57
One more thing I want to tell I am using jsp and servlet for inserting username,subject,message.
payal sharma
Paramagurusamy Balasubramanian
Ranch Hand

Joined: Aug 17, 2001
Posts: 55
dear sharma,
Here i've furnished the sample code to achieve your task.I've done by using wml,jsp and xtags.
In these examples the msg.jsp file would parse the xml file and get the record id of the corresponding subject link..msg1.jsp gets the record id from msg.jsp and display the message..
msg.xml
-------
<?xml version="1.0"?>
<record>
<row>
<user>ajith</user>
<recordid>1</recordid>
<subject>Hello</subject>
<message>Welcome to java ranch</message>
</row>
<row>
<user>Maprapatu</user>
<recordid>2</recordid>
<subject>xml</subject>
<message>Welcome to xml discussion</message>
</row>
</record>
msg.jsp
-------
<%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" prefix="xtags" %>
<%@ page language="java" contentType="text/vnd.wap.wml" %>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>
<card id="card1" title="Products">

<xtags:parse url="http://localhost:8080/shop/msg.xml"/>
<p align="center" mode="nowrap">
Products Display

<table columns="2">
<tr>
<td>User</td>
<td>Subject</td>

</tr>
<xtags:forEach select="//row">
<xtags:variable id="rec_id" select="recordid"/>
<tr>
<td><xtags:valueOf select="user"/></td>
<td><a href="msg1.jsp?recordid=<%=rec_id%>"><xtags:valueOf select="subject"/></a></td>
</tr>
</xtags:forEach>
</table>

</p>
</card>
</wml>
msg1.jsp
--------
<%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" prefix="xtags" %>
<%@ page language="java" contentType="text/vnd.wap.wml" %>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>
<card id="card1" title="Message display">
<%
String recordid=request.getParameter("recordid");
%>
<xtags:parse url="http://localhost:8080/shop/msg.xml"/>
<p align="center" mode="nowrap">
Message Display<br/>
<xtags:forEach select="//row[recordid=$recordid]">
<xtags:valueOf select="message"/>
</xtags:forEach>

</p>
</card>
</wml>

Best Regards,
Parama guru.
payal sharma
Ranch Hand

Joined: Oct 04, 2000
Posts: 57
Thanks Parama guru,
Your code help me lot to use xtags library in my example. In future for learning java and xml what I should learn. These are lot of packages in market as xerces,xalan,dom,jaxp from apache now sun in jdk1.4 beta had included sax and dom library.Where these are best used? Any idea
Payal sharma
Paramagurusamy Balasubramanian
Ranch Hand

Joined: Aug 17, 2001
Posts: 55
Hi,
I heard from sources that in future if the web related technogies boom up then XML will play a main role to accomplish all our tasks.As you know It acts as a layer between our application and the database.To do like this we can avoid network traffic and deal faster.

There are many parsers like xerces,jaxp etc.,available in the market.If we install those plug ins then we can do all necessary operations in our XML document according to our requirement. It all depends on you to use such parsers.

Java programmers may use parsers like jaxp,dom4j etc.,
Taglib programmers may use xtags.

These 3rd party plug in providers are focussing the type of programmers and giving their set of own APIs/packages or taglibs.
So programmers who are specialized in their areas can make use of those respective plug ins.

Best Regards,
Paramaguru
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: guestbook as an example
 
Similar Threads
struts 2.0 iterator
XML -vs- HTML or others
HTML to XML
Read data to the xml file from the database?
Hibernate - Mapping foreign keys tables