incompatible Kawa change: symbol vs. java.lang.String

Per Bothner per@bothner.com
Tue Apr 3 17:46:00 GMT 2007


Hoehle, Joerg-Cyril wrote:
> I've put the Java-String <-> Scheme Symbol mapping to great (IMHO) use
> in a XML to Scheme SXML converter.  The core issue is that as Scheme
> symbols, all Java strings would be uniq'ified. EQ and MEMQ are useable
> to match XML element names.

 > If I understand the implications of this incompatible change in Kawa
 > right, code depending on this property of Scheme symbols originating
 > from <String> would break.

Yes.

The Kawa recommendation is to represent XML element names
using symbols, not strings.

If you use:
   (define-xml-namespace PREFIX "URI")
then you can write:
   'PREFIX:LOCAL-NAME
and
   (PREFIX:LOCAL-NAME CONTENT ...)
evaluates to a gnu.kawa.xml.KElement object.  For example:
   (foo:a attr:"ATTR" "text" (foo:child))

You can even do:
   (foo:,(string-append "aa" "b3") "text")
to get a KElement whose tag is foo:aab3.

Unfortunately
   `foo:,(string-append "aa" "b3")
doesn't work, though it's probably a simple fix.

These are the same data types used for Kawa's XQuery
implementation.

Of course you can just use namespaces and symbols without using
the KNode/KElement classes.


-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/



More information about the Kawa mailing list