You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Elena Litani <el...@ca.ibm.com> on 2001/12/11 18:23:57 UTC

JAXP, validation, schemas

Edwin, 

Edwin Goei wrote:
> Yes, currently, if you use JAXP and turn on validation (and
> namespaceAware), this also turns on XML Schema validation.  I agree with
> Arnaud, that this probably isn't the best thing to do.  I sent some
> email regarding this issue and how it may be incompatible with future
> JAXP API specs.  I'd vote to change the behavior now before its use gets
> too entrenched.

Can you clarify? So in the new release of JAXP schema won't be
automatically turned on?
To turn on the schema support user must use
"http://java.sun.com/xml/jaxp/properties/schemaLanguage" property?
If so, how can users specify:
"My application receives documents that may include different grammars:
some may include DTD, others may include XML Schemas. I want the parser
to validate against the DTD if XML document has DTD, otherwise against
XML Schema"? 


Thank you!

--
Elena Litani / IBM Toronto



-------- Original Message --------
Subject: Re: Xerces 1.4.4: Exposing XML Schema normalized values
[README]
Date: Thu, 18 Oct 2001 18:37:35 -0700
From: Edwin Goei <ed...@sun.com>
Reply-To: xerces-j-dev@xml.apache.org
To: xerces-j-user@xml.apache.org
CC: xerces-j-dev@xml.apache.org
References: <3B...@ca.ibm.com>
<3B...@us.ibm.com>

Arnaud Le Hors wrote:
> 
> For what it's worth I'd like to point out that the first error was to
> make schema processing happen by default. I'm not sure whether people
> care to do the right thing or not at this point but here is what I
> think.
> 
> To be backward compatible everytime a new feature is added it must be
> off by default. That way, new applications can get the new behavior by
> turning the new feature on and old applications still get the old
> behavior they need not to break.
> 
> The general trend seems to be "let's make it easy for new applications",
> but that's just plain wrong. If you care about backward compatibility
> that is. I do, but I seem to represent a minority, since everytime such
> a question gets raised I have to go to the front to make my point
> again...

Yes, currently, if you use JAXP and turn on validation (and
namespaceAware), this also turns on XML Schema validation.  I agree with
Arnaud, that this probably isn't the best thing to do.  I sent some
email regarding this issue and how it may be incompatible with future
JAXP API specs.  I'd vote to change the behavior now before its use gets
too entrenched.

-Edwin

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: JAXP, validation, schemas

Posted by Elena Litani <el...@ca.ibm.com>.
Kohsuke KAWAGUCHI wrote:
> > First of all, I could not find anywhere in JAXP specs that setting
> > setValidation() sets validation against DTD.
> > So it was parser/implementation specific.
> 
> Maybe so, but I guess when JAXP is developed, "validation" implied
> nothing but DTD, since there wasn't XML Schema at that time.

As I mentioned in my previous post, I am fine with this interpretation.
 
> And even if I'm wrong, I'm sure many developers made this assumption. So
> I think Edwin is right from practical point of view.

Many but not all. I think JAXP should clarify this in the spec.
 
> > >   3) app wants to validate to DTD or XSD, the case you state
> How can I specify this behavior without relying on the parser default
> behavior?
> 
> If this #3 use case is really anticipated, we should have a mechanism to
> explicitly specify this behavior.

See my previous post (it has a proposed sol-n for this case).

--
Elena Litani / IBM Toronto

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: JAXP, validation, schemas

Posted by Edwin Goei <ed...@sun.com>.
Kohsuke KAWAGUCHI wrote:
> 
> One additional comment: don't we need to take JAXP schemaLocation
> property into account?

Yes, that is another issue.  How hard would this be to implement in
Xerces2?  The JAXP "schemaLocation" property does not work same the way
as in Xerces1.  See http://java.sun.com/xml/jaxp/change-requests-12.html
for details.

-Edwin

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: JAXP, validation, schemas

Posted by Kohsuke KAWAGUCHI <ko...@yahoo.com>.
Sorry to jump in to the middle of a discussion,

> > I don't think this would be backward compatible to the previous spec
> > version.  Old apps may want to validate against a DTD and expect an
> > error if instance doc does not reference one.
> 
> First of all, I could not find anywhere in JAXP specs that setting
> setValidation() sets validation against DTD. 
> So it was parser/implementation specific. 

Maybe so, but I guess when JAXP is developed, "validation" implied
nothing but DTD, since there wasn't XML Schema at that time.

