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 kris2006 <ad...@crnomarkovic.com> on 2006/12/07 06:28:21 UTC

Validator features

I am looking for the set of valid Features for the Xerces implementation of
the JAXP Validator class. The Features described in
http://xerces.apache.org/xerces2-j/features.html pertain to DocumentBuilder
and SAXParser. I have tried using one of the general features listed there
(http://apache.org/xml/features/validation/warn-on-undeclared-elemdef) but
it is not recognised for either Validator or SchemaFactory classes.
In particular I would like to validate a soap envelope that contains a xml
string as its body - using both the SOAP-ENV schema and the relevant schema
of the enveloped xml. This works, but if the wrong schema is specified for
the enveloped xml the soap still validates! I think the feature mentioned
above would warn if the schema was incorrect and so would solve my problem.
Any other suggestions appreciated...
-- 
View this message in context: http://www.nabble.com/Validator-features-tf2772590.html#a7733810
Sent from the Xerces - J - Dev mailing list archive at Nabble.com.


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


Re: Validator features

Posted by kris2006 <ad...@crnomarkovic.com>.
I'll give that a shot. Thanks again Michael.

Kris Crnomarkovic
NSW Police


Michael Glavassevich wrote:
> 
> kris2006 <ad...@crnomarkovic.com> wrote on 12/11/2006 07:21:33 PM:
> 
>> Michael,
>> 
>> Thank you for your lightning response. 
>> 
>> I was able to cast my jaxp Validator object as a PSVIProvider, in theory
>> giving me access to the getElementPSVI() methods to find the value of
>> validationAttempted, as you've suggested. However, getElementPSVI() 
> returns
>> a null, I presume since it is only valid within the start/end of the
>> element, and I am simply using:
>>
>> ...
>> Schema schema = schemaFactory.newSchema(schemaSource);
>> Validator validator = schema.newValidator();
>> validator.validate(streamSource);
>>
>> and so no longer have a context for getElementPSVI().
> 
> Right. Specifically the Javadoc [1] for getElementPSVI() says: "The method 
> must be called by an application while in the scope of the methods which 
> report the start and end of an element. For example, for SAX the method 
> must be called within the scope of the document handler's startElement or 
> endElement call. If the method is called outside of the specified scope, 
> the return value is undefined."
> 
>> Any idea how do I could return a valid ElementPSVI?
> 
> So you need to write a SAX content handler which receives the output from 
> the Validator (SAXSource/SAXResult) or ValidatorHandler. Within the scope 
> of the startElement/endElement callbacks of your content handler you would 
> query the PSVIProvider.
> 
>> Thanks again for your help...
>> 
>> Regards,
>> Kris
> 
> [1] 
> http://xerces.apache.org/xerces2-j/javadocs/xs/org/apache/xerces/xs/PSVIProvider.html#getElementPSVI()
> 
>> Michael Glavassevich wrote:
>> > 
>> > kris2006 <ad...@crnomarkovic.com> wrote on 12/07/2006 12:28:21 AM:
>> > 
>> >> I am looking for the set of valid Features for the Xerces 
> implementation 
>> > of
>> >> the JAXP Validator class. The Features described in
>> >> http://xerces.apache.org/xerces2-j/features.html pertain to 
>> > DocumentBuilder
>> >> and SAXParser.
>> > 
>> > That's been on my TODO list for awhile. Just haven't been finding the 
> time 
>> > to write it up.
>> > 
>> >> I have tried using one of the general features listed there
>> >> 
> (http://apache.org/xml/features/validation/warn-on-undeclared-elemdef) 
>> > but
>> >> it is not recognised for either Validator or SchemaFactory classes.
>> > 
>> > That feature only applies to DTDs. It warns [1] you when the content 
> model 
>> > of an element declaration references an element which has not been 
>> > declared in the DTD.
>> > 
>> >> In particular I would like to validate a soap envelope that contains 
> a 
>> > xml
>> >> string as its body - using both the SOAP-ENV schema and the relevant 
>> > schema
>> >> of the enveloped xml. This works, but if the wrong schema is 
> specified 
>> > for
>> >> the enveloped xml the soap still validates! I think the feature 
>> > mentioned
>> >> above would warn if the schema was incorrect and so would solve my 
>> > problem.
>> >> Any other suggestions appreciated...
>> > 
>> > You should examine the PSVI [2] if you want to check the degree [3] to 
> 
>> > which the SOAP message was validated. 
>> > 
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
>> >> For additional commands, e-mail: j-dev-help@xerces.apache.org
>> > 
>> > [1] http://www.w3.org/TR/2006/REC-xml-20060816/#elemdecls
>> > [2] http://xerces.apache.org/xerces2-j/faq-xs.html#faq-8
>> > [3] 
>> > http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-
>> schema-api.html#ItemPSVI-validationAttempted
>> > 
>> > 
>> > Michael Glavassevich
>> > XML Parser Development
>> > IBM Toronto Lab
>> > E-mail: mrglavas@ca.ibm.com
>> > E-mail: mrglavas@apache.org
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
>> > For additional commands, e-mail: j-dev-help@xerces.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context: http://www.nabble.com/Validator-
>> features-tf2772590.html#a7824915
>> Sent from the Xerces - J - Dev mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
>> For additional commands, e-mail: j-dev-help@xerces.apache.org
> 
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Validator-features-tf2805479.html#a7827361
Sent from the Xerces - J - Users mailing list archive at Nabble.com.


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


Re: Validator features

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
kris2006 <ad...@crnomarkovic.com> wrote on 12/11/2006 07:21:33 PM:

> Michael,
> 
> Thank you for your lightning response. 
> 
> I was able to cast my jaxp Validator object as a PSVIProvider, in theory
> giving me access to the getElementPSVI() methods to find the value of
> validationAttempted, as you've suggested. However, getElementPSVI() 
returns
> a null, I presume since it is only valid within the start/end of the
> element, and I am simply using:
>
> ...
> Schema schema = schemaFactory.newSchema(schemaSource);
> Validator validator = schema.newValidator();
> validator.validate(streamSource);
>
> and so no longer have a context for getElementPSVI().

Right. Specifically the Javadoc [1] for getElementPSVI() says: "The method 
must be called by an application while in the scope of the methods which 
report the start and end of an element. For example, for SAX the method 
must be called within the scope of the document handler's startElement or 
endElement call. If the method is called outside of the specified scope, 
the return value is undefined."

> Any idea how do I could return a valid ElementPSVI?

So you need to write a SAX content handler which receives the output from 
the Validator (SAXSource/SAXResult) or ValidatorHandler. Within the scope 
of the startElement/endElement callbacks of your content handler you would 
query the PSVIProvider.

> Thanks again for your help...
> 
> Regards,
> Kris

[1] 
http://xerces.apache.org/xerces2-j/javadocs/xs/org/apache/xerces/xs/PSVIProvider.html#getElementPSVI()

> Michael Glavassevich wrote:
> > 
> > kris2006 <ad...@crnomarkovic.com> wrote on 12/07/2006 12:28:21 AM:
> > 
> >> I am looking for the set of valid Features for the Xerces 
implementation 
> > of
> >> the JAXP Validator class. The Features described in
> >> http://xerces.apache.org/xerces2-j/features.html pertain to 
> > DocumentBuilder
> >> and SAXParser.
> > 
> > That's been on my TODO list for awhile. Just haven't been finding the 
time 
> > to write it up.
> > 
> >> I have tried using one of the general features listed there
> >> 
(http://apache.org/xml/features/validation/warn-on-undeclared-elemdef) 
> > but
> >> it is not recognised for either Validator or SchemaFactory classes.
> > 
> > That feature only applies to DTDs. It warns [1] you when the content 
model 
> > of an element declaration references an element which has not been 
> > declared in the DTD.
> > 
> >> In particular I would like to validate a soap envelope that contains 
a 
> > xml
> >> string as its body - using both the SOAP-ENV schema and the relevant 
> > schema
> >> of the enveloped xml. This works, but if the wrong schema is 
specified 
> > for
> >> the enveloped xml the soap still validates! I think the feature 
> > mentioned
> >> above would warn if the schema was incorrect and so would solve my 
> > problem.
> >> Any other suggestions appreciated...
> > 
> > You should examine the PSVI [2] if you want to check the degree [3] to 

> > which the SOAP message was validated. 
> > 
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> >> For additional commands, e-mail: j-dev-help@xerces.apache.org
> > 
> > [1] http://www.w3.org/TR/2006/REC-xml-20060816/#elemdecls
> > [2] http://xerces.apache.org/xerces2-j/faq-xs.html#faq-8
> > [3] 
> > http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-
> schema-api.html#ItemPSVI-validationAttempted
> > 
> > 
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-dev-help@xerces.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Validator-
> features-tf2772590.html#a7824915
> Sent from the Xerces - J - Dev mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org


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


Re: Validator features

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
kris2006 <ad...@crnomarkovic.com> wrote on 12/11/2006 07:21:33 PM:

> Michael,
> 
> Thank you for your lightning response. 
> 
> I was able to cast my jaxp Validator object as a PSVIProvider, in theory
> giving me access to the getElementPSVI() methods to find the value of
> validationAttempted, as you've suggested. However, getElementPSVI() 
returns
> a null, I presume since it is only valid within the start/end of the
> element, and I am simply using:
>
> ...
> Schema schema = schemaFactory.newSchema(schemaSource);
> Validator validator = schema.newValidator();
> validator.validate(streamSource);
>
> and so no longer have a context for getElementPSVI().

Right. Specifically the Javadoc [1] for getElementPSVI() says: "The method 
must be called by an application while in the scope of the methods which 
report the start and end of an element. For example, for SAX the method 
must be called within the scope of the document handler's startElement or 
endElement call. If the method is called outside of the specified scope, 
the return value is undefined."

> Any idea how do I could return a valid ElementPSVI?

So you need to write a SAX content handler which receives the output from 
the Validator (SAXSource/SAXResult) or ValidatorHandler. Within the scope 
of the startElement/endElement callbacks of your content handler you would 
query the PSVIProvider.

> Thanks again for your help...
> 
> Regards,
> Kris

[1] 
http://xerces.apache.org/xerces2-j/javadocs/xs/org/apache/xerces/xs/PSVIProvider.html#getElementPSVI()

> Michael Glavassevich wrote:
> > 
> > kris2006 <ad...@crnomarkovic.com> wrote on 12/07/2006 12:28:21 AM:
> > 
> >> I am looking for the set of valid Features for the Xerces 
implementation 
> > of
> >> the JAXP Validator class. The Features described in
> >> http://xerces.apache.org/xerces2-j/features.html pertain to 
> > DocumentBuilder
> >> and SAXParser.
> > 
> > That's been on my TODO list for awhile. Just haven't been finding the 
time 
> > to write it up.
> > 
> >> I have tried using one of the general features listed there
> >> 
(http://apache.org/xml/features/validation/warn-on-undeclared-elemdef) 
> > but
> >> it is not recognised for either Validator or SchemaFactory classes.
> > 
> > That feature only applies to DTDs. It warns [1] you when the content 
model 
> > of an element declaration references an element which has not been 
> > declared in the DTD.
> > 
> >> In particular I would like to validate a soap envelope that contains 
a 
> > xml
> >> string as its body - using both the SOAP-ENV schema and the relevant 
> > schema
> >> of the enveloped xml. This works, but if the wrong schema is 
specified 
> > for
> >> the enveloped xml the soap still validates! I think the feature 
> > mentioned
> >> above would warn if the schema was incorrect and so would solve my 
> > problem.
> >> Any other suggestions appreciated...
> > 
> > You should examine the PSVI [2] if you want to check the degree [3] to 

> > which the SOAP message was validated. 
> > 
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> >> For additional commands, e-mail: j-dev-help@xerces.apache.org
> > 
> > [1] http://www.w3.org/TR/2006/REC-xml-20060816/#elemdecls
> > [2] http://xerces.apache.org/xerces2-j/faq-xs.html#faq-8
> > [3] 
> > http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-
> schema-api.html#ItemPSVI-validationAttempted
> > 
> > 
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-dev-help@xerces.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Validator-
> features-tf2772590.html#a7824915
> Sent from the Xerces - J - Dev mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org


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


Re: Validator features

Posted by kris2006 <ad...@crnomarkovic.com>.
Michael,

Thank you for your lightning response. 

I was able to cast my jaxp Validator object as a PSVIProvider, in theory
giving me access to the getElementPSVI() methods to find the value of
validationAttempted, as you've suggested. However, getElementPSVI() returns
a null, I presume since it is only valid within the start/end of the
element, and I am simply using:

...
Schema schema = schemaFactory.newSchema(schemaSource);
Validator validator = schema.newValidator();
validator.validate(streamSource);

and so no longer have a context for getElementPSVI(). 
Any idea how do I could return a valid ElementPSVI?

Thanks again for your help...

Regards,
Kris


Michael Glavassevich wrote:
> 
> kris2006 <ad...@crnomarkovic.com> wrote on 12/07/2006 12:28:21 AM:
> 
>> I am looking for the set of valid Features for the Xerces implementation 
> of
>> the JAXP Validator class. The Features described in
>> http://xerces.apache.org/xerces2-j/features.html pertain to 
> DocumentBuilder
>> and SAXParser.
> 
> That's been on my TODO list for awhile. Just haven't been finding the time 
> to write it up.
> 
>> I have tried using one of the general features listed there
>> (http://apache.org/xml/features/validation/warn-on-undeclared-elemdef) 
> but
>> it is not recognised for either Validator or SchemaFactory classes.
> 
> That feature only applies to DTDs. It warns [1] you when the content model 
> of an element declaration references an element which has not been 
> declared in the DTD.
> 
>> In particular I would like to validate a soap envelope that contains a 
> xml
>> string as its body - using both the SOAP-ENV schema and the relevant 
> schema
>> of the enveloped xml. This works, but if the wrong schema is specified 
> for
>> the enveloped xml the soap still validates! I think the feature 
> mentioned
>> above would warn if the schema was incorrect and so would solve my 
> problem.
>> Any other suggestions appreciated...
> 
> You should examine the PSVI [2] if you want to check the degree [3] to 
> which the SOAP message was validated. 
>  
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
>> For additional commands, e-mail: j-dev-help@xerces.apache.org
> 
> [1] http://www.w3.org/TR/2006/REC-xml-20060816/#elemdecls
> [2] http://xerces.apache.org/xerces2-j/faq-xs.html#faq-8
> [3] 
> http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-schema-api.html#ItemPSVI-validationAttempted
> 
> 
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Validator-features-tf2772590.html#a7824915
Sent from the Xerces - J - Dev mailing list archive at Nabble.com.


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


Re: Validator features

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
kris2006 <ad...@crnomarkovic.com> wrote on 12/07/2006 12:28:21 AM:

> I am looking for the set of valid Features for the Xerces implementation 
of
> the JAXP Validator class. The Features described in
> http://xerces.apache.org/xerces2-j/features.html pertain to 
DocumentBuilder
> and SAXParser.

That's been on my TODO list for awhile. Just haven't been finding the time 
to write it up.

> I have tried using one of the general features listed there
> (http://apache.org/xml/features/validation/warn-on-undeclared-elemdef) 
but
> it is not recognised for either Validator or SchemaFactory classes.

That feature only applies to DTDs. It warns [1] you when the content model 
of an element declaration references an element which has not been 
declared in the DTD.

> In particular I would like to validate a soap envelope that contains a 
xml
> string as its body - using both the SOAP-ENV schema and the relevant 
schema
> of the enveloped xml. This works, but if the wrong schema is specified 
for
> the enveloped xml the soap still validates! I think the feature 
mentioned
> above would warn if the schema was incorrect and so would solve my 
problem.
> Any other suggestions appreciated...

You should examine the PSVI [2] if you want to check the degree [3] to 
which the SOAP message was validated. 
 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org

[1] http://www.w3.org/TR/2006/REC-xml-20060816/#elemdecls
[2] http://xerces.apache.org/xerces2-j/faq-xs.html#faq-8
[3] 
http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/xml-schema-api.html#ItemPSVI-validationAttempted


Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

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