[cxml-devel] Possible bug in cxml-stp

Raymond Wiker rwiker at gmail.com
Tue May 22 13:20:47 UTC 2012


On Tue, May 22, 2012 at 2:45 PM, <rm at tuxteam.de> wrote:

> On Tue, May 22, 2012 at 12:03:40PM +0200, Raymond Wiker wrote:
> > On May 22, 2012, at 12:16 , rm at tuxteam.de wrote:
> > > On Tue, May 22, 2012 at 10:43:27AM +0200, Raymond Wiker wrote:
> > >> I'm using cxml-stp to build XML responses for a web service that
> implements Microsoft's "Research" API (actually, this is just a generalised
> search interface). While building this, I found something that looks like a
> bug in cxml-stp. If this is _not_ a bug, I'd be happy for any hint about
> what I'm doing wrong :-)
> > >>
> > >> The attachment contains a small test case which builds an XML
> document and serializes it. The attachment should be compiled and loaded
> after cxml-stp has been loaded, and the commented-out test form at the end
> of the file should then be evaluated.
> > >>
> > >> The test uses two implementations of
> cxml-stp-impl::collect-local-namespaces. With the original implementation,
> the "Status" and "Providers" elements get incorrect xmlns attributes. With
> the modified version, this is not the case.
> > >>
> > >
> > >
> > > Sorry, I don't have much time to investigate your example, but I think
> > > your "fixup" is wrong. Your code (add-element ...) will put the new
> > > element into the namespace with namespace name "", but your "fixup"
> will
> > > emit xml that puts the element into the _default_ namespace (which, in
> > > your example will be "urn:Microsoft.Search.Registration.Response").
> > > A namespace of "" is _not_ the same as no declaration.
> > >
> >
> > add-element calls cxml-stp:make-element, which sets the namespace to ""
> if it is not supplied (or nil). Thus, setting namespace-uri to "" if no uri
> is supplied should not make any difference (and it does not seem to do so -
> I just checked by defaulting namespace-uri to nil instead of "").
>
>
> Yes, that first observation seemsa to be correct. But the conclusion
> isn't. Cxml-stp's assumption seems to be that an unspecified namespace
> means the namespace with uri "" (wich is a valid assumption given that
> every element/attribute _has_ to be in a namespace). What you seem to
> expect is that cxml-stp puts an element with unspecified namespace uri
> into the same namespace as an ancessor element somewhere up the tree
> whose namespace prefix is "". But the element hierarchy isn't even given
> during (cxml-stp:make-element ...).
> Iff you want "Status" to be in the
> "urn:Microsoft.Search.Registration.Response"
> namespace, then put it there. Something like:
>
>
>  (let ((namespace-uri "urn:Microsoft.Search.Registration.Response"))
>    (let ((root
>           (cxml-stp:make-element "ProviderUpdate" namespace-uri)))
>      (add-element root `("Status" ,namespace-uri) nil "SUCCESS")
>      ......
>
>
Aha... thanks.

I was confused about empty namespace uris vs empty namespace tags - I
wanted to create nodes that would be in the same namespace as their parent,
but I now see why that would be problematic.

Thank you for your patience.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cxml-devel/attachments/20120522/1227a46e/attachment.html>


More information about the cxml-devel mailing list