[ 
https://issues.apache.org/jira/browse/XERCESJ-1488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12972354#action_12972354
 ] 

Mukul Gandhi commented on XERCESJ-1488:
---------------------------------------

Hi Khaled,
    Thanks for your comments. They would be quite useful for us to work on 
these issues further.

I'm replying to your following comments. I would analyze your other comments 
and would reply to them asap.

<quote>
In case1, <xs:union memberTypes="xs:int MYDATE" />, MYDate was used to validate 
the attribute value, then we call XSTypeHelper.isAtomicValueValidForAnUnion 
which will return false, so we do not change the value of 
fisAtomicValueValidForSTVarietyUnion and evaluate the assertion(s).

In case 2, <xs:union memberTypes="xs:int MYDATE xs:date" />, MYDate was also 
used to validate the attribute value, but the call to 
XSTypeHelper.isAtomicValueValidForAnUnion will return true, so we set 
fisAtomicValueValidForSTVarietyUnion to false and do not evaluate the 
assertion(s).

This is inconsistent. Also, if we just take the case of an atomic type (e.g. 
the attribute type is just MYDATE), we will evaluate the assertion(s). 
</quote>

It seems the XML Schema 1.1 spec doesn't explicitly specify any special 
treatment for assertion evaluations for "simpleType -> union" cases. The schema 
language spec only specifies assertion facets on "simpleType -> restriction" 
cases. The above design for which you've raised comments is a custom design 
built for Xerces, since it is not explicitly required by the spec; and 
therefore I believe that such aspects of XML schema validator implementation 
are implementation defined/dependent. 

I also request you to please look at the validation use-cases I attached with 
this JIRA issue and requesting comments whether from schema language point of 
view, would these use-cases be correct (and what kind of validation failure 
error messages we would like Xerces to produce for such cases)? After which we 
could try to correct the Xerces schema validator implementation in this regard.

Regards,
Mukul


> NullPointerException caused by XMLSchemaValidator.addDefaultAttributes
> ----------------------------------------------------------------------
>
>                 Key: XERCESJ-1488
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1488
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: XML Schema 1.1 Structures
>    Affects Versions: 2.11.0
>         Environment: Java version: 1.6.0_23
> Java home: C:\Program Files\Java\jdk1.6.0_23\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows vista" version: "6.0" arch: "amd64" Family: "windows"
>            Reporter: Gary Gregory
>            Assignee: Khaled Noaman
>            Priority: Blocker
>         Attachments: XERCESJ-1488_samples.zip
>
>
> The following is a regression from 2.10 because our unit tests run OK with 
> 2.10 and blow up with 2.11.
> NullPointerException caused by XMLSchemaValidator.addDefaultAttributes  
> Note that the second argument is null in the call:
> {noformat}
> if (XSTypeHelper.isAtomicValueValidForAnUnion(attDV.getMemberTypes(), 
>       null, defaultValue)) {
> {noformat}
> at
> XMLSchemaValidator.addDefaultAttributes(QName, XMLAttributes, 
> XSAttributeGroupDecl) line: 3385        
> Which means that at this point in the call chain:
> {noformat}
> Thread [main] (Suspended (breakpoint at line 2255 in XSSimpleTypeDecl))       
>       XSSimpleTypeDecl.normalize(Object, short) line: 2255    
>       XSSimpleTypeDecl.getActualValue(Object, ValidationContext, 
> ValidatedInfo, boolean) line: 2053   
>       XSSimpleTypeDecl.validate(String, ValidationContext, ValidatedInfo) 
> line: 1742  
>       XSTypeHelper.isValueValidForASimpleType(String, XSSimpleType) line: 135 
>       XSTypeHelper.isAtomicValueValidForAnUnion(XSObjectList, String, 
> ValidatedInfo) line: 108        
>       XMLSchemaValidator.addDefaultAttributes(QName, XMLAttributes, 
> XSAttributeGroupDecl) line: 3385  
>       XMLSchemaValidator.handleStartElement(QName, XMLAttributes, 
> Augmentations) line: 2375   
>       XMLSchemaValidator.startElement(QName, XMLAttributes, Augmentations) 
> line: 815  
>       XMLNSDocumentScannerImpl.scanStartElement() line: 283   
>       XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook() 
> line: 733    
>       
> XMLNSDocumentScannerImpl$NSContentDispatcher(XMLDocumentFragmentScannerImpl$FragmentContentDispatcher).dispatch(boolean)
>  line: 1754     
>       
> XMLNSDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanDocument(boolean)
>  line: 324        
>       IntegratedParserConfiguration(DTDConfiguration).parse(boolean) line: 
> 515        
>       IntegratedParserConfiguration(DTDConfiguration).parse(XMLInputSource) 
> line: 571 
>       DOMParser(XMLParser).parse(XMLInputSource) line: 108    
>       DOMParser.parse(InputSource) line: 230  
>       DocumentBuilderImpl.parse(InputSource) line: 298        
>       XmlValidator.validate(InputSource) line: 279    
>       XmlValidator.validate(URL) line: 317    
>       XmlValidator.validate(String) line: 300 
>       XmlValidatorTestCase.validateXmlSchema1_0_2(String) line: 187   
>       XmlValidatorTestCase.testSimpleXsd_XmlSchema1_0_2() line: 126   
>       NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not 
> available [native method]  
>       NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39      
>       DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25  
>       Method.invoke(Object, Object...) line: 597      
>       FrameworkMethod$1.runReflectiveCall() line: 44  
>       FrameworkMethod$1(ReflectiveCallable).run() line: 15    
>       FrameworkMethod.invokeExplosively(Object, Object...) line: 41   
>       InvokeMethod.evaluate() line: 20        
>       BlockJUnit4ClassRunner.runNotIgnored(FrameworkMethod, EachTestNotifier) 
> line: 79        
>       BlockJUnit4ClassRunner.runChild(FrameworkMethod, RunNotifier) line: 71  
>       BlockJUnit4ClassRunner.runChild(Object, RunNotifier) line: 49   
>       ParentRunner$3.run() line: 193  
>       ParentRunner$1.schedule(Runnable) line: 52      
>       BlockJUnit4ClassRunner(ParentRunner<T>).runChildren(RunNotifier) line: 
> 191      
>       ParentRunner<T>.access$000(ParentRunner, RunNotifier) line: 42  
>       ParentRunner$2.evaluate() line: 184     
>       BlockJUnit4ClassRunner(ParentRunner<T>).run(RunNotifier) line: 236      
>       JUnit4TestMethodReference(JUnit4TestReference).run(TestExecution) line: 
> 49      
>       TestExecution.run(ITestReference[]) line: 38    
>       RemoteTestRunner.runTests(String[], String, TestExecution) line: 467    
>       RemoteTestRunner.runTests(TestExecution) line: 683      
>       RemoteTestRunner.run() line: 390        
>       RemoteTestRunner.main(String[]) line: 197       
> {noformat}
>       
> The "return null;" runs at:
> XSSimpleTypeDecl.normalize(Object, short) line: 2255  
> {noformat}
>         if (content == null)
>             return null;
> {noformat}
>                       
> Which then causes:
> {noformat}
> java.lang.NullPointerException
>       at java.util.StringTokenizer.<init>(StringTokenizer.java:182)
>       at java.util.StringTokenizer.<init>(StringTokenizer.java:204)
>       at 
> org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.getActualValue(XSSimpleTypeDecl.java:2105)
>       at 
> org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.validate(XSSimpleTypeDecl.java:1742)
>       at 
> org.apache.xerces.impl.xs.util.XSTypeHelper.isValueValidForASimpleType(XSTypeHelper.java:135)
>       at 
> org.apache.xerces.impl.xs.util.XSTypeHelper.isAtomicValueValidForAnUnion(XSTypeHelper.java:108)
>       at 
> org.apache.xerces.impl.xs.XMLSchemaValidator.addDefaultAttributes(XMLSchemaValidator.java:3385)
>       at 
> org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2375)
>       at 
> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:815)
>       at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:283)
>       at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:733)
>       at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1754)
>       at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:324)
>       at 
> org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:515)
>       at 
> org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:571)
>       at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
>       at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:230)
>       at 
> org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:298)
>       at 
> com.seagullsw.toolbox.xml.XmlValidator.validate(XmlValidator.java:279)
>       at 
> com.seagullsw.toolbox.xml.XmlValidator.validate(XmlValidator.java:317)
>       at 
> com.seagullsw.toolbox.xml.XmlValidator.validate(XmlValidator.java:300)
>       at 
> com.seagullsw.toolbox.xml.XmlValidatorTestCase.validateXmlSchema1_0_2(XmlValidatorTestCase.java:187)
>       at 
> com.seagullsw.toolbox.xml.XmlValidatorTestCase.testSimpleXsd_XmlSchema1_0_2(XmlValidatorTestCase.java:126)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>       at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>       at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>       at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>       at 
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
>       at 
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> {noformat}
> because the null value is passed all the way down the call chain until it 
> causes the implosion.

-- 
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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to