[Nexus-developers] [Nexus] XML format--A way to serialize binary?
Peterson, Peter F.
petersonpf at ornl.gov
Fri Dec 8 16:25:33 GMT 2006
Brian,
I have been interested in producing a C++ wrapper around the napi for
some time. Would you be willing to share this code with NeXus and
possibly incorporate it into a future release?
P^2
-----Original Message-----
From: nexus-bounces at nexusformat.org
[mailto:nexus-bounces at nexusformat.org] On Behalf Of tieman
Sent: Friday, December 08, 2006 10:39 AM
To: Mark Koennecke; Nexus List
Subject: Re: [Nexus] XML format--A way to serialize binary?
Mark,
Comments inline...
Mark Koennecke wrote:
> Dear Brian Tiemann,
>
> tieman schrieb:
>> Hello all!
>>
>> After much trial and tribulation (linking on Windows is a nightmare!)
>> I have all my windows programs using Nexus 3.0...on to linux!
>>
>> Well, not quite yet...is there a way to serialize binary data into a
>> more compact format with NAPI? I generally need to write image data
>> that can be quite large. The "default" serialization method
>> generates an ascii string for each pixel. While this is very
>> readable--it typically makes the files 4-5 times larger than encoding
>> the data as binary. It would be nice to be able to write the image
>> data as a raw binary dump to save space.
>>
>>
> We implemented NeXus-XML in order to:
> * be buzword compliant
> * allow people to edit their data...
> So the editable data is by design. If you want efficiency, use HDF-5.
> In principle you can
> convert your data into an UINT8 array and print that as hex. The
> NeXus-API allows to set
> the format strings for printing numbers. This will yield a compact
> representation but will not be readable
> with the NeXus-API.
Hmmm...seems like a simple hack in the Nexus-API should handle this. If
the appropriate flag is set, serialize binary data as a byte stream and
tag it such that we can unserialize it properly on read...I'm not sure
I'll ever need this feature, but I do currently have a web app that
reads Nexus nexus files and passes them over the net as serialized XML
in this manner so I did want to at least try writing XML formatted data.
>> I don't anticipate needing the use the XML format often, but XML
>> would make it easier to write a web app that can browse the data
>> online for instance...
>>
>>
> Well, how do you write your web apps? If you do Java servlets, you may
> use the NeXus-Java interface.
> If you do Tcl you may use the SWIG generated wrapper around the
> NeXus-API, if you use perl or php
> you may help out with your knowledge to make the SWIG interface to
> those languages tick. This is
> little work. If you use python, contact Peter Peterson, they have a
> python interface to NeXus.
>
I use Java. I do not, and probably will not, use the NeXus-Java
interface. The reason is that I have a C++ wrapper around Nexus that
I've been using for many years now. The C++ wrapper maps the data file
to a data tree that can be accessed easily by paths and is an even
higher level interface than Napi. This has been linked to Java and
other languages through a simple C wrapper that has also been in use for
years now. In short--now that I have a robust class structure that's
cross platform and well integrated into a number of apps--I don't want
to change it :)
Thanks!
Brian
_______________________________________________
NeXus mailing list
NeXus at nexusformat.org
http://lists.nexusformat.org/mailman/listinfo/nexus
More information about the NeXus-developers
mailing list