You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Alexi Zuo <al...@gmail.com> on 2008/06/16 07:03:57 UTC

What do these SAX2 features exactly mean?

 *I am writing a schema validation tool to make the content of a XML file is
consistent with a XSD file. Although I can make it work, but I still don't
know what the following SAX2 features exactly mean.  I can't understand the
simple explanation in
**http://xerces.apache.org/xerces-c/program-sax2.html*<http://xerces.apache.org/xerces-c/program-sax2.html>
*.*
**
*Can anybody tell me what they eactly mean, and when I should set them to
true (or false)? *
**
*1. XMLUni::fgSAX2CoreNameSpaces*
  *Predefined Constant:  * *fgSAX2CoreNameSpaces   * *note:  * *If the
validation feature is set to true, then the document must contain a grammar
that supports the use of namespaces.   *
* *
*But what is a grammar that supports the use of namespaces?*
*2.XMLUni::fgXercesSchema*
  *http://apache.org/xml/features/validation/schema  * *true:  * *Enable the
parser's schema support.   * *false:  * *Disable the parser's schema
support.   *
*What does it mean by "a parser that supports schema"?*

*3.XMLUni::fgSAX2CoreNameSpacePrefixes*
  *http://xml.org/sax/features/namespace-prefixes  * *true:  * *Report the
original prefixed names and attributes used for Namespace declarations.   *
*false:  * *Do not report attributes used for Namespace declarations, and
optionally do not report original prefixed names.  *
*Can anybody give me an example for this?*
**
**
*4.XMLUni::fgXercesSchemaFullChecking
*
  *http://apache.org/xml/features/validation/schema-full-checking  * *true:
* *Enable full schema constraint checking, including checking which may be
time-consuming or memory intensive. Currently, particle unique attribution
constraint checking and particle derivation restriction checking are
controlled by this option.   * *false:  * *Disable full schema constraint
checking.   * *default:  * *false   * *XMLUni Predefined Constant:  *
*fgXercesSchemaFullChecking
  * *note:  * *This feature checks the schema grammar itself for additional
errors that are time-consuming or memory intensive. It does not affect the
level of checking performed on document instances that use schema grammars.
  * *see:  * *http://apache.org/xml/features/validation/schema*<http://xerces.apache.org/xerces-c/program-sax2.html#schema>
*  *
*This feature is only used to check grammar in the XSD file?*
**
*5.XMLUni::fgXercesDynamic*
  *http://apache.org/xml/features/validation/dynamic  * *true:  * *The