And even if I'm wrong, I'm sure many developers made this assumption. So
I think Edwin is right from practical point of view.



> >   3) app wants to validate to DTD or XSD, the case you state
> 
> On factory, set validation to true. Language property is not specified.
> For Xerces implementation it would mean that we create a parser with all
> available validators (currently use DTDXSParserConfiguration). 

How can I specify this behavior without relying on the parser default
behavior?

If this #3 use case is really anticipated, we should have a mechanism to
explicitly specify this behavior.


(Edwin wrote:)
> I don't think this is backward compatible.  We may need to come up w/ a
> new schemaLanguage value for this case.

Although I can't think of any other way, I'm not sure if it's a good
idea to treat DTD-or-w3c-schema auto detection feature as one virtual
schema language.

For one, what happens with respect to the schemaLocation property?  Or,
why can't I do DTD-or-relax-ng auto detection, while I can do
DTD-or-w3c-schema?



One additional comment: don't we need to take JAXP schemaLocation
property into account?


regards,
----------------------
K.Kawaguchi
E-Mail: kohsukekawaguchi@yahoo.com


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: JAXP, validation, schemas

Posted by Edwin Goei <ed...@sun.com>.
Elena Litani wrote:
> 
> Edwin Goei wrote:
> > > Note: if application sets validation to true, but the property is
> > > not specified, it is up to an implementation to decide what to validate
> > > against:
> > > validation may occur against DTD or XML Schemas or both.
> >
> > I don't think this would be backward compatible to the previous spec
> > version.  Old apps may want to validate against a DTD and expect an
> > error if instance doc does not reference one.
> 
> First of all, I could not find anywhere in JAXP specs that setting
> setValidation() sets validation against DTD.
> So it was parser/implementation specific.

I would not interpret it that way.  JAXP 1.0 originally supported the
XML REC which refers to validating and non-validating parsers.  JAXP 1.1
was a update but does not mention any other schema language other than
what is in the XML REC itself.  JAXP 1.2 is/will be the first spec that
mentions any other schema language.  So in JAXP 1.1, setValidation()
refers to DTD validation.  In JAXP 1.2 proposed spec, setValidation()
refers to either DTD or XML Schema validation depending on the value of
the "http://java.sun.com/xml/jaxp/properties/schemaLanguage" DBF
attribute or javax.xml.parsers.SaxParser property.

> 
> And it is not how it worked in Xerces 1. For Xerces1, setting validation
> feature on would also set validation/schema feature on. Thus, via JAXP
> users could not specify: "validate only against DTD, ignore XML Schema".

I agree this is not how Xerces 1 worked and I considered this a bug.  I
posted some messages on this topic earlier.  I believe Neil replied that
he prefered not to change the behavior for Xerces 1.4.4 even though it
was not spec conformant and instead change it for Xerces2.  I'll try and
find the postings in the archives and post it to the list if you want.

> Only if document had DTD and NO XML schema, validation errors against
> DTD were reported.
> So from Jaxp users point of view, they will get the same behavior from
> parser as they used to have.

Suppose an app was written to the JAXP 1.1 spec that wanted to read a
webapp deployment descriptor (DD).  DDs currently require validation to
a particular DTD.  Under past non-XML schema aware parsers, if a
doctypedecl is not included, the parser would generate a validation
error.  This happens even if the DD contains a pointer to an XSD.  Under
the scheme you are proposing, this would no longer be true.  The DD
would validate which may not be the expected behavior when the app was
originally written.

> 
> 
> > > >   1) app wants to validate to DTD as before. If no doctypedecl, then
> > > > error.
> > >
> > > On factory, set validation to true and the schemaLanguage property to
> > > DTD.
> > > In JAXP implementation for Xerces, the parser will be created with
> > > StandartParserConfiguration.
> >
> > In previous version of JAXP, all that was required was to call
> > setValidating(true), so this would not be backward compatible.
> 
> As I said above, setting validation to true in JAXP was also turn on
> schema, so if document had no DTD but had valid XML Schema, the document
> would be validated against XML Schema and user would never see any
> errors against DTD.
> 
> > >
> > > >   2) app wants to validate to XSD. If no XSD association (either using
> > > > doc hint or programmatically) then error.
> > >
> > > On factory, set validation to true and schemaLanguage property to XML
> > > Schema
> > > Namespace.
> > > In JAXP implementation for Xerces, the parser will be created with
> > > DTDXSParserConfiguration.
> >
> > Sounds fine, but when I tried this w/ Xerces2 beta3, there was no error
> > reported.
> 
> It works against the current code in CVS.

