• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

guestbook as an example

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more thing I want to tell I am using jsp and servlet for inserting username,subject,message.
payal sharma
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic