Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Schema validation in production environment

Reply
Thread Tools

Schema validation in production environment

 
 
aliptay@gmail.com
Guest
Posts: n/a
 
      06-26-2008
Hi,

Specifically, we're using Spring 2.5 and Xerces jaxp
SAXParserFactoryImpl parser. At some point in time last week, we
couldn't reach http://www.springframework.org/schem...rity-2.0.1.xsd
and our system froze.

Generally, what is the best approach to avoid schema and dtd
dependencies? I know most spring xsd's are defined in the
spring.schemas, but we have some DTD and Schema references which do
not have a local reference. Should I:

1. Make all schema location references local?

2. Forgo default schema validation in our production environment?

Making #1 work appears to be non-trivial for the various environments
we use the code in (Eclipse, JUnit, QA, Production) (ie. the absolute
folder the relative location references seems to change)

For #2, how do you specify a default schema validation of false with
Xerces? The best I could do is extend both the DocumentBuilder and
Parser and set the validation to false programmatically the first time
newParser or newBuilder is called.

Can someone shed some light as to best practices regarding this?

Thanks,
Albert.
 
Reply With Quote
 
 
 
 
Tom Anderson
Guest
Posts: n/a
 
      06-26-2008
On Thu, 26 Jun 2008, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Specifically, we're using Spring 2.5 and Xerces jaxp
> SAXParserFactoryImpl parser. At some point in time last week, we
> couldn't reach
> http://www.springframework.org/schem...rity-2.0.1.xsd
> and our system froze.
>
> Generally, what is the best approach to avoid schema and dtd
> dependencies? I know most spring xsd's are defined in the
> spring.schemas, but we have some DTD and Schema references which do
> not have a local reference. Should I:
>
> 1. Make all schema location references local?
>
> 2. Forgo default schema validation in our production environment?


No.

You should get copies of all the schemata you need, and store them
locally, somehow keyed by their defining URL (use a database, or DBM, or
escape the URLs and use them as filenames, or just use a text file to
index them, etc). You should then write a class which will take URLs and
resolve them to schemata using your local store, and plug this into your
parser.

I don't actually know how you plug such a class into a parser, but i
pretty much guarantee that it can be done. It'd be complete madness if it
couldn't.

I *think* it's just a question of implementing EntityResolver, but i'm not
sure this is used to resolve schemata. I'd create an implementation of
this which resolves entities by opening their URLs, as is the default, but
logs the calls - that way, you can see exactly what it's handling, and
tell quickly if this is the right thing to do.

As for actually getting the data to the code in different environments,
i'd put the schema files or whatever in your classpath, and access them
via Class.getResourceAsStream. This will work in all environments, whether
the code is files in directories or JARred up.

tom

--
They didn't have any answers - they just wanted weed and entitlement.
 
Reply With Quote
 
 
 
 
Arne Vajh°j
Guest
Posts: n/a
 
      06-30-2008
Tom Anderson wrote:
> On Thu, 26 Jun 2008, (E-Mail Removed) wrote:
>> Specifically, we're using Spring 2.5 and Xerces jaxp
>> SAXParserFactoryImpl parser. At some point in time last week, we
>> couldn't reach
>> http://www.springframework.org/schem...rity-2.0.1.xsd
>> and our system froze.
>>
>> Generally, what is the best approach to avoid schema and dtd
>> dependencies? I know most spring xsd's are defined in the
>> spring.schemas, but we have some DTD and Schema references which do
>> not have a local reference. Should I:
>>
>> 1. Make all schema location references local?
>>
>> 2. Forgo default schema validation in our production environment?

>
> No.
>
> You should get copies of all the schemata you need, and store them
> locally, somehow keyed by their defining URL (use a database, or DBM, or
> escape the URLs and use them as filenames, or just use a text file to
> index them, etc). You should then write a class which will take URLs and
> resolve them to schemata using your local store, and plug this into your
> parser.
>
> I don't actually know how you plug such a class into a parser, but i
> pretty much guarantee that it can be done. It'd be complete madness if
> it couldn't.
>
> I *think* it's just a question of implementing EntityResolver, but i'm
> not sure this is used to resolve schemata. I'd create an implementation
> of this which resolves entities by opening their URLs, as is the
> default, but logs the calls - that way, you can see exactly what it's
> handling, and tell quickly if this is the right thing to do.


DocumentBuilder.setEntityResolver works for both DTD's and schemas.

But the code validating against external DTD/schema URL's are very
likely external libraries, where one has no control over the code
(can not call DocumentBuilder.setEntityResolver).

Well - most of it is open source, so one could download the source,
hack it and build. But that is not an elegant solution.

Arne

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New to xml schema - does the dtd/schema validation happens always ? pramodr XML 3 04-05-2009 12:10 PM
Validation with XSD using XML::LibXML::Schema, and XML::Validator::Schema huntingseasonson@gmail.com Perl Misc 5 11-29-2006 12:37 PM
Problem with schema-validation and property "http://apache.org/xml/properties/schema/external-schemaLocation" Markus Java 1 11-23-2005 02:41 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Complex validation of business rules possible with XML Schema? Any other validation "languages"? Mike XML 1 11-21-2003 07:27 PM



Advertisments