Good to hear it's fixed, I've only tested this with beta3.

-Edwin

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: JAXP, validation, schemas

Posted by Edwin Goei <ed...@sun.com>.
Elena Litani wrote:
> 
> Edwin Goei wrote:
> > > Note: if application sets validation to true, but the property is
> > > not specified, it is up to an implementation to decide what to validate
> > > against:
> > > validation may occur against DTD or XML Schemas or both.
> >
> > I don't think this would be backward compatible to the previous spec
> > version.  Old apps may want to validate against a DTD and expect an
> > error if instance doc does not reference one.

I'd like to reply to this thread, but may not get to it until later.

-Edwin

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: JAXP, validation, schemas

Posted by Elena Litani <el...@ca.ibm.com>.
Edwin Goei wrote:
> > Note: if application sets validation to true, but the property is
> > not specified, it is up to an implementation to decide what to validate
> > against:
> > validation may occur against DTD or XML Schemas or both.
> 
> I don't think this would be backward compatible to the previous spec
> version.  Old apps may want to validate against a DTD and expect an
> error if instance doc does not reference one.

First of all, I could not find anywhere in JAXP specs that setting
setValidation() sets validation against DTD. 
So it was parser/implementation specific. 

And it is not how it worked in Xerces 1. For Xerces1, setting validation
feature on would also set validation/schema feature on. Thus, via JAXP
users could not specify: "validate only against DTD, ignore XML Schema". 
Only if document had DTD and NO XML schema, validation errors against
DTD were reported. 
So from Jaxp users point of view, they will get the same behavior from
parser as they used to have.

 
> > >   1) app wants to validate to DTD as before. If no doctypedecl, then
> > > error.
> >
> > On factory, set validation to true and the schemaLanguage property to
> > DTD.
> > In JAXP implementation for Xerces, the parser will be created with
> > StandartParserConfiguration.
> 
> In previous version of JAXP, all that was required was to call
> setValidating(true), so this would not be backward compatible.

As I said above, setting validation to true in JAXP was also turn on
schema, so if document had no DTD but had valid XML Schema, the document
would be validated against XML Schema and user would never see any
errors against DTD. 


> >
> > >   2) app wants to validate to XSD. If no XSD association (either using
> > > doc hint or programmatically) then error.
> >
> > On factory, set validation to true and schemaLanguage property to XML
> > Schema
> > Namespace.
> > In JAXP implementation for Xerces, the parser will be created with
> > DTDXSParserConfiguration.
> 
> Sounds fine, but when I tried this w/ Xerces2 beta3, there was no error
> reported.

It works against the current code in CVS.

> >
> > >   3) app wants to validate to DTD or XSD, the case you state
> >
> > On factory, set validation to true. Language property is not specified.
> > For Xerces implementation it would mean that we create a parser with all
> > available validators (currently use DTDXSParserConfiguration).
> 
> I don't think this is backward compatible.  We may need to come up w/ a
> new schemaLanguage value for this case.

Again this is what Xerces 1 used to do. The only difference between
Xerces1 and Xerces2 in the case document has 2 grammars (DTD and XML
Schemas):
In Xerces1 we would look at the document root and if schemaLocation was
present we would ignore DTD. 
In Xerces1 if we found DTD, we won't ignore it and try to validate
against it.

Since this case is not defined by any specifications, I feel that this
change should not be a major concern.

Comments? 

--
Elena Litani / IBM Toronto

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: JAXP, validation, schemas

Posted by Edwin Goei <ed...@sun.com>.
Elena Litani wrote:
> 
> Hi, Rajiv, Edwin,
> 
> Thank you for your reply!
> 
> Rajiv Mordani wrote:
> >  If someone sets
> > setValidating(true) and also sets the schema language then it will use the
> > schema if available else will use the DOCTYPE declaration in the document
> > for validating using DTDs.
> 
> It is very hard (if not impossible) for any parser to implement the
> above, unless document is parsed twice:
> first time to find XML Schema and second time if schema is not found to
> validate against DTD.
> According to XML Schema specification, the schema might not be available
> at the root, but can be found for one of the children. In this case,
> validation attempted for document root will be NONE, but it is NOT a
> validity error and your document may have a schema even if it was found
> at the last element in the document. So unless JAXP would like to come
> up with some mechanism for locating XML Schemas, setting schemaLanguage
> property should mean that validation must occur against the requested
> language.

