You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Denis Tkachov (JIRA)" <xe...@xml.apache.org> on 2007/08/10 11:33:43 UTC

[jira] Created: (XERCESC-1736) xml document validation againsta schema

xml document validation againsta schema
---------------------------------------

                 Key: XERCESC-1736
                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
             Project: Xerces-C++
          Issue Type: Bug
          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
    Affects Versions: 2.7.0
         Environment: Windows XP professional
Visual Studio 2005
            Reporter: Denis Tkachov


Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
So it seems to be a bug in the library.
 As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser

Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:

datasetSchema.xsd:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:element name="DataObject">
		<xs:complexType>
			<xs:choice minOccurs="0" maxOccurs="unbounded">
				<xs:element name="MasterDataTable">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="key" type="xs:int"/>
							<xs:element name="name" type="xs:string"/>
							<xs:element name="surname" type="xs:string"/>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="ChildDataTable">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="key" type="xs:int"/>
							<xs:element name="age" type="xs:string"/>
							<xs:element name="info" type="xs:string"/>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:choice>
		</xs:complexType>
	</xs:element>
</xs:schema>

output.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">

  <MasterDataTable>
    <key>1</key>
    <name>Vasya</name>
    <surname>Pupkin</surname>
  </MasterDataTable>

  <MasterDataTable>
    <key>2</key>
    <name>Petro</name>
    <surname>Kukurudza</surname>
  </MasterDataTable>

  <ChildDataTable>
    <key1>1</key1> <!-- does not match schema-->
    <age>23</age>
    <info>famous guy</info>
  </ChildDataTable>

  <ChildDataTable>
    <key1>2</key1> <!-- does not match schema-->
    <age>29</age>
    <info></info>
  </ChildDataTable>

</DataObject>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Jesse Pelton (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519729 ] 

Jesse Pelton commented on XERCESC-1736:
---------------------------------------

David,

Denis cited incomplete instructions on schema.html. It looks to me like schema.xml remains to be updated.

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "cargilld (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519672 ] 

cargilld commented on XERCESC-1736:
-----------------------------------

Hi,
I had already changed the documentation to say the default is never in revision's 405114 and 405115...

Changing the default to actually be auto may suprise some user's.

David

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Denis Tkachov (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519394 ] 

Denis Tkachov commented on XERCESC-1736:
----------------------------------------

Hi Jesse,

You wrote:
>Once I revised the instance document to use a known good URL for the schema location and removed the default >namespace declaration, DOMPrint reported the errors one would expect.

Unfortunately your advices did not help me.
I did following:
1. Removed namespace declaration ('xmlns' attribute) from schema document.
2. Specified full fiel name in 'noNamespaceSchemaLocation' attribute (with path).

Also I tried set for schema the same namespace as for xml file.
Also I tried set schema location in code- using XercesDOMParser::setExternalNoNamespaceSchemaLocation(const char* const) method.

Would you provide modified xml, xsd files and c++ that test validation?

BTW: I also tested validation with 'samples\data\personakl.xml' and 'samples\data\personakl.xsd' files. Validation never fails.



> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Jesse Pelton (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519938 ] 

Jesse Pelton commented on XERCESC-1736:
---------------------------------------

Denis,

When I asked whether you could create a patch, what I meant was whether you could create a patch file ("unified diff" is the preferred format, I think) that could be applied to the most recent version of the code to produce the behavior you think is correct. In short, I was suggesting that you submit code that fixes the problem as you see it.

Since  David has already updated the documentation to agree with the code's behavior, the behavior is unlikely to change unless someone a) makes a strong case for changing the behavior and b) offers code that implements the new behavior.

Personally, I think the current behavior is preferable. I don't want Xerces (or any other tool) to perform time-consuming operations like fetching schemas and validating documents unless I explicitly ask it to.

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Jesse Pelton (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519458 ] 

Jesse Pelton commented on XERCESC-1736:
---------------------------------------

I used the DOMPrint sample app with the following command line:

  DOMPrint -n -s -f -v=always output.xml

When I ran it against the original output.xml, I got the following output:

  Error at file "D:\test/output.xml", line 2, column 157
     Message: Unknown element 'DataObject'

I then removed the default namespace, so the second line of the document became as follows:

  <DataObject xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">

