octave-maintainers
[Top][All Lists]
Advanced

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

Re: XML tools for Octave


From: Andy Adler
Subject: Re: XML tools for Octave
Date: Thu, 29 Jun 2006 15:08:21 -0400 (EDT)

On Thu, 29 Jun 2006, Bill Denney wrote:

On Thu, 29 Jun 2006, Andy Adler wrote:

I honestly don't know how to address this. Your suggestion would basically mean that we expose the full DOM API. Matlab did this with a thin wrapper over Java's DOM.

However, this is a really bad idea. It means that all the effort of
XML parsing falls on the user - who will either make mistakes or
shortcuts, with the result of really fragile code.

For example a user will parse
    <data><item> 1 </item></data>

using
  v.data.CHILD{1}.item.TEXT{1}

But this will break when you have
    <data> <item> 1 </item></data>

or
    <data><metadata/><item> 1 </item></data>

That's true, but users will always write fragile code like that. One option around this would be to have options like "strip-space" (taking a cue from XSL: http://www.w3schools.com/xsl/el_preserve-space.asp) that would relatively intelligently help the user. Perhaps make stripping spaces the default would be most helpful to the users.

I don't think parsers should take options like that. I think the
interpreter variables that John recently got rid of in Octave are a good example.

But the issue here is the extensibility at the heart of XML. The point
is that you should be able to add extra information (the <metadata/>)
and a parser for the old format should still work

Here is my latest idea for the format:
 <a b="c" d="e"> text <f g="h"/> more <é->text</é-> <f>data</f></a>

 v.a.UTFNAME         : "a"
 v.a.NAMESPACE       : ""
 v.a.ORDER           : 1
 v.a.ATTS.b          : "c"
 v.a.ATTS.d          : "e"
 v.a.TEXT{1}         : " text "
 v.a.TEXT{2}         : " more "
 v.a.TEXT{3}         : " "

 v.a.f{1}.UTFNAME    : "f"
 v.a.f{1}.NAMESPACE  : ""
 v.a.f{1}.ORDER      : 2
 v.a.f{1}.ATTS.g     : "h"

 v.a.f{2}.UTFNAME    : "f"
 v.a.f{2}.NAMESPACE  : ""
 v.a.f{2}.ORDER      : 6
 v.a.f{2}.TEXT{1}    : "data"

 v.a.e_{1}.UTFNAME    : "é-"
 v.a.e_{1}.NAMESPACE  : ""
 v.a.e_{1}.ORDER      : 4
 v.a.e_{1}.TEXT{1}    : "text"

Here I keep the order of the tags in each tag. The text elements are
then interspersed between them. Names (like é- are modified, but
the original is kept, as required).

Comments?

--
Andy Adler <address@hidden> 1(613)562-5800x6218

reply via email to

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