You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "Mike Beckerle (Jira)" <ji...@apache.org> on 2020/05/12 17:28:00 UTC

[jira] [Comment Edited] (DAFFODIL-2339) CLI Test fails if xsi:schemaLocation added to config.xml file.

    [ https://issues.apache.org/jira/browse/DAFFODIL-2339?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17105607#comment-17105607 ] 

Mike Beckerle edited comment on DAFFODIL-2339 at 5/12/20, 5:27 PM:
-------------------------------------------------------------------

The CLI constructs a DaffodilXMLLoader() with the default constructor. This provides an error handler of type RethrowSchemaErrorHandler which just rethrows the SAX exception. This is problematic as the CLI should be reporting these as errors, not letting them throw to top level. These should also just be warnings. But... truly it should be finding the dafext.xsd file. That's the ultimate cause of this problem. 

The other uses of DaffodilXMLLoader(...) supply an argument which is the handler. This gathers these errors somewhere. The TDML runner gathers them onto the loadingExceptions member.

However, this error appears to be suppressed. Only if the TDML file itself is deemed invalid are the loading exceptions displayed. 
So the TDML runner has a bug, DAFFODIL-2340) in that an invalid config file being loaded as part of the test doesn't signal the TDML being invalid altogether. 



was (Author: mbeckerle):
The CLI constructs a DaffodilXMLLoader() with the default constructor. This provides an error handler of type RethrowSchemaErrorHandler which just rethrows the SAX exception. This is problematic as the CLI should be reporting these as errors, not letting them throw to top level. These should also just be warnings. But... truly it should be finding the dafext.xsd file. That's the ultimate cause of this problem. 

The other uses of DaffodilXMLLoader(...) supply an argument which is the handler. This gathers these errors somewhere. The TDML runner gathers them onto the loadingExceptions member.

However, this error appears to be suppressed. Only if the TDML file itself is deemed invalid are the loading exceptions displayed. 
So the TDML runner has a bug in that an invalid config file being loaded as part of the test doesn't signal the TDML being invalid altogether. 


> CLI Test fails if xsi:schemaLocation added to config.xml file.
> --------------------------------------------------------------
>
>                 Key: DAFFODIL-2339
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2339
>             Project: Daffodil
>          Issue Type: Bug
>          Components: CLI
>    Affects Versions: 2.6.0
>            Reporter: Mike Beckerle
>            Priority: Major
>             Fix For: 3.0.0
>
>
> For CLI test_3507_CLI_Parsing_SimpleParse_SaveParser_extVars
> This specifies a config file on the command line via the path
> daffodil-test/src/test/resources/org/apache/daffodil/section07/external_variables/daffodil_config_cli_test.xml
> This file contains
> {code}
> <daf:dfdlConfig xmlns:daf="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext">
> 	<daf:externalVariableBindings xmlns="http://www.w3.org/2001/XMLSchema"
> 		xmlns:ex="http://example.com">
> 		<daf:bind name="ex:var1">-9</daf:bind>
> 		<daf:bind name="ex:var3">-8</daf:bind>
> 	</daf:externalVariableBindings>
> </daf:dfdlConfig>
> {code}
> It would be valuable to add xsi:schemaLocation to this so as to specify where the
> daf namespace schema is defined like so:
> {code}
> <daf:dfdlConfig xmlns:daf="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext org/apache/daffodil/xsd/dafext.xsd">
> 	<daf:externalVariableBindings xmlns="http://www.w3.org/2001/XMLSchema"
> 		xmlns:ex="http://example.com">
> 		<daf:bind name="ex:var1">-9</daf:bind>
> 		<daf:bind name="ex:var3">-8</daf:bind>
> 	</daf:externalVariableBindings>
> </daf:dfdlConfig>
> {code}
> Unfortunately, that causes a failure:
> {code}
> /home/mbeckerle/dataiti/git/daffodil/daffodil-cli/target/universal/stage/bin/daffodil -v save-parser -s /home/mbeckerle/dataiti/git/daffodil/daffodil-test/src/test/resources/org/apache/daffodil/section07/external_variables/external_variables.dfdl.xsd -r row -c /home/mbeckerle/dataiti/git/daffodil/daffodil-test/src/test/resources/org/apache/daffodil/section07/external_variables/daffodil_config_cli_test.xml test_3507.xsd.bin
> [info] Unable to resolve file:/home/mbeckerle/dataiti/git/daffodil/daffodil-test/src/test/resources/org/apache/daffodil/section07/external_variables/org/apache/daffodil/xsd/dafext.xsd in Some(file:/home/mbeckerle/dataiti/git/daffodil/daffodil-test/src/test/resources/org/apache/daffodil/section07/external_variables/daffodil_config_cli_test.xml)
> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> !!   An unexpected exception occurred. This is a bug!   !!
> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>  Please report this bug and help us fix it:
>   https://daffodil.apache.org/community/#issue-tracker
>  Please include the following exception, the command you
>  ran, and any input, schema, or tdml files used that led
>  to this bug.
> org.xml.sax.SAXParseException; systemId: file:/home/mbeckerle/dataiti/git/daffodil/daffodil-test/src/test/resources/org/apache/daffodil/section07/external_variables/daffodil_config_cli_test.xml; lineNumber: 21; columnNumber: 110; schema_reference.4: Failed to read schema document 'file:/home/mbeckerle/dataiti/git/daffodil/daffodil-test/src/test/resources/org/apache/daffodil/section07/external_variables/org/apache/daffodil/xsd/dafext.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
> 	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
> 	at org.apache.xerces.util.ErrorHandlerWrapper.warning(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaWarning(Unknown Source)
> 	at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument1(Unknown Source)
> 	at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source)
> 	at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
> 	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
> 	at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
> 	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
> 	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
> 	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> 	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> 	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> 	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> 	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
> 	at org.apache.daffodil.xml.DFDLXercesAdapter.loadXML(DaffodilXMLLoader.scala:400)
> 	at scala.xml.factory.XMLLoader.load(XMLLoader.scala:56)
> 	at scala.xml.factory.XMLLoader.load$(XMLLoader.scala:56)
> 	at scala.xml.parsing.FactoryAdapter.load(FactoryAdapter.scala:38)
> 	at org.apache.daffodil.xml.DaffodilXMLLoader.load(DaffodilXMLLoader.scala:562)
> 	at org.apache.daffodil.configuration.ConfigurationLoader$.getConfiguration(ConfigurationLoader.scala:43)
> 	at org.apache.daffodil.configuration.ConfigurationLoader$.getConfiguration(ConfigurationLoader.scala:50)
> 	at org.apache.daffodil.Main$.loadConfigurationFile(Main.scala:589)
> 	at org.apache.daffodil.Main$.run(Main.scala:1181)
> 	at org.apache.daffodil.Main$.main(Main.scala:1379)
> {code}
> Simple things like adding an sbt dependency from daffodil-cli back to daffodil-lib, whether always or "it->test"  dependent, don't fix this.
> The CLI is using DaffodilXMLLoader to load this config file, so the resolver should be doing the right thing by finding this dafext.xsd on the class path inside of daffodil-lib's jar.
>  
> It seems to be erroring out because it is failing upon constructing and not finding the relative path, that is the path creating by concatenating this file's URL with the org/apache/daffodil/xsd/dafext.xsd. That should not be found, but it should then not fail, but go search the class path for the org/apache/daffodil/xsd/dafext.xsd.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)