octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML tools for Octave: XML4MAT


From: Alois Schloegl
Subject: Re: XML tools for Octave: XML4MAT
Date: Wed, 17 May 2006 09:18:11 +0200
User-agent: Mozilla Thunderbird 0.9 (Windows/20041103)

Andy Adler wrote:

On Tue, 9 May 2006, Alois Schloegl wrote:

First the good news:

There is now a possiblity to read a general XML file. Thanks to Paul for
patching XML4MAT and David for MAT2CELL.CC and REGEXPREP.CC
If you wants to give it a try: you need
- need the latest octave (with mat2cell and regexprep)
- the patched version XML4MAT
I make this is temporarily available at
http://hci.tugraz.at/schloegl/biosig/xml/XML4MATv21.zip

An XML-file can be loaded with the command XML2CELL. Paul tested it on
Octave, I did the test on Matlab.

The good think is, it converts the XML file into one big variable; so no
complex API's are needed.

I took a quick look at the code you posted from this tool.
In my opinion this code is completely and catastrophically
broken.

1) It parses non-xml files as XML

 Example:
   <xml>v
   <b>v</xml>

2) Is can't parse valid XML

 Example:
   <xml>v
   <b/>v</xml>

 Example:
   <xml tag="<">v</xml>

3) It gives the same output for different files

 Example:
   <xml>v<b>v</xml>

 And
   <xml><b>v</xml>

4) It gives different output of equivalent files:

 Example:
   <xml>v<b>v</xml>

 And
   <xml>v<b>v
   </xml>

The use of a regexp based XML parser is well known
to be a fundamentally wrong approach.

For these reasons, I would recommend that xml2mat
is not a good code base to work with.
--
Andy Adler <address@hidden> 1(613)562-5800x6218


Hi Andy,


what I like on XML4MAT and XMLTREE is, it returns a structure; the fields can be easily accessed and the API is simple. Also I think that XML4MAT is a flawed approach, because it uses to many passes through the data.

So, I used your examples to test XMLTREE.


s{1}=['<xml>v',13,'<b>v</xml>'];

s{2}=['<xml>v',13,'<b/>v</xml>'];
s{3}='<xml tag="<">v</xml>';


s{4}='<xml>v<b>v</xml>';
s{5}='<xml><b>v</xml>';

s{6}='<xml>v<b>v</xml>';
s{7}=['<xml>v<b>v',13,'</xml>'];

for k=1:length(s)
       h=xmltree(s{k})
       try,
       convert(h),
       catch
       end
end;


And get these results:

h =

   XMLTree object (5 nodes) []

ans =

1x1 struct array with no fields.


It parses example 1 . Problem?


h =

   XMLTree object (4 nodes) []


h =

   XMLTree object (2 nodes) []

ans =

1x1 struct array with no fields.

It parses examples 2a and 2b. This seems OK.

h =

   XMLTree object (5 nodes) []

ans =

1x1 struct array with no fields.

h =

   XMLTree object (4 nodes) []

ans =

1x1 struct array with no fields.

The output on examples 3a and 3b is not the same. This seems Ok.

h =

   XMLTree object (5 nodes) []

ans =

1x1 struct array with no fields.

h =

   XMLTree object (5 nodes) []

ans =

1x1 struct array with no fields.


The output for examples 4a and 4b is the same. (Is this a Problem ?)


The homepage of XMLTREE says:
---------
XMLTree: an XML toolbox for Matlab
XML Parser is an XML 1.0 parser written in Matlab. It aims to be fully conforming. It is currently not a validating XML processor. "
---------

Do you think XMLTREE is a reasonable approach and its worth making it useful for Octave?


 Alois



reply via email to

[Prev in Thread] Current Thread [Next in Thread]