>From some discussions w/ others here, I think this will be changed. 
Rajiv tells me he will send out a note.

> 
> One way to solve the problem would be to redefined the JAXP
> schemaLanguage
> property in the following way:
> [[
> This property defines the schema language that must be used for
> validation. The
> set of possible schema languages include: DTD, XML Schema, RelaxNG, etc.
> For DTD, the value of this property must be "DTD" string. For all other
> type of schema languages, the value of this property must be the uri of
> the schema language specification being used (e.i. the value of the
> property
> must be set to http://www.w3.org/2001/XMLSchema for the XML Schema
> specification).
> ]]
> 
> Note: if application sets validation to true, but the property is
> not specified, it is up to an implementation to decide what to validate
> against:
> validation may occur against DTD or XML Schemas or both.

I don't think this would be backward compatible to the previous spec
version.  Old apps may want to validate against a DTD and expect an
error if instance doc does not reference one.

> 
> The JAXP property must be associated with the parser. Thus,
> setProperty() (or maybe it should be named setJAXPProperty()) should be
> on the factory classes (DocumentBuilderFactory and SAXParserFactory).
> The "schemaLanguage" property will describe the type of parser user gets
> and the type can not be changed between different parse() calls.
> This is similar to the way setValidation() is defined in JAXP: user must
> setValidation() on the factory to get a validating parser.
> 
> For Xerces implementation that would mean that the parser will be
> created with different configurations depending on features/properties
> set on the JAXP factory:
> 
> >   1) app wants to validate to DTD as before. If no doctypedecl, then
> > error.
> 
> On factory, set validation to true and the schemaLanguage property to
> DTD.
> In JAXP implementation for Xerces, the parser will be created with
> StandartParserConfiguration.

In previous version of JAXP, all that was required was to call
setValidating(true), so this would not be backward compatible.

> 
> >   2) app wants to validate to XSD. If no XSD association (either using
> > doc hint or programmatically) then error.
> 
> On factory, set validation to true and schemaLanguage property to XML
> Schema
> Namespace.
> In JAXP implementation for Xerces, the parser will be created with
> DTDXSParserConfiguration.

Sounds fine, but when I tried this w/ Xerces2 beta3, there was no error
reported.

> 
> >   3) app wants to validate to DTD or XSD, the case you state
> 
> On factory, set validation to true. Language property is not specified.
> For Xerces implementation it would mean that we create a parser with all
> available validators (currently use DTDXSParserConfiguration).

I don't think this is backward compatible.  We may need to come up w/ a
new schemaLanguage value for this case.

> 
> >   4) app wants to validate to both DTD and XSD.
> 
> As Edwin said, I don't think we had requests to support it, nor we know
> how to define it. Thus, JAXP should leave it up to the implementation.
> For Xerces, we kinna combine case (3) and (4):
> -- if we find DTD we validate against it
> -- if we don't find DTD, we attempt to validate against XML Schema and
> report validation errors against it.
> -- if document has both: DTD and XML Schema, we will report errors
> against DTD (and possibly against XML Schema)

So I think you are saying use case #4 is not useful.

> 
> >   5) app wants to validate to RelaxNG
> 
> Set validation to true, set schemaLanguage property to RelaxNG
> namespace. Create Xerces parser with RelaxNG validator (this is for the
> future).

Sounds good.

> 
> I will be sending shortly a note on how we plan to change description of
> Xerces validation features, and how we would use JAXPs language
> property.

There may be more comments on this thread.

-Edwin

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: JAXP, validation, schemas

Posted by Elena Litani <el...@ca.ibm.com>.
Hi, Rajiv, Edwin,

Thank you for your reply!

Rajiv Mordani wrote:
>  If someone sets
> setValidating(true) and also sets the schema language then it will use the
> schema if available else will use the DOCTYPE declaration in the document
> for validating using DTDs.

It is very hard (if not impossible) for any parser to implement the
above, unless document is parsed twice:
first time to find XML Schema and second time if schema is not found to
validate against DTD. 
According to XML Schema specification, the schema might not be available
at the root, but can be found for one of the children. In this case,
validation attempted for document root will be NONE, but it is NOT a
validity error and your document may have a schema even if it was found
at the last element in the document. So unless JAXP would like to come
up with some mechanism for locating XML Schemas, setting schemaLanguage
property should mean that validation must occur against the requested
language.

