See also http://www196.pair.com/lisovsky/xml/index.html
This code needs
myenv-rscheme.scm
and
catch-error.scm
(C) public domain - see: http://www.geocrawler.com/archives/3/15235/2002/1/0/7705636/
BALL makes SXML is available in NameSpaceDSSSL.
When DSSSL expressions return SXML conformant data these are
expanded in the internal representation.
Please note, that the expansion incures an additional traversal
of the data. This and the prefix-embedding of SXML might incure
undesired preformance loss.
SXML elements may only ever occure as return value,
not mixed as "inner" data structures.
To expand the latter use (sxml sxml-tree).
However it is possible to mix ordinary XML result tree fragments,
e.g., as returned by make element or xsl-variable among SXML nodes.
For turtorial see:
http://schematics.sourceforge.net/scheme-uk/xml.html
and
http://sjamaan.ath.cx/temporary/sxslt.pdf
Note: be careful the sxpath functions are not optimal.
When in doubt concerning performance try to get along with the
DSSSL functions. They are faster.
Bugs
The sxml implementation in ball failes on annotations
(namespace declarations) given at the document root
(*TOP*) level:
namespace declarations for these declarations are only included
in the result tree, if the position of the annotations is specified:
(sxml '(*TOP*
(@ (*NAMESPACES* (foo "http://foo.org/foobar")))
(foo:bar (@ (@))
(zoo:baz (@ (@ (*NAMESPACES* (zoo "http://foo.org/foobaz"))))))
))
results in
<foo:bar xmlns:foo="http://foo.org/foobar">
<zoo:baz xmlns:zoo="http://foo.org/foobaz"></zoo:baz>
</foo:bar>
while
(sxml '(*TOP*
(@ (*NAMESPACES* (foo "http://foo.org/foobar")))
(foo:bar (@)
(zoo:baz (@ (@ (*NAMESPACES* (zoo "http://foo.org/foobaz"))))))
))
is beeing serialised as (note the missing namespace foo)
<bar>
<zoo:baz xmlns:zoo="http://foo.org/foobaz"></zoo:baz>
</bar>
Since those declarations could go there anyway, it's
recommended to put declarations always in the attributes list
of the document element.
future of xml
Beware: the XML standard version 1.1 will break SXML,
since "Unicode will continue to grow past version 4.0, further changes to XML can be avoided by allowing almost any character, including those not yet assigned, in names".