[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sxml simple, sxml->xml and namespaces
From: |
Andy Wingo |
Subject: |
Re: sxml simple, sxml->xml and namespaces |
Date: |
Tue, 21 Jun 2016 22:58:36 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Hi,
On Tue 21 Jun 2016 22:36, Ricardo Wurmus <address@hidden> writes:
> This is the same patch I sent to the discussion of bug#20339 about a
> year ago.
Yeah sorry for the miscommunication; two lists, split brain.
> The patch is not very ambitious: it only gives the user a way around the
> error by letting them pass an alist of namespaces. The patched
> “sxml->xml” does not attempt to be smart about anything. It will still
> fail if it encounters an undeclared namespace.
This sounds fine to me to be honest.
> ;; Define SVG document with namespaces
> (define the-svg "<svg xmlns='http://www.w3.org/2000/svg'
> xmlns:xlink='http://www.w3.org/1999/xlink'>
> <rect x='5' y='5' width='20' height='20'
> stroke-width='2' stroke='purple' fill='yellow'
> id='rect1' />
> <rect x='30' y='5' width='20' height='20'
> ry='5' rx='8' stroke-width='2' stroke='purple' fill='blue'
> xlink:href='#rect1' />
> </svg>")
>
> ;; Define alist of namespaces
> (define ns '((svg . "http://www.w3.org/2000/svg")
> (xlink . "http://www.w3.org/1999/xlink")))
>
> ;; Convert to SXML, abbreviate namespaces according to ns alist
> (define the-sxml (xml->sxml the-svg #:namespaces ns))
>
> ;; Convert back to XML
> (sxml->xml the-sxml #:namespaces ns)
>
> => <svg:svg xmlns:svg="http://www.w3.org/2000/svg"
> xmlns:xlink="http://www.w3.org/1999/xlink">
> <svg:rect y="5" x="5"
> width="20"
> stroke-width="2"
> stroke="purple"
> id="rect1"
> height="20"
> fill="yellow" />
> <svg:rect xlink:href="#rect1"
> y="5" x="30"
> width="20"
> stroke-width="2"
> stroke="purple"
> ry="5" rx="8"
> height="20"
> fill="blue" />
> </svg:svg>
This doesn't seem quite right to me, in the sense that it should be
possible to specify default namespaces (i.e. xmlns=..., not requiring
xmlns:svg=...). What do you think? The patch window is wide open :)
Andy