One way to solve the problem would be to redefined the JAXP
schemaLanguage
property in the following way:
[[ 
This property defines the schema language that must be used for
validation. The
set of possible schema languages include: DTD, XML Schema, RelaxNG, etc.
For DTD, the value of this property must be "DTD" string. For all other
type of schema languages, the value of this property must be the uri of
the schema language specification being used (e.i. the value of the
property
must be set to http://www.w3.org/2001/XMLSchema for the XML Schema
specification).
]]

Note: if application sets validation to true, but the property is 
not specified, it is up to an implementation to decide what to validate
against: 
validation may occur against DTD or XML Schemas or both.

The JAXP property must be associated with the parser. Thus,
setProperty() (or maybe it should be named setJAXPProperty()) should be
on the factory classes (DocumentBuilderFactory and SAXParserFactory). 
The "schemaLanguage" property will describe the type of parser user gets
and the type can not be changed between different parse() calls. 
This is similar to the way setValidation() is defined in JAXP: user must
setValidation() on the factory to get a validating parser.


For Xerces implementation that would mean that the parser will be
created with different configurations depending on features/properties
set on the JAXP factory:

>   1) app wants to validate to DTD as before. If no doctypedecl, then
> error.

On factory, set validation to true and the schemaLanguage property to
DTD. 
In JAXP implementation for Xerces, the parser will be created with
StandartParserConfiguration.

>   2) app wants to validate to XSD. If no XSD association (either using
> doc hint or programmatically) then error.

On factory, set validation to true and schemaLanguage property to XML
Schema
Namespace.
In JAXP implementation for Xerces, the parser will be created with
DTDXSParserConfiguration.


>   3) app wants to validate to DTD or XSD, the case you state

On factory, set validation to true. Language property is not specified.
For Xerces implementation it would mean that we create a parser with all
available validators (currently use DTDXSParserConfiguration). 

>   4) app wants to validate to both DTD and XSD.

As Edwin said, I don't think we had requests to support it, nor we know
how to define it. Thus, JAXP should leave it up to the implementation.
For Xerces, we kinna combine case (3) and (4):
-- if we find DTD we validate against it
-- if we don't find DTD, we attempt to validate against XML Schema and
report validation errors against it.
-- if document has both: DTD and XML Schema, we will report errors
against DTD (and possibly against XML Schema)


>   5) app wants to validate to RelaxNG

Set validation to true, set schemaLanguage property to RelaxNG
namespace. Create Xerces parser with RelaxNG validator (this is for the
future).


I will be sending shortly a note on how we plan to change description of
Xerces validation features, and how we would use JAXPs language
property.


Comments?

--
Elena Litani / IBM Toronto

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: JAXP, validation, schemas

Posted by Rajiv Mordani <Ra...@Sun.COM>.
Ok I am the spec lead on this one and there is still time to fix this, but
please send comments asap on the proposal. The way it is supposed to work
as of now is that if anyone sets setValidating(true) and doesn't set the
schema language then DTD validation is on. If someone sets
setValidating(true) and also sets the schema language then it will use the
schema if available else will use the DOCTYPE declaration in the document
for validating using DTDs. 

Thanks

- Rajiv
--
:wq

On Tue, 11 Dec 2001, Edwin Goei wrote:

