JSP and XML

I wish somebody can advice me how to extract data from the elements and attributes in the given xml document which is validated by the following DTD. I read the examples provided by java.sun.com at http://developer.java.sun.com/developer/technicalArticles/xml/WebAppDev2/, but there is no examples to tell how to extract the data from the attributes of each of the elements.
Here is an DTD for the XML Doc:

<!DOCTYPE project [<!ELEMENT project ( command+) > 
<!ATTLIST project name CDATA #REQUIRED > 
<!ELEMENT command ( codeBase?, target*, requestparameter* ) > 
<!ATTLIST command name NMTOKEN #REQUIRED >
<!ELEMENT codeBase ( #PCDATA ) >
<!ELEMENT target ( #PCDATA ) >
<!ATTLIST target name NMTOKEN #REQUIRED >
<!ELEMENT requestparameter ( #PCDATA ) >
<!ATTLIST requestparameter get ( true | false ) #REQUIRED >
<!ATTLIST requestparameter name NMTOKEN #REQUIRED >
<!ATTLIST requestparameter set ( true | false ) #REQUIRED >
<!ELEMENT sessionattribute ( #PCDATA ) > 
<!ATTLIST sessionattribute get ( true | false ) #REQUIRED >
<!ATTLIST sessionattribute name NMTOKEN #REQUIRED >
<!ATTLIST sessionattribute set ( true | false ) #REQUIRED > ]>

Thanks!

Amy01Asked:
Who is Participating?
 
NetminderCommented:
Per request http://www.experts-exchange.com/commspt/Q_20328409.html user resolved the question elsewhere. Points refunded and question closed.

Netminder
CS Moderator
0
 
Amy01Author Commented:
0
 
cheekycjCommented:
I think the URL you have does a good job of explaining the process and has sample code, what more are you looking for?

If you want to sidestep the usage of xsl to display the xml you can just use an xml parser to read the xml file and then display the parsed xml in JSP.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
Amy01Author Commented:
Sorry, this question is waiting to delete before you added your command.
0
 
Amy01Author Commented:
I have changed my previous question, and make it more clear.
0
 
cheekycjCommented:
look at the code on that page that uses the DOMParser, DOM means you have built a tree from the xml document.  you can traverse through the tree and retrieve data.

domstocks.jsp is a good example of how to traverse and display a DOM tree.

CJ
0
 
Amy01Author Commented:
But the domstocks.jsp doesn't extract data from the attributes. Here is an XML example, and I only need to know each element's name(not value) and it's attributes's names and values.
 
<?xml version="1.0"?>
<project name="XML Generator Application">
     <command name="View">
     <codeBase>xmlgenerator.commands.View</codeBase>
     <target name="success">/viewXMLDocument.jsp</target>
     <target name="fail">/viewXMLDocument.jsp</target>
     <requestparameter get="true" set="false" name="userFile">java.lang.String</requestparameter>
     <requestparameter get="true" set="false" name="action">java.lang.String</requestparameter>
     <requestparameter get="true" set="false" name="xmlDocument">java.lang.String</requestparameter>
     <requestparameter get="true" set="false" name="xmlFile">java.lang.String</requestparameter>
     <requestparameter get="false" set="true" name="msg">java.lang.String</requestparameter>
     <requestparameter get="false" set="true" name="viewList">java.util.Vector</requestparameter>
      </command>
</project>
0
 
cheekycjCommented:
I thought the question asker changed the question and was seeking a solution as per their comment on 07/26/2002 01:04PM PST

CJ
0
 
NetminderCommented:
cheekycj,

If you think you've provided a suitable answer here, let me know and I'll make it right for you. I admit, I missed the asker's comment.

Netminder
0
 
cheekycjCommented:
By NO means have I provided a suitable answer yet, but we were working on it :-)

CJ
0
 
NetminderCommented:
Hmmm... well... she asked me to delete it...
0
 
cheekycjCommented:
yeah but then I posted a comment and then she change the question text to start a new thread but lets see what she says and go from there :-)

CJ
0
 
NetminderCommented:
Okay... you have my email address. I can't remember what the point value was here. Send it, and I'll take care of you.

Netminder
0
 
cheekycjCommented:
I wonder if the question asker is getting email notifs of our posts?  There was an old bug that when a question was closed the question asker did not recieve any more notifs.

CJ
0
 
cheekycjCommented:
I wonder if the question asker is getting email notifs of our posts?  There was an old bug that when a question was closed the question asker did not recieve any more notifs.

CJ
0
 
NetminderCommented:
I'm receiving them, so I assume the Asker is.

Netminder
0
 
cheekycjCommented:
I don't think the Asker is receiving the notifs.

CJ
0
 
NetminderCommented:
I'm inclined to agree. Your humble, albeit unquestionably accurate, recommendation, my friend?

N
0
 
cheekycjCommented:
can you email the Asker providing the link to here?  To get her input.

CJ
0
 
NetminderCommented:
CJ,

You have email.

Netminder
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.