Fw: Re: [plt-scheme] ssax and namespace handling

From: Dmitry Lizorkin (lizorkin at ispras.ru)
Date: Wed Apr 30 03:14:14 EDT 2008

----- Original Message ----- 
From: <oleg at okmij.org>
To: <lizorkin at ispras.ru>
Sent: Wednesday, April 30, 2008 4:57 AM
Subject: Re: Fw: [plt-scheme] ssax and namespace handling


> In particular, in WSDLs there are namespace prefixes declared that are
> not used in the element tags but as values in attributes

If I may make a side remark, using namespace prefixes in attributes,
(in quoted strings!) is one of the worst offenses, of many the WSDL
(and XML Schema) authors have committed. One should not be surprised
that XML Schema and WSDL meet nothing but disdain in the programming
language community. I wish standards bodies had imposed minimum
qualification requirements on its members.

As to the problem at hand, it can be solved by a non-standard
instantiation of the SSAX parser. In particular, the FINISH-ELEMENT
handler of ssax:xml->sxml needs to be modified. It contains the
following code

       (lambda (attr accum)
(cons (list
(if (symbol? (car attr)) (car attr)
    (RES-NAME->SXML (car attr)))
(cdr attr)) accum))
       '() attributes)

Here, (cdr attr) is the value of the attribute. One has to examine the
value (perhaps for attributes with a particular name: (car attr) is the name 
the attribute, a symbol or RES-NAME) and adjust it if needed, e.g.,
replacing namespace prefixes with shorthands or the full namespace
URLs -- whatever is appropriate to make (S)XPath happy. Or, the
examination of the attribute value (check if (string-prefix? value
namespace-prefix) for any namespace-prefix) can tell that some
namespace-prefix is being used in the document, and so should be
retained in the SSAX output (or a @@ node should be created for it).


Posted on the users mailing list.