Re: Bug in ssax:xml->sxml
[email protected] Mon, 20 Jun 2005 13:55:30 -0700 (PDT)
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <[email protected]> |
Hello!
> I am trying to define my own namespace definitions before parsing an xml
> fragment. It does not work.
There is no bug in the SSAX code, but there is a matter of
misunderstanding.
<foo><testns:tag>bar</testns:tag></foo>
That is not well-formed XML (if we take XML Namespace Recommendation
into account): the namespace `testns' is not defined. So, SSAX
correctly reports the error, *as it must* according to that
Recommendation.
The well-formed document would look like
<foo xmlns:testns="http://my/long/URI"><testns:tag>bar</testns:tag></foo>
When you parse it, you'd get
(*TOP* (foo (http://my/long/URI:tag "bar")))
obviously, tag `http://my/long/URI:tag' is a bit too unwieldy to carry
around. That's where user-defined prefixes come in:
gosh> (call-with-input-string testxml
(lambda (port) (ssax:xml->sxml port '((t . "http://my/long/URI")))))
(*TOP* (|@@| (*NAMESPACES* (t "http://my/long/URI"))) (foo (t:tag "bar")))
So, you define the abbreviation 't' that stands for http://my/long/URI
as the namespace URI. The prefix `testns' doesn't occur anywhere -- as
it actually shouldn't by the intention of XML Namespace
Recommendation. The prefix `testns' can still be preserved in the
output of the parser (as some XML activities are alas contrary to the
spirit of XML Namespace Recommendation).
The Section
http://pobox.com/~oleg/ftp/Scheme/SXML.html#Namespaces
discusses this subject of XML Namespaces and prefixes in more detail.
Cheers,
Oleg
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click