DOMPrint then produce the following, which looks correct to me:

  Error at file "D:\test/output.xml", line 14, column 11
     Message: Unknown element 'key1'
  Error at file "D:\test/output.xml", line 17, column 20
     Message: Element 'key1' is not valid for content model: '((key,age),info)'
  Error at file "D:\test/output.xml", line 19, column 11
     Message: Unknown element 'key1'
  Error at file "D:\test/output.xml", line 22, column 20
     Message: Element 'key1' is not valid for content model: '((key,age),info)'

I got the same results with both v2.5 and v2.7 of the software. I was apparently wrong about the need to change the schema URI on my machine.

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Reopened: (XERCESC-1736) xml document validation againsta schema

Posted by "Denis Tkachov (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Denis Tkachov reopened XERCESC-1736:
------------------------------------


Hi Jesse!
Thank you for your assistance.
I have found a problem.
There is a bug with XercesDOMParser::ValidationScheme default value. Documentation states that this property is Val_Auto by default, hence there is no need to set this property manually. But if you do not set this property - invoking method parse will not invoke validation of the xml document.

Please see a sample here:
http://xml.apache.org/xerces-c/schema.html
     DOMParser parser;
     parser.setDoNamespaces(true);
     parser.setDoSchema(true);
     parser.parse(xmlFile); 

It will not work until you insert line parser.setValidationScheme(XercesDOMParser::Val_Auto);
DOMPrint sample always sets this property even if this is not necessary.

I have took a look into code. Method XercesDOMParser::ValidationScheme internally invokes method XMLScanner::setValidationScheme. If leave property by default, method XercesDOMParser::ValidationScheme will be never invoked and  XercesDOMParser::fValScheme will not set to correct value.

So, even so there is workarround to the problem, this is a bug - implementation does not match documentation.
Please do the following:
 - change documentation. (Seems to be not very good point  because java version might work correct, and this is expected to have validationScheme property set to Val_Auto)
 - fix this problem in code.

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Boris Kolpackov (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519974 ] 

Boris Kolpackov commented on XERCESC-1736:
------------------------------------------

I personally think the Val_Auto does not make any sense. The application should either turn validation on or off. It should not leave that decision to the XML instance.

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Denis Tkachov (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12520472 ] 

Denis Tkachov commented on XERCESC-1736:
----------------------------------------

Jesse,

Thank you for you assistance in fixing the problem with validation. By the time I have been opening this issue I had really no idea why validation does not work (since I did all necessary things stated in documentation), so it was really helpful to get your opinion.

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Denis Tkachov (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12520167 ] 

Denis Tkachov commented on XERCESC-1736:
----------------------------------------

Jesse,
I really did not understand that you are asking me to fix the problem by myself. I would do this but since David changed documentation I think it is odd.

Boris, 
concerning a sense of Val_Auto:
Look at this peace of code (taken from Xerces documentation):
     DOMParser parser;
     parser.setDoNamespaces(true);
     parser.setDoSchema(true);
     parser.parse(xmlFile); 

If there is invocation of method parse, it is clear that user wants to parse the document. Setting one more property ValidationScheme looks to be odd.


> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (XERCESC-1736) xml document validation againsta schema

Posted by "Denis Tkachov (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Denis Tkachov updated XERCESC-1736:
-----------------------------------

    Comment: was deleted

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Denis Tkachov (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519388 ] 

Denis Tkachov commented on XERCESC-1736:
----------------------------------------

Hi Jesse,

You wrote:
>Once I revised the instance document to use a known good URL for the schema location and removed the default >namespace declaration, DOMPrint reported the errors one would expect.

I have modified xml and xsd documents like you advised but unfortunately it did not helped. 
I did following:
1.  I have removed 'xmlns' attribute from 'DataObject' node of 'output.xml' document.
2. Specified full path in 'xs:noNamespaceSchemaLocation' attribute.

I have also tested specifying 'xmlns' attribute for schema document and set location of schema manually from code - through DOMParser::setExternalNoNamespaceSchemaLocation() method.

Would you please provide modified xml and xsd documents and c++ code to test xml document validation ?

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Jesse Pelton (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12520212 ] 

Jesse Pelton commented on XERCESC-1736:
---------------------------------------

Denis,

Xerces being open source, anyone can offer improvements, and I wanted to make sure you knew that changes are more likely to occur when someone offers the code. I initially suggested that you create a patch before I knew David had updated the documentation, and it's still an option.

However, for your patch to be applied, you would need to make a compelling case for changing the behavior and updating the documentation again. Your case would have to be strong because while anyone can offer a patch, a relatively small number of people are authorized to commit changes, and they'd have to be convinced that the change is a good idea.

