Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Hex dump (e.g. S-Record) from XML via XSLT?

Reply
Thread Tools

Hex dump (e.g. S-Record) from XML via XSLT?

 
 
Ingolf Steinbach
Guest
Posts: n/a
 
      04-21-2008
Hi,

I am searching for an XSLT which takes an input XML file like for
instance

<!-- preamble etc -->
<xPosition>3572</xPosition>
<yPosition>12345</yPosition>
<temperature>3.142</temperature>
<!-- ... -->

and creates a hex dump (for instance S-Record format) using rules
specifying that the number in xPosition shall be encoded as an
unsigned 16-bit integer in big-endian byte order, the same for
yPosition, and that <temperature> shall be encoded as a 32-bit IEEE
floating point, again big-endian? The example above should generate a
line like

S10B00000DF430394049168764

in the output.

Any pointers to solutions to this problem are welcome. If the output
is not S-Record but some other hex-dump like format, that is ok, too.

Do you think that this is possible with an XSLT at all? Would it be
possible without float or endianess support?

Kind regards
Ingolf
 
Reply With Quote
 
 
 
 
Joseph J. Kesselman
Guest
Posts: n/a
 
      04-21-2008
> Do you think that this is possible with an XSLT at all? Would it be
> possible without float or endianess support?


XSLT is a turing-complete programming language, so it's certainly
possible. People have done obscene things like writing
eight-queens-problem solvers in XSLT, or rendering a series of chess
moves as board grids, just to prove that it's possible.

Whether it's *reasonable* is a separate question. XSLT is not the
langauge I would select for this task.
 
Reply With Quote
 
 
 
 
Jürgen Kahrs
Guest
Posts: n/a
 
      04-21-2008
Ingolf Steinbach schrieb:

> and creates a hex dump (for instance S-Record format) using rules
> specifying that the number in xPosition shall be encoded as an
> unsigned 16-bit integer in big-endian byte order, the same for
> yPosition, and that <temperature> shall be encoded as a 32-bit IEEE
> floating point, again big-endian? The example above should generate a
> line like
>
> S10B00000DF430394049168764
>
> in the output.


Such output is probably easier to generate with
a tool like XMLgawk:

http://home.vrweb.de/~juergen.kahrs/...tree-with-gawk

 
Reply With Quote
 
Ingolf Steinbach
Guest
Posts: n/a
 
      04-21-2008
On 21 Apr., 21:41, "Joseph J. Kesselman" <(E-Mail Removed)>
wrote:
> Whether it's *reasonable* is a separate question. XSLT is not the
> langauge I would select for this task.


Can someone recommend a tool* (other than XSLT) suitable for this
task?

Hopefully, interpreting a binary file and displaying the result in XML
-- as well as the other way round (like in my situation) -- is not too
uncommon...

Kind regards
Ingolf

* Any tools (commercial, free ware, ...) are welcome.
 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      04-21-2008
Ingolf Steinbach wrote:
> On 21 Apr., 21:41, "Joseph J. Kesselman" <(E-Mail Removed)>
> wrote:
>> Whether it's *reasonable* is a separate question. XSLT is not the
>> langauge I would select for this task.

>
> Can someone recommend a tool* (other than XSLT) suitable for this
> task?


Any decent programming language. C is the obvious choice.

> Hopefully, interpreting a binary file and displaying the result in XML
> -- as well as the other way round (like in my situation) -- is not too
> uncommon...


No indeed, but I would imagine your chances of finding a prewritten
system for doing your precise task are virtually nil -- unless it
happens to be a common format of data in your particular industry, in
which case your industry's own web sites and forums are a more likely
place to find it than here.

///Peter
 
Reply With Quote
 
Ingolf Steinbach
Guest
Posts: n/a
 
      04-22-2008
On 21 Apr., 23:20, Peter Flynn <(E-Mail Removed)> wrote:
> No indeed, but I would imagine your chances of finding a prewritten
> system for doing your precise task are virtually nil -- unless it
> happens to be a common format of data in your particular industry,

[...]