parser will validate the document only if a grammar is specified. (
http://xml.org/sax/features/validation must be true).   * *false:  *
*Validation
is determined by the state of the
http://xml.org/sax/features/validationfeature.
* *default:  * *false   * *XMLUni Predefined Constant:  * *fgXercesDynamic
* *see:  * *http://xml.org/sax/features/validation*<http://xerces.apache.org/xerces-c/program-sax2.html#validation>
*   *
The "true" and "false" clauses seems say the same thing?

Re: What do these SAX2 features exactly mean?

Posted by David Bertoni <db...@apache.org>.
Alexi Zuo wrote:
> Dave,
> 
> Thanks, for the second one "XMLUni::fgXercesSchema", can you just tell me
> when it should be set to true?
If you want to do schema validation, then yes, set it to true.

> 
> So in my case, I just need to set XMLUni::fgSAX2CoreValidation to true, and
> leave others unchanged?
If you want to do validation, then yes, set it to true.  If you want to 
force validation whether a grammar is present or not, then don't enable 
dynamic validation (http://apache.org/xml/features/validation/dynamic)

Dave

Re: What do these SAX2 features exactly mean?

Posted by Alexi Zuo <al...@gmail.com>.
Dave,

Thanks, for the second one "XMLUni::fgXercesSchema", can you just tell me
when it should be set to true?

So in my case, I just need to set XMLUni::fgSAX2CoreValidation to true, and
leave others unchanged?

thanks,


On 6/17/08, David Bertoni <db...@apache.org> wrote:
>
> Alexi Zuo wrote:
>
>>  *I am writing a schema validation tool to make the content of a XML file
>> is
>> consistent with a XSD file. Although I can make it work, but I still don't
>> know what the following SAX2 features exactly mean.
>>
> ...
>
>> *Can anybody tell me what they eactly mean, and when I should set them to
>> true (or false)? *
>> **
>> *1. XMLUni::fgSAX2CoreNameSpaces*
>>  *Predefined Constant:  * *fgSAX2CoreNameSpaces   * *note:  * *If the
>> validation feature is set to true, then the document must contain a
>> grammar
>> that supports the use of namespaces.   *
>> * *
>> *But what is a grammar that supports the use of namespaces?*
>>
> XML Schema requires namespace support to be enabled.
>
> *2.XMLUni::fgXercesSchema*
>>  *http://apache.org/xml/features/validation/schema  * *true:  * *Enable
>> the
>> parser's schema support.   * *false:  * *Disable the parser's schema
>> support.   *
>> *What does it mean by "a parser that supports schema"?*
>>
> I don't see the text "a parser that supports schema" anywhere on the page.
>
>
>> *3.XMLUni::fgSAX2CoreNameSpacePrefixes*
>>  *http://xml.org/sax/features/namespace-prefixes  * *true:  * *Report the
>> original prefixed names and attributes used for Namespace declarations.
>> *
>> *false:  * *Do not report attributes used for Namespace declarations, and
>> optionally do not report original prefixed names.  *
>> *Can anybody give me an example for this?*
>>
> When this feature is set to true, any attributes that define namespace
> bindings appear in the attributes list for the element.  If set to false,
> they are not report as attributes, and are only reported through
> startPrefixMapping() and endPrefixMapping() events.  For example:
>
> <foo xmlns:bar="http://www.bar.com" />
>
> If this feature is set to false, the attribute list for this element will
> be empty.  If set to true, it will contain one attribute.
>
> **
>> **
>> *4.XMLUni::fgXercesSchemaFullChecking
>> *
>>
> ...
>
>> *This feature is only used to check grammar in the XSD file?*
>>
> Yes
>
> **
>> *5.XMLUni::fgXercesDynamic*
>>  *http://apache.org/xml/features/validation/dynamic  * *true:  * *The
>> parser will validate the document only if a grammar is specified. (
>> http://xml.org/sax/features/validation must be true).   * *false:  *
>> *Validation
>> is determined by the state of the
>> http://xml.org/sax/features/validationfeature.
>> * *default:  * *false   * *XMLUni Predefined Constant:  * *fgXercesDynamic
>> * *see:  * *http://xml.org/sax/features/validation*<
>> http://xerces.apache.org/xerces-c/program-sax2.html#validation>
>> *   *
>> The "true" and "false" clauses seems say the same thing?
>>
> No.  If dynamic validation is set to true, and validation is set to true,
> validation will only occur if a grammar is found.  If dynamic validation is
> set to false, and validation is set to true, then validation will always
> occur, possibly leading to validation errors if a document doesn't have a
> grammar.
>
> Dave
>

Re: What do these SAX2 features exactly mean?

Posted by David Bertoni <db...@apache.org>.
Alexi Zuo wrote:
>  *I am writing a schema validation tool to make the content of a XML file is
> consistent with a XSD file. Although I can make it work, but I still don't
> know what the following SAX2 features exactly mean.
...
> *Can anybody tell me what they eactly mean, and when I should set them to
> true (or false)? *
> **
> *1. XMLUni::fgSAX2CoreNameSpaces*
>   *Predefined Constant:  * *fgSAX2CoreNameSpaces   * *note:  * *If the
> validation feature is set to true, then the document must contain a grammar
> that supports the use of namespaces.   *
> * *
> *But what is a grammar that supports the use of namespaces?*
XML Schema requires namespace support to be enabled.

> *2.XMLUni::fgXercesSchema*
>   *http://apache.org/xml/features/validation/schema  * *true:  * *Enable the
> parser's schema support.   * *false:  * *Disable the parser's schema
> support.   *
> *What does it mean by "a parser that supports schema"?*
I don't see the text "a parser that supports schema" anywhere on the page.

> 
> *3.XMLUni::fgSAX2CoreNameSpacePrefixes*
>   *http://xml.org/sax/features/namespace-prefixes  * *true:  * *Report the
> original prefixed names and attributes used for Namespace declarations.   *
> *false:  * *Do not report attributes used for Namespace declarations, and
> optionally do not report original prefixed names.  *
> *Can anybody give me an example for this?*
When this feature is set to true, any attributes that define namespace 
bindings appear in the attributes list for the element.  If set to 
false, they are not report as attributes, and are only reported through 
startPrefixMapping() and endPrefixMapping() events.  For example:

<foo xmlns:bar="http://www.bar.com" />

If this feature is set to false, the attribute list for this element 
will be empty.  If set to true, it will contain one attribute.

> **
> **
> *4.XMLUni::fgXercesSchemaFullChecking
> *
...
> *This feature is only used to check grammar in the XSD file?*
Yes

> **
> *5.XMLUni::fgXercesDynamic*
>   *http://apache.org/xml/features/validation/dynamic  * *true:  * *The
> parser will validate the document only if a grammar is specified. (
> http://xml.org/sax/features/validation must be true).   * *false:  *
> *Validation
> is determined by the state of the
> http://xml.org/sax/features/validationfeature.
> * *default:  * *false   * *XMLUni Predefined Constant:  * *fgXercesDynamic
> * *see:  * *http://xml.org/sax/features/validation*<http://xerces.apache.org/xerces-c/program-sax2.html#validation>
> *   *
> The "true" and "false" clauses seems say the same thing?
No.  If dynamic validation is set to true, and validation is set to 
true, validation will only occur if a grammar is found.  If dynamic 
validation is set to false, and validation is set to true, then 
validation will always occur, possibly leading to validation errors if a 
document doesn't have a grammar.

Dave