We're Hiring!

help on loci.formats.tools.XMLValidate

Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats
Please note:
Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats

If you are having trouble with image files, there is information about reporting bugs in the Bio-Formats documentation. Please send us the data and let us know what version of Bio-Formats you are using. For issues with your code, please provide a link to a public repository, ideally GitHub.

Re: help on loci.formats.tools.XMLValidate

Postby dgault » Wed Nov 28, 2018 11:33 am

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');
User avatar
dgault
Team Member
 
Posts: 197
Joined: Fri Aug 14, 2015 2:56 pm

Re: help on loci.formats.tools.XMLValidate

Postby Kouichi_C_Nakamura » Thu Dec 06, 2018 3:30 pm

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.
Kouichi_C_Nakamura
 
Posts: 131
Joined: Thu Oct 19, 2017 1:35 pm

Re: help on loci.formats.tools.XMLValidate

Postby dgault » Fri Dec 07, 2018 1:49 pm

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?
User avatar
dgault
Team Member
 
Posts: 197
Joined: Fri Aug 14, 2015 2:56 pm

Re: help on loci.formats.tools.XMLValidate

Postby Kouichi_C_Nakamura » Fri Dec 07, 2018 4:18 pm

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


Yes, I duplicated it for the testing purpose.
Kouichi_C_Nakamura
 
Posts: 131
Joined: Thu Oct 19, 2017 1:35 pm

Re: help on loci.formats.tools.XMLValidate

Postby dgault » Mon Dec 10, 2018 11:08 am

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.
User avatar
dgault
Team Member
 
Posts: 197
Joined: Fri Aug 14, 2015 2:56 pm

Re: help on loci.formats.tools.XMLValidate

Postby Kouichi_C_Nakamura » Mon Dec 10, 2018 11:28 am

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.
Kouichi_C_Nakamura
 
Posts: 131
Joined: Thu Oct 19, 2017 1:35 pm

Previous

Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 1 guest

cron