> > I have just added an example file into the SSAX CVS repository:
> > SSAX/examples/daml-parse-unparse.scm
> Sure? Which cvs repository? Not the sourceforge one, just checked.
Hmm. Indeed. I distinctly remember committing the code. I did it
again, and now it's definitely there:
The code traverses the SXML tree twice: once to design the translation
from SXML names to XML names and find out about all the namespaces; On
the second traversal, the code emits XML. It is actually possible to
do everything in only one pass. The latter would require a different
traversal combinator (accum-pre-post-order rather than
pre-post-order). Besides, it was past midnight already when I wrote
the code, so I chose the easy way out.
I have just noticed that I used a match-case special form,
which is Bigloo specific:
I believe many other systems have something similar (DrScheme, for
example). match-case has a distinct feature: non-linear patterns. I
don't use that feature however. Finally,
defines a somewhat similar (but unoptimized) pattern matcher and the
corresponding special binding form. However ungainly, the latter
matcher can do what Bigloo's match-case can do. The latter matcher
should run on any R5RS Scheme.
> My requirements can be relaxed to
> (lambda (str)
> (string=? (xml-format (xml-parse (xml-format (xml-parse str))))
> (xml-format (xml-parse str))))
> => #t for any string str.
UNPARSE . PARSE . UNPARSE . PARSE === UNPARSE . PARSE
The property above can be derived from the invariant of unparsing I
PARSE . UNPARSE . PARSE === PARSE
by left-multiplying by 'UNPARSE'. That is, I do believe your
requirements will be satisfied.
> Hey, what are you doing with agents?
... described in the next message ;)
From: Joerg F. Wittenberger <Joerg.W<ittenberger@po...> - 2002-11-15 12:53:14
> The code traverses the SXML tree twice: once to design the translation
> from SXML names to XML names and find out about all the namespaces; On
I understand there was a missunderstanding due to me presumtions. I
need a way to recognize arbitrary namespace declarations in an XML
file and somehow keep the declarations (local prefixes) with the
elements where they where declared.
The code I used to use kept namespace declarations as if they where
attribute assignments with the elements...
The code in Askemos does not (yet) use SXML, instead elements (for
instance) are kept in records like this:
(make-xml-element name ns attributes content)
i.e. instead of symbols of the form 'url:local' the local name and
namespace url are stored in different fields. This should presumably
save processing when xslt matches of the form 'namespace:*' are
tested. (wouldn't it?)
Until now the declarations appear in the attributes field as any other
attributes do. BTW is that correct with the XML specs? (If not I
should modify the record to keep the declarations separate or maybe
filter in the accessor function.)
My problem is, that the SSAX code leaves me without access to the
parsed declarations, hence the prefix is lost. Your'e appear to
circumvent the problem by use of preassigned prefixes, which I can
Is there a way to do that with unmodified SSAX? Meanwhile I dove
deeper into the sources and I believe I'll have to modify the
prototype (and calling code) for the FINISH-ELEMENT handler (and
should do the same with the START-ELEMENT handler for consistency).
The worst of harm may often result from the best of intentions.