CellProfiler / python-bioformats

Read and write life sciences file formats
Other
132 stars 46 forks source link

OMEXML strings generated by python-bioformats cannot be parsed #37

Open hackermd opened 9 years ago

hackermd commented 9 years ago

Generating an OMLXML string

metadata = bioformats.OMEXML()
metadata.to_xml()

produces the following output

'<ome:OME xmlns:ns2="%(NS_BINARY_FILE)s" xmlns:ome="http://www.openmicroscopy.org/Schemas/ome/2013-06s" xmlns:sa="http://www.openmicroscopy.org/Schemas/sa/2013-06s" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2013-06 http://www.openmicroscopy.org/Schemas/OME/2012-03/ome.xsd">\n  <ome:Image ID="Image:0" Name="default.png">\n    <ome:AcquiredDate>%(DEFAULT_NOW)s</ome:AcquiredDate>\n    <ome:Pixels DimensionOrder="XYCTZ" ID="Pixels:0" SizeC="1" SizeT="1" SizeX="512" SizeY="512" SizeZ="1" Type="uint8">\n<ome:Channel ID="Channel:0:0" SamplesPerPixel="1">\n        <ome:LightPath />\n      </ome:Channel>\n      <ns2:BinData BigEndian="false" Length="0" />\n    </ome:Pixels>\n  </ome:Image>\n  <sa:StructuredAnnotations />\n</ome:OME>'

This string cannot be parsed

from lxml import etree

root = etree.fromstring(metadata)

gives

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-e1da52d13adb> in <module>()
----> 1 root = etree.fromstring(metadata)

lxml.etree.pyx in lxml.etree.fromstring (src/lxml/lxml.etree.c:70569)()

parser.pxi in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:106392)()

ValueError: can only parse strings

I'm using python-bioformats (1.0.5) installed via pip.