You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mark Johnson <ma...@onfiber.com> on 2002/02/21 21:17:39 UTC

Fumbling around Tomcat and Java and XML

ENV: Linux 2.4, tomcat-4.0.1, JDK1.3.1

I have just inherited a servlet project that uses tomcat running on Linux.
I'm not a java programmer so I'm fumbling around trying to learn java and
tomcat and everything else that's involved simultaneously.  

I need to add the ability to parse an XML document but have not been
successful at getting to the right jar files.  What import directive do I
need to use in my servlet to get access to the DOM parsers available in the
tomcat xerces.jar, or what environment settings do I need to check for
correctness.

I tried "import javax.xml.*;" which said that I had no such javax.xml does
not exist, I tried "import org.w3c.dom.*;" and the same general error.  I
have been browsing the sun java site for a day now and can't figure out
where to download the javax XML stuff. I found the xerces xml files but it
complains about the w3c stuff.  I downloaded the w3c stuff but, can't get it
to compile.  I'm striking out on all fronts. I noticed that tomcat already
has a xerces.jar but I don't know how to get to it or what my environment
variables should be setup as and if it's still going to complain about the
w3c stuff...

Does the tomcat XML parsing stuff work out of the box or do I need to do
download more software.  From what I've read so far, Sun only provides an
interface which must be coupled to a specific vendor's implementation.  I
assume that is what xerces is -- the actual implementation based on the Sun
interface.  But I don't know if everything is all there with a vanilla
installation of the jdk and tomcat. Is there a way to find out?

Thanks for any direction you can give me here.  I can't see to find the
correct document to read so if you can send me a URL to the any documents
that tell me how to set this up that would be great. It can't be this hard I
must be just not understanding something trivial...

thanks for your time...

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


RE: Fumbling around Tomcat and Java and XML

Posted by Tom Parker <to...@econz.co.nz>.
> I need to add the ability to parse an XML document but have not been
> successful at getting to the right jar files.  What import directive do I
> need to use in my servlet to get access to the DOM parsers
> available in the
> tomcat xerces.jar, or what environment settings do I need to check for
> correctness.

Have a look at the documentation for xalan at http://xml.apache.org this
includes examples and javadocs which will tell you everything you need to
know.


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


RE: Fumbling around Tomcat and Java and XML

Posted by Jim Urban <ji...@netsteps.net>.
Here is a hint to get you started...

import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.apache.xerces.parsers.DOMParser;


	DOMParser parser = new DOMParser();
	parser.parse("your.xml");
	Document document = parser.getDocument();
	NodeList elements = document.getElementsByTagName("your-element-tag");
	int elementCount = elements.getLength();
	for (int i = 0; i < elementCount; i++){
		Element element 	= (Element) elements.item(i);
...

> -----Original Message-----
> From: Mark Johnson [mailto:mark.johnson@onfiber.com]
> Sent: Thursday, February 21, 2002 2:18 PM
> To: 'Tomcat User List (E-mail)'
> Subject: Fumbling around Tomcat and Java and XML
>
>
> ENV: Linux 2.4, tomcat-4.0.1, JDK1.3.1
>
> I have just inherited a servlet project that uses tomcat running on Linux.
> I'm not a java programmer so I'm fumbling around trying to learn java and
> tomcat and everything else that's involved simultaneously.
>
> I need to add the ability to parse an XML document but have not been
> successful at getting to the right jar files.  What import directive do I
> need to use in my servlet to get access to the DOM parsers
> available in the
> tomcat xerces.jar, or what environment settings do I need to check for
> correctness.
>
> I tried "import javax.xml.*;" which said that I had no such javax.xml does
> not exist, I tried "import org.w3c.dom.*;" and the same general error.  I
> have been browsing the sun java site for a day now and can't figure out
> where to download the javax XML stuff. I found the xerces xml files but it
> complains about the w3c stuff.  I downloaded the w3c stuff but,
> can't get it
> to compile.  I'm striking out on all fronts. I noticed that tomcat already
> has a xerces.jar but I don't know how to get to it or what my environment
> variables should be setup as and if it's still going to complain about the
> w3c stuff...
>
> Does the tomcat XML parsing stuff work out of the box or do I need to do
> download more software.  From what I've read so far, Sun only provides an
> interface which must be coupled to a specific vendor's implementation.  I
> assume that is what xerces is -- the actual implementation based
> on the Sun
> interface.  But I don't know if everything is all there with a vanilla
> installation of the jdk and tomcat. Is there a way to find out?
>
> Thanks for any direction you can give me here.  I can't see to find the
> correct document to read so if you can send me a URL to the any documents
> that tell me how to set this up that would be great. It can't be
> this hard I
> must be just not understanding something trivial...
>
> thanks for your time...
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>