> Elena Litani wrote:
> > 
> > Edwin,
> > 
> > Edwin Goei wrote:
> > > Yes, currently, if you use JAXP and turn on validation (and
> > > namespaceAware), this also turns on XML Schema validation.  I agree with
> > > Arnaud, that this probably isn't the best thing to do.  I sent some
> > > email regarding this issue and how it may be incompatible with future
> > > JAXP API specs.  I'd vote to change the behavior now before its use gets
> > > too entrenched.
> > 
> > Can you clarify? So in the new release of JAXP schema won't be
> > automatically turned on?
> 
> Thanks for bringing this up.  I was about to myself.  Probably, but I'm
> not the spec lead.  I think these issues need more discussion before
> finalizing on the spec.  Unfortunately, the spec is on a schedule so
> there may not be time.
> 
> > To turn on the schema support user must use
> > "http://java.sun.com/xml/jaxp/properties/schemaLanguage" property?
> > If so, how can users specify:
> > "My application receives documents that may include different grammars:
> > some may include DTD, others may include XML Schemas. I want the parser
> > to validate against the DTD if XML document has DTD, otherwise against
> > XML Schema"?
> 
> I think we need to discuss the different use cases:
> 
>   1) app wants to validate to DTD as before. If no doctypedecl, then
> error.
>   2) app wants to validate to XSD. If no XSD association (either using
> doc hint or programmatically) then error.
>   3) app wants to validate to DTD or XSD, the case you state
>   4) app wants to validate to both DTD and XSD.
>   5) app wants to validate to RelaxNG
> 
> I've tested with beta3 and read docs.  I've tested w/ these instance
> docs
> A) w/ DTD only, B) w/ XSD only, C) w/ both D) w/ none
> 
> It appears when both DTD and XSD validation is turned on the current
> behavior approximates the DTD-or-XSD in the table below.  The asterisk
> means see comment in text.
> 
>     | Validation
> Doc | DTD-only | XSD-only | DTD-or-XSD  | DTD-and-XSD
> ----+----------+----------+-------------+------------
> A   | Valid    | Valid*   | Valid(DTD)  |
> B   | Error    | Valid    | Valid(XSD)  |
> C   | Valid    | Valid    | Valid(both) |
> D   | Error    | Error    | Error(XSD)* |
> 
> Since XSD validation is on by default, use case #1 does not work for
> type B docs, but this is easy to fix by changing the default value. 
> Case #2 does not work.  (See Valid* in table.)  Is this not a valid use
> case?  Case #3 seems to work except that I'd argue that the error should
> come from the DTD validator since that is part of the fundamental XML
> spec, or maybe both validators.  Case #4 is not really supported.  Is
> there a reason to support use case #4?  Are there apps that perhaps want
> to use parameter entities and use XSD for validation?  Case #5 is for a
> future use case to keep in mind.  There may be also other issues to
> consider for the future like newer versions of XMLSchema.
> 
> Comments welcome.
> 
> -Edwin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: JAXP, validation, schemas

Posted by Edwin Goei <ed...@sun.com>.
Elena Litani wrote:
> 
> Edwin,
> 
> Edwin Goei wrote:
> > Yes, currently, if you use JAXP and turn on validation (and
> > namespaceAware), this also turns on XML Schema validation.  I agree with
> > Arnaud, that this probably isn't the best thing to do.  I sent some
> > email regarding this issue and how it may be incompatible with future
> > JAXP API specs.  I'd vote to change the behavior now before its use gets
> > too entrenched.
> 
> Can you clarify? So in the new release of JAXP schema won't be
> automatically turned on?

Thanks for bringing this up.  I was about to myself.  Probably, but I'm
not the spec lead.  I think these issues need more discussion before
finalizing on the spec.  Unfortunately, the spec is on a schedule so
there may not be time.

> To turn on the schema support user must use
> "http://java.sun.com/xml/jaxp/properties/schemaLanguage" property?
> If so, how can users specify:
> "My application receives documents that may include different grammars:
> some may include DTD, others may include XML Schemas. I want the parser
> to validate against the DTD if XML document has DTD, otherwise against
> XML Schema"?

I think we need to discuss the different use cases:

  1) app wants to validate to DTD as before. If no doctypedecl, then
error.
  2) app wants to validate to XSD. If no XSD association (either using
doc hint or programmatically) then error.
  3) app wants to validate to DTD or XSD, the case you state
  4) app wants to validate to both DTD and XSD.
  5) app wants to validate to RelaxNG

I've tested with beta3 and read docs.  I've tested w/ these instance
docs
A) w/ DTD only, B) w/ XSD only, C) w/ both D) w/ none

It appears when both DTD and XSD validation is turned on the current
behavior approximates the DTD-or-XSD in the table below.  The asterisk
means see comment in text.

    | Validation
Doc | DTD-only | XSD-only | DTD-or-XSD  | DTD-and-XSD
----+----------+----------+-------------+------------
A   | Valid    | Valid*   | Valid(DTD)  |
B   | Error    | Valid    | Valid(XSD)  |
C   | Valid    | Valid    | Valid(both) |
D   | Error    | Error    | Error(XSD)* |

Since XSD validation is on by default, use case #1 does not work for
type B docs, but this is easy to fix by changing the default value. 
Case #2 does not work.  (See Valid* in table.)  Is this not a valid use
case?  Case #3 seems to work except that I'd argue that the error should
come from the DTD validator since that is part of the fundamental XML
spec, or maybe both validators.  Case #4 is not really supported.  Is
there a reason to support use case #4?  Are there apps that perhaps want
to use parameter entities and use XSD for validation?  Case #5 is for a
future use case to keep in mind.  There may be also other issues to
consider for the future like newer versions of XMLSchema.

Comments welcome.

-Edwin

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org