The idea was to have a tool which allows
- describing the format of a binary file and
- specification of the contents in (human readable) text based form
(both preferably in XML) and doing the conversion from text based
contents to binary.

I would expect this to be quite a general task not limited to a small
and specialized area of applications.

Kind regards
Ingolf
 
Reply With Quote
 
Joseph J. Kesselman
Guest
Posts: n/a
 
      04-22-2008
Websearch on "data binding", which is the general term for mapping
standard representations such as XML over arbitrary back-end data such
as your binary dump.

Various tools have been proposed. It's been a while since I've looked at
this, so I'm not sure where the current state of the art stands.
 
Reply With Quote
 
Ingolf Steinbach
Guest
Posts: n/a
 
      04-22-2008
On 21 Apr., 22:00, Jürgen Kahrs <(E-Mail Removed)>
wrote:
> Such output is probably easier to generate with
> a tool like XMLgawk:
>
> http://home.vrweb.de/~juergen.kahrs/...ml#How-to-trav...


Thank you, Jürgen, for the pointer. The examples in that document seem
to suggest that xmlgawk is used mainly for rearranging data (replacing
tags by other text but leaving the actual data mostly as is) rather
than *transforming* the data. Is this observation correct?

Kind regards
Ingolf
 
Reply With Quote
 
Philippe Poulard
Guest
Posts: n/a
 
      04-23-2008
Ingolf Steinbach a écrit :
> On 21 Apr., 22:00, Jürgen Kahrs <(E-Mail Removed)>
> wrote:
>> Such output is probably easier to generate with
>> a tool like XMLgawk:
>>
>> http://home.vrweb.de/~juergen.kahrs/...ml#How-to-trav...

>
> Thank you, Jürgen, for the pointer. The examples in that document seem
> to suggest that xmlgawk is used mainly for rearranging data (replacing
> tags by other text but leaving the actual data mostly as is) rather
> than *transforming* the data. Is this observation correct?


Perhaps a more suitable tool would be a SAX parser : you read the input
XML and you write whatever suitable for your application. SAX parsers
are available in every popular language and your own part would consist
for example when you match the <temperature> element on buffering the
text content, parse it as a float, and dump it. Most languages supply
such basic tools and you just have to put them all together.

Regards,

--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
 
Reply With Quote
 
Jürgen Kahrs
Guest
Posts: n/a
 
      04-23-2008
Hello Ingolf,

>> Such output is probably easier to generate with
>> a tool like XMLgawk:
>>
>> http://home.vrweb.de/~juergen.kahrs/...ml#How-to-trav...

>
> Thank you, Jürgen, for the pointer. The examples in that document seem
> to suggest that xmlgawk is used mainly for rearranging data (replacing
> tags by other text but leaving the actual data mostly as is) rather
> than *transforming* the data. Is this observation correct?


No, transforming data is also possible. For example,
I have written AWK scripts for doing linear regression
(statistics) or a simple recursive-descent compiler.
Just look at the other examples. For example the one
that transforms an XML file into a graph drawing:

http://home.vrweb.de/~juergen.kahrs/...-tree-drawings
http://home.vrweb.de/~juergen.kahrs/...ok_chapter.jpg

XMLgawk is based on a SAX parser and handles each
tag separately. If you prefer to work with a DOM
parser (because you need access to the complete
DOM tree), then XMLgawk is not as convenient as
you might need a tool.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dump complete java VM state as core dump (not via OS) possible? halfdog Java 12 02-21-2013 06:14 AM
How to read/write continuous hex dump using STL capnwhit@yahoo.com C++ 7 06-30-2007 11:47 PM
Hex Color Codes - Hex 6 <=> Hex 3 lucanos@gmail.com HTML 10 08-18-2005 11:21 PM
Usage of Hex Dump in C++ Programming Matt C++ 4 07-29-2004 10:02 PM
hex(-5) => Futurewarning: ugh, can't we have a better hex than '-'[:n<0]+hex(abs(n)) ?? Bengt Richter Python 6 08-19-2003 07:33 AM



Advertisments