Re: XML support in E

Mark Miller <[email protected]>
Newsgroups gmane.comp.lang.e.general
Message-ID <[email protected]>
On Fri, Jan 15, 2010 at 4:47 AM, Kevin Reid <[email protected]> wrote:

> On Jan 15, 2010, at 6:12, Thomas Leonard wrote:
> > OK, I can create JSON documents easily enough using
> >
> > def Term := <type:org.quasiliteral.term.Term>
> > def serialised := (testData :Term).asText()
> >
> > This is nice and fast, and I assume it could produce XML in a
> > similar way.
>
> Huh, I didn't know that worked except for leaf types. (I find that the
> relevant code is in
> org.erights.e.meta.org.quasiliteral.astro.AstroGuardSugar.)
>
>
Yes. The first test case at src/jsrc/org/quasiliteral/term/Term.updoc is

    ? [3=>4, "a"=>'x', [2,3]=>[4,5]]:Term
    # value: term`{3: 4,
    #              "a": 'x',
    #              [2, 3]:
    #                  [4, 5]}`

which exercises some of the interesting cases.



> > I can turn the serialised string back into a term like this:
> >
> > def TermParserMaker := <import:org.quasiliteral.term.makeTermParser>
> > TermParserMaker(serialised)
> >
> > But how do I turn that term back into the E data-structure (i.e.
> > reverse the effect of :Term)?
>
> I don't know of a facility to do this. (deJSONKit does so the long way
> around.) MarkM?
>
> For leaf data terms, their __conformTo already knows how to auto-coerce to
their primitive data value.

Kevin, regarding non-leaf terms, I recall you once wrote such a guard as an
experiment, but I don't think we ever added it to the E library. As I
recall, at the time you may have called it Termish. But that conflicts with
a different use of that name in the org.quasiliteral.term package. I may be
misremembering.




> --
> Kevin Reid                                  <http://switchb.org/kpreid/>
>
>
>
>
> _______________________________________________
> e-lang mailing list
> [email protected]
> http://www.eros-os.org/mailman/listinfo/e-lang
>



-- 
Text by me above is hereby placed in the public domain

   Cheers,
   --MarkM

_______________________________________________
e-lang mailing list
[email protected]
http://www.eros-os.org/mailman/listinfo/e-lang
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.