[jdom-interest] RE:question on JDom document validation. Happ y N ew Year

Jian, David DJian at priceinteractive.com
Wed Jan 10 14:38:25 PST 2001


Brett Mclaughlin talked about this issue in "Java and XML". He takes a shema
as anothe xml file with dtd, validate shema's dtd to validate the xml data
with that shema. Does anyone implement that with JDOM?

-----Original Message-----
From: Davies, Richard [mailto:richard.davies at retek.com]
Sent: Wednesday, January 10, 2001 2:27 PM
To: 'jdom-interest at jdom.org'
Subject: [jdom-interest] RE:question on JDom document validation. Happy
N ew Year


I'm not sure what your security requirements are, but I've implemented an
entity resolver that searches the local classpath for dtd's (including jar
files), then if the dtd of interest is not found locally the dtd is pulled
down off the web.

Briefly, the DOCTYPE looks like:
<!DOCTYPE XXX SYSTEM "http://www.myhome.com/dtd/some.dtd">

and the MyEntityResolver.resolveEntity method looks like:
   public InputSource resolveEntity (String publicId, String systemId) {
      InputSource inputSource = null;
      try  {
         InputStream inputStream =
ClassLoader.getSystemResourceAsStream(getResourceName(systemId));
         if ( inputStream != null )
            inputSource = new InputSource(inputStream);
      } catch (Throwable t) { }
      return inputSource;
   }

where getResourceName() extracts the dtd filename from the system id.  If
the ClassLoader can't find the dtd locally, null is returned to the parser,
which then gets the resource from the systemid's url.  We ship the dtd's in
a jar file along with other application files (classes, etc).

Hope this helps,
Rich

-----Original Message-----
From: Feber, Mark [mailto:Mark_Feber at bmc.com]
Sent: Wednesday, January 10, 2001 12:41 PM
To: 'jdom-interest at jdom.org'
Subject: RE: [jdom-interest] question on JDom document validation. Happy
N ew Year


Thanks in advance for any info (also for JDOM).

As an extension to this question:

	Is there a way to validate against a dtd that exists only in a jar
file on the user's CLASSPATH?

I can validate against a file uri, but I haven't yet figured out how to make
it transparent.  Example:

in a doctype if I specfiy the URI as an path, it works:
<!DOCTYPE XXX SYSTEM "file:/some/path/foo.dtd">

or as ajar url with an  path built in:
<!DOCTYPE XXX SYSTEM "jar:file:/path/to/jarFile.jar!/com/foo/foo.dtd">

But how do you specify the URI for a jar file that just lives somewhere on a
CLASSPATH?  Hopefully, there's an obvious solution I haven't come across
yet.  Thanks,

	mark

-----Original Message-----
From: Jian, David [mailto:DJian at priceinteractive.com]
Sent: Wednesday, January 10, 2001 6:56 AM
To: 'jdom-interest at jdom.org'
Cc: 'Jason Hunter'
Subject: RE: [jdom-interest] question on JDom document validation. Happy
N ew Year


Hi,

I read this message and I hava a simple question:

How do I implement JDOM validation with schema (or dtd)?

Any example code will be appreciated.

Thanks

DJ

-----Original Message-----
From: Jason Hunter [mailto:jhunter at collab.net]
Sent: Tuesday, January 02, 2001 2:47 PM
To: Dominik Hasek
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] question on JDom document validation. Happy
New Year


> i must tell you that jdom is the
> best API ever made. I really wanted to knock my head to the wall when i
see
> the DOM or Sax API.

:-)

> I don't know what is exactly validation. But i think it is something
> like a verification to know if the inputted xml file is valid or not.

Yep.

> Does validation checks according to the dtd assigned to the xml file ?

Yep.

> If validation is set to true, and xml file is not valid what kind of
> exception is thrown ? saxExceptions ?

A JDOMException.

> Thanks to all of you who can me see the light ;-))

You'll find Brett's book "Java and XML" to be very enlightening.

-jh-
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list