From: Rupert Swarbrick on
"Frode V. Fjeld" <frodef(a)cs.uit.no> writes:
> I just got around to upload this library which perhaps does what you
> need: http://github.com/frodef/pithy-xml
>
> Here's an intro session:
>
> PITHY-XML> (define-xml-namespace dia "http://www.lysator.liu.se/~alla/dia/")
> DIA
> PITHY-XML> (read-xml "<diagram xmlns:dia='http://www.lysator.liu.se/~alla/dia/' />")
> (:DIAGRAM XMLNS::DIA "http://www.lysator.liu.se/~alla/dia/")
> PITHY-XML> (print-xml *)
> "<Diagram xmlns:dia='http://www.lysator.liu.se/~alla/dia/'/>"

Does it really give "Diagram" (with this capitalisation)? Wouldn't that
be a bug?

Rupert
From: Frode V. Fjeld on
Rupert Swarbrick <rswarbrick(a)gmail.com> writes:

> Does it really give "Diagram" (with this capitalisation)? Wouldn't
> that be a bug?

Well.. this behavior happened to fit my requirements at the time. There
are quite a few ways that can be used to convert :DIAGRAM (or more
generally :SOME-DIAGRAM) to an XML-ish string (and back). I suppose the
solution would be to implement and support them all and set behavior per
namespace. I won't have time for this in the immediate future,
however. Unless I'll happen to need it..

BTW I was aiming for a syntax that was convenient to use from the lisp
side. As opposed to require lisp symbols such ash :|someDiagram| etc.

--
Frode V. Fjeld

From: Thomas A. Russ on
"Frode V. Fjeld" <frode(a)netfonds.no> writes:

> Rupert Swarbrick <rswarbrick(a)gmail.com> writes:
>
> > Does it really give "Diagram" (with this capitalisation)? Wouldn't
> > that be a bug?
>
> Well.. this behavior happened to fit my requirements at the time. There
> are quite a few ways that can be used to convert :DIAGRAM (or more
> generally :SOME-DIAGRAM) to an XML-ish string (and back). I suppose the
> solution would be to implement and support them all and set behavior per
> namespace. I won't have time for this in the immediate future,
> however. Unless I'll happen to need it..
>
> BTW I was aiming for a syntax that was convenient to use from the lisp
> side. As opposed to require lisp symbols such ash :|someDiagram| etc.

Unfortunately, xml is case-sensitive, so reading a tag <diagram...> and
turning it into <Diagram...> is an error.

Perhaps the solution would be to use READTABLE-CASE = :PRESERVE when you
read and write the XML. That will give you keywords like :|diagram|,
but generally if READTABLE-CASE is :PRESERVE, it will print without the
vertical bars.

(let* ((csrt (copy-readtable))
(*readtable* csrt))
(setf (readtable-case csrt) :preserve)
(print (read-from-string "(:digaram :xmlns dia Fred)"))
(terpri))

(:digaram :xmlns dia Fred)

(:|digaram| :|xmlns| |dia| |Fred|)

Of course, you will have to use all uppercase for standard lisp names.

An alternative may be to use :INVERT as the readtable case.


--
Thomas A. Russ, USC/Information Sciences Institute
From: Frode V. Fjeld on
tar(a)sevak.isi.edu (Thomas A. Russ) writes:

> Unfortunately, xml is case-sensitive, so reading a tag <diagram...> and
> turning it into <Diagram...> is an error.

Yes. I believe that translating from a cased string to a typical
mono-case-hyphened willl have to be lossy. However I believe most
applications/namespaces employs some case convention that can be dealt
with. My approach would be to support that on a per-namespace basis.

--
Frode V. Fjeld

From: Thomas A. Russ on
"Frode V. Fjeld" <frode(a)netfonds.no> writes:

> tar(a)sevak.isi.edu (Thomas A. Russ) writes:
>
> > Unfortunately, xml is case-sensitive, so reading a tag <diagram...> and
> > turning it into <Diagram...> is an error.
>
> Yes. I believe that translating from a cased string to a typical
> mono-case-hyphened willl have to be lossy. However I believe most
> applications/namespaces employs some case convention that can be dealt
> with. My approach would be to support that on a per-namespace basis.

But wouldn't it be easier for both you as the supporter and for users to
just do it right from the beginning? If you preserved the case of the
tags when you read them in, then you could write them out the way they
are supposed to be without having to do anything special at all for
particular namespaces.

In other words, if you just use the convention that all namespaces are
case-preserving then you will have solved the problem once and for all.

--
Thomas A. Russ, USC/Information Sciences Institute