Personally, I would not offer such a patch. I think the current behavior is intentional and well-designed, and I suspect most or all of the committers would agree.

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (XERCESC-1736) xml document validation againsta schema

Posted by "Jesse Pelton (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesse Pelton resolved XERCESC-1736.
-----------------------------------

    Resolution: Invalid

I see two problems with your test case, one of which masks the other, at least on my machine.

First, the DataObject in the instance document is in the namespace "http://creopod.com/DataObject.xsd", but there is no namespace associated with the schema. The DataObject in the schema therefore has no relationship to the DataObject in the instance document. Likewise for other elements.

Second, the URL for the schema may not resolve as you expect (it didn't on my machine). If it doesn't, the schema won't load, and no validation can occur.

I used the DOMPrint sample (admittedly the 2.5 version, but I have no reason to think core functionality broke between 2.5 and 2.7) to test. Once I revised the instance document to use a known good URL for the schema location and removed the default namespace declaration, DOMPrint reported the errors one would expect.

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Denis Tkachov (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519912 ] 

Denis Tkachov commented on XERCESC-1736:
----------------------------------------

Hi Jesse,

Sure, I can work it around by invoking XercesDOMParser::setValidationScheme method.
You can fix it or not but inconsistency between documentation and implementation is a bug.

>Changing the default to actually be auto may suprise some user's. 
I do not think so. I was rather surprised that I have to set some one more property in order to make validation available.  From usability side it is more intuitive that if you invoked XercesDOMParser::parse method, document will be validated and you do not need to set some more properties...


> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Jesse Pelton (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519666 ] 

Jesse Pelton commented on XERCESC-1736:
---------------------------------------

Can you create a patch? If so, it might make it into the recently proposed 2.8.0 release.

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (XERCESC-1736) xml document validation againsta schema

Posted by "Jesse Pelton (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519461 ] 

Jesse Pelton commented on XERCESC-1736:
---------------------------------------

I just noticed the difference between what you did and what I did: I removed the default namespace from the instance document, not the schema.

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Closed: (XERCESC-1736) xml document validation againsta schema

Posted by "Denis Tkachov (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESC-1736?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Denis Tkachov closed XERCESC-1736.
----------------------------------

    Resolution: Fixed

Documentation changed to match functionality.

> xml document validation againsta schema
> ---------------------------------------
>
>                 Key: XERCESC-1736
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1736
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (Schema) (Xerces 1.5 or up only)
>    Affects Versions: 2.7.0
>         Environment: Windows XP professional
> Visual Studio 2005
>            Reporter: Denis Tkachov
>
> Instances of both  XercesDOMParser and  SAX2XMLReader threat all the documents as valid even if a document does not match schema provided.
> In order if document does not match schema provided the library does not throw exception and getErrorCount method of the parser returns zero.
> So it seems to be a bug in the library.
>  As example you can try this code: http://xml.apache.org/xerces-c/program-dom.html#ConstructXercesDOMParser
> Below are provided scheme and document (error marked with "does not match schema" comment) that reproduces error:
> datasetSchema.xsd:
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 	<xs:element name="DataObject">
> 		<xs:complexType>
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:element name="MasterDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="name" type="xs:string"/>
> 							<xs:element name="surname" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 				<xs:element name="ChildDataTable">
> 					<xs:complexType>
> 						<xs:sequence>
> 							<xs:element name="key" type="xs:int"/>
> 							<xs:element name="age" type="xs:string"/>
> 							<xs:element name="info" type="xs:string"/>
> 						</xs:sequence>
> 					</xs:complexType>
> 				</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> </xs:schema>
> output.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <DataObject xmlns="http://creopod.com/DataObject.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="datasetSchema.xsd">
>   <MasterDataTable>
>     <key>1</key>
>     <name>Vasya</name>
>     <surname>Pupkin</surname>
>   </MasterDataTable>
>   <MasterDataTable>
>     <key>2</key>
>     <name>Petro</name>
>     <surname>Kukurudza</surname>
>   </MasterDataTable>
>   <ChildDataTable>
>     <key1>1</key1> <!-- does not match schema-->
>     <age>23</age>
>     <info>famous guy</info>
>   </ChildDataTable>
>   <ChildDataTable>
>     <key1>2</key1> <!-- does not match schema-->
>     <age>29</age>
>     <info></info>
>   </ChildDataTable>
> </DataObject>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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