Solved

JSP and XML

Posted on 2002-07-26
20
289 Views
Last Modified: 2013-11-19
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!

0
Comment
Question by:Amy01
  • 9
  • 7
  • 4
20 Comments
 

Author Comment

by:Amy01
ID: 7180534
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7180556
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
 

Author Comment

by:Amy01
ID: 7180946
Sorry, this question is waiting to delete before you added your command.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:Amy01
ID: 7180954
I have changed my previous question, and make it more clear.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7181106
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
 

Author Comment

by:Amy01
ID: 7181133
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
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7181642
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
 
LVL 19

Expert Comment

by:cheekycj
ID: 7182548
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
 
LVL 5

Expert Comment

by:Netminder
ID: 7182617
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
 
LVL 19

Expert Comment

by:cheekycj
ID: 7182637
By NO means have I provided a suitable answer yet, but we were working on it :-)

CJ
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7183536
Hmmm... well... she asked me to delete it...
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7184082
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
 
LVL 5

Expert Comment

by:Netminder
ID: 7184100
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
 
LVL 19

Expert Comment

by:cheekycj
ID: 7188055
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
 
LVL 19

Expert Comment

by:cheekycj
ID: 7188056
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
 
LVL 5

Expert Comment

by:Netminder
ID: 7188267
I'm receiving them, so I assume the Asker is.

Netminder
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7196111
I don't think the Asker is receiving the notifs.

CJ
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7196513
I'm inclined to agree. Your humble, albeit unquestionably accurate, recommendation, my friend?

N
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7196613
can you email the Asker providing the link to here?  To get her input.

CJ
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7197454
CJ,

You have email.

Netminder
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xml xsd validation free tool to download 10 85
countXY challenge 28 152
how to extract window origin in spring 2 70
replace quotes with UTF-8 character 38 97
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question