Page 2 of 2

Re: help on loci.formats.tools.XMLValidate

PostPosted: Wed Nov 28, 2018 11:33 am
by dgault
It might be that the logging level needs updated in order to return the same level of logging as the command line tools. You can change the logger level as below:

Code: Select all
loci.common.DebugTools.setRootLevel('INFO');


or for even more detail:

Code: Select all
loci.common.DebugTools.setRootLevel('DEBUG');

Re: help on loci.formats.tools.XMLValidate

PostPosted: Thu Dec 06, 2018 3:30 pm
by Kouichi_C_Nakamura
When I analyze purposefully distorted OME-XML file using the command line tools, the command line output looks like this.

Code: Select all
>> [status,res]= system(sprintf('%s "%s"',xmlvalid,"C:\xxxxxxxxxx\Desktop\boats.ome.xml"))
status =
     0
res =
    'Parsing schema path
     Error parsing schema path from C:\xxxxxxxxxx\Desktop\boats.ome.xml
     org.xml.sax.SAXParseException: Attribute "PhysicalSizeXUnit" was already specified for element "Pixels".
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanAttribute(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at javax.xml.parsers.SAXParser.parse(Unknown Source) ~[na:1.8.0_191]
        at loci.common.xml.XMLTools.validateXML(XMLTools.java:653) [bioformats_package.jar:5.8.2]
        at loci.common.xml.XMLTools.validateXML(XMLTools.java:627) [bioformats_package.jar:5.8.2]
        at loci.formats.tools.XMLValidate.process(XMLValidate.java:60) [bioformats_package.jar:5.8.2]
        at loci.formats.tools.XMLValidate.main(XMLValidate.java:81) [bioformats_package.jar:5.8.2]
     '



The most of the stack tace is not useful, but the line "org.xml.sax.SAXParseException: Attribute "PhysicalSizeXUnit" was already specified for element "Pixels"." is crucial.

At the moment, when I run `res = loci.common.xml.XMLTools.validateXML(xml, "XML");` instead, initially there was no command line output.

Using this
Code: Select all
loci.common.DebugTools.enableLogging();

resulted in the command line output as below (much simpler than the above):

Code: Select all
Parsing schema path

Error parsing schema path from XML


futher executing

Code: Select all
loci.common.DebugTools.setRootLevel('DEBUG');


or

Code: Select all
loci.common.DebugTools.setRootLevel('INFO');


or

Code: Select all
loci.common.DebugTools.enableIJLogging(true);


doesn't seem to make a difference.


Looking at the source code (https://github.com/ome/ome-common-java/ ... .java#L788), perhaps I need to specify the third input argument `schemaReader` to get a detailed error message??? I don't really know what `schemaReader` is about, though.

Re: help on loci.formats.tools.XMLValidate

PostPosted: Fri Dec 07, 2018 1:49 pm
by dgault
You shouldn't need to specify the schemaReader, this should be automatically parsed from the XML itself, however it seems to have resulted in the exception while parsing the schema path.

If you open the XML do any of the Pixels elements have multiple 'PhysicalSizeXUnit' attributes?

Re: help on loci.formats.tools.XMLValidate

PostPosted: Fri Dec 07, 2018 4:18 pm
by Kouichi_C_Nakamura
If you open the XML do any of the Pixels elements have multiple 'PhysicalSizeXUnit' attributes?


Yes, I duplicated it for the testing purpose.

Re: help on loci.formats.tools.XMLValidate

PostPosted: Mon Dec 10, 2018 11:08 am
by dgault
The duplicate attributes on Pixels look as though they are causing the issue. If they are removed it should run without the Exception which you are seeing.

Re: help on loci.formats.tools.XMLValidate

PostPosted: Mon Dec 10, 2018 11:28 am
by Kouichi_C_Nakamura
Sorry, but I'm afraid that you might have missed the point of this testing.

By directly using Java API, I want to retrieve the same command line output as the one we obtain with Command Line Tools. If I validate a correct OME-XML, the output is much shorter without a stack trace.

Code: Select all
Parsing schema path
     http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd
     Validating C:\Users\xxxxxx\Desktop\tpc2a8e01c_d4f2_4276_9cc3_e110b708be07.ome.tif
     No validation errors found.



But when I validate a wrong OME-XML, I get detailed command line output with Command Line Tools.

Code: Select all
'Parsing schema path
     Error parsing schema path from C:\Users\xxxxxxx\Desktop\boats.ome.xml
     org.xml.sax.SAXParseException: Attribute "PhysicalSizeXUnit" was already specified for element "Pixels".
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanAttribute(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source) ~[bioformats_package.jar:5.8.2]
        at javax.xml.parsers.SAXParser.parse(Unknown Source) ~[na:1.8.0_191]
        at loci.common.xml.XMLTools.validateXML(XMLTools.java:653) [bioformats_package.jar:5.8.2]
        at loci.common.xml.XMLTools.validateXML(XMLTools.java:627) [bioformats_package.jar:5.8.2]
        at loci.formats.tools.XMLValidate.process(XMLValidate.java:60) [bioformats_package.jar:5.8.2]
        at loci.formats.tools.XMLValidate.main(XMLValidate.java:81) [bioformats_package.jar:5.8.2]



And this is what I want to reproduce by accessing Java API from MATLAB. At the moment, using `loci.common.DebugTools.enableLogging();`, it looks like:

Code: Select all
Parsing schema path

Error parsing schema path from XML


Of course, this is not very informative.

Re: help on loci.formats.tools.XMLValidate

PostPosted: Tue Dec 11, 2018 4:04 pm
by dgault
Sorry, I may have misunderstood, I have been trying today to see if I can reproduce the issue and get the stack trace to display but so far have had no such luck. I will continue to investigate and keep you update if I find a solution.