BTW when parsing documents with DTDs or schemas referenced in them, its
often preferable to give the parser a help by parsing the URL String rather
than giving it an InputStream.

So rather than...

> > >                 InputStream is= new FileInputStream(url);
> > >                 document = reader.read(is);

just do

 document = reader.read(url);

then the parser knows where the document is coming from then it can deduce
relative URLs for DTDs and schemas etc.

James
-------
http://radio.weblogs.com/0112098/
----- Original Message -----
From: "Federico Michele Facca" <[EMAIL PROTECTED]>
To: "Mike Skells" <[EMAIL PROTECTED]>
Cc: "Dom4j-User@Lists. Sourceforge. Net" <[EMAIL PROTECTED]>
Sent: Friday, October 18, 2002 7:40 PM
Subject: Re: [dom4j-user] help!


> you're completly right!
> it seems that there's some problem with the dtd even if I don't understand
why
> as eiht dom there's no problem... actually my solution is to remove the
> dtd specification line from the xml file... but I bet there's a way to
skip it.
> but reader.setIncludeInternalDTDDeclarations(false);
> doesn't seem to affect it.
>
> BTW I've to say that dom4j is much more performant than dom!
> Before using that the bottleneck in my software was the preprossing
> of the xml file! Now is the mining data package! My teacher may
> kill me because of that ;o)
>
> Federico
>
> http://chicco.grafedi.it
> --------------------------------------------------------------------------
-----------------------
> "In the book of life, the answers aren't in the back"
> Charlie Brown
> ----- Original Message -----
> From: "Mike Skells" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: "Dom4j-User@Lists. Sourceforge. Net"
<[EMAIL PROTECTED]>
> Sent: Thursday, October 17, 2002 9:04 PM
> Subject: RE: [dom4j-user] help!
>
>
> > Hi,
> > When you say that they are failing without message, you would not know,
> > as you are not doing anything with the message!
> >
> > Try e.printStackTrace();
> >
> >
> > Mike
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> > > [mailto:dom4j-user-admin@;lists.sourceforge.net] On Behalf Of
> > > [EMAIL PROTECTED]
> > > Sent: Thursday 17 October 2002 11:18
> > > To: [EMAIL PROTECTED]
> > > Subject: [dom4j-user] help!
> > >
> > >
> > > I'm trying to xml load a file to process. But using SAXReader
> > > directly it doesn't work! I've to read it with DOM and then
> > > convert it to dom4j... I think it's very weird.... Any idea?
> > > Thanks a lot! Federico
> > >
> > > (Document url:
> > > http://www.informatik.uni-freiburg.de/~may/Mondial/mondial-
> > > 3.0.xml it's almost 2mb!)
> > >
> > > SAX reader code:
> > >
> > > import java.io.*;
> > > import java.util.*;
> > > import org.dom4j.*;
> > > import org.dom4j.io.*;
> > >
> > > public class xmine2  implements ElementHandler {
> > >     SAXReader reader = new SAXReader();
> > >     Document document=null;
> > >
> > >     public xmine2(String url) {
> > >         try {
> > >
> > >             reader.setIncludeExternalDTDDeclarations(false);
> > >             reader.setIncludeInternalDTDDeclarations(false);
> > >             reader.setStripWhitespaceText(true);
> > >             reader.setStringInternEnabled(true);
> > >             System.out.println("opening doc");
> > >             File f= new File(url);
> > >             if (f.exists()) {
> > >                 InputStream is= new FileInputStream(url);
> > >                 document = reader.read(is);
> > >                 System.out.println("opened doc");
> > >                 List list = document.selectNodes( "//religions", ".",
> > > true);
> > >                 System.out.println("created list");
> > >                 ListIterator iterator=list.listIterator();
> > >                 int i=0;
> > >                 do {
> > >
> > > System.out.println(((Node)iterator.next()).asXML());
> > >                     i++;
> > >                 } while (iterator.hasNext());
> > >                 System.out.println(i);
> > >             } else System.out.println("no file");
> > >         } catch (Exception e) {e.getMessage();}
> > >
> > >
> > >     }
> > >     public static void main(String[] args) {
> > >         xmine2 xmine21 = new xmine2("mondial.3.0.xml");
> > >     }
> > > }
> > >
> > >
> > > DOM to SAX code:
> > >
> > > import org.dom4j.*;
> > > import org.dom4j.io.*;
> > > import javax.xml.parsers.DocumentBuilder;
> > > import javax.xml.parsers.DocumentBuilderFactory;
> > > import java.util.*;
> > > import java.io.*;
> > >
> > > public class dom {
> > >     DOMReader reader;
> > >     Document d;
> > >
> > >     public dom() {
> > >         try{
> > >         DocumentBuilderFactory factory =
> > > DocumentBuilderFactory.newInstance
> > > ();
> > >         DocumentBuilder builder = factory.newDocumentBuilder();
> > >         reader=new DOMReader();
> > >
> > >         d=reader.read(builder.parse("mondial.3.0.xml"));
> > >         List list = document.selectNodes( "//religions", ".", true);
> > >         ListIterator iterator=list.listIterator();
> > >         do {
> > >             System.out.println(((Node)iterator.next()).asXML());
> > >         } while (iterator.hasNext());
> > >
> > >         } catch (Exception e) {e.getLocalizedMessage();};
> > >     }
> > >     public static void main(String[] args) {
> > >         dom dom1 = new dom();
> > >     }
> > > }
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > This sf.net email is sponsored by: viaVerio will pay you up
> > > to $1,000 for every account that you consolidate with us.
> > > http://ad.doubleclick.net/clk;4749864;7604308;> v?
> > >
> > http://www.viaverio.com/consolidator/osdn.cfm
> >
> > _______________________________________________
> > dom4j-user mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/dom4j-user
> >
> >
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by: viaVerio will pay you up to
> > $1,000 for every account that you consolidate with us.
> > http://ad.doubleclick.net/clk;4749864;7604308;v?
> > http://www.viaverio.com/consolidator/osdn.cfm
> > _______________________________________________
> > dom4j-user mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/dom4j-user
> >
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:
> Access Your PC Securely with GoToMyPC. Try Free Now
> https://www.gotomypc.com/s/OSND/DD
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


-------------------------------------------------------
This sf.net emial is sponsored by: Influence the future 
of Java(TM) technology. Join the Java Community 
Process(SM) (JCP(SM)) program now. 
http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0002en
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to