By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,035 Members | 1,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,035 IT Pros & Developers. It's quick & easy.

Module to read svg

P: n/a
I'm looking for a module to load an SVG document so that I can read out
its contents in some graphics-centric way. For example, path elements
store their vertices in a long attribute string you need to parse. An
ideal module would get me these vertices in a list.

SVGdraw seems to only write, but not read.

I'm interested in a pretty simple subset of the actual spec, where SVG
Tiny is sufficient. W3C's python spec seems just what I want:
http://www.w3.org/TR/SVGMobile12/python-binding.html

Does anyone know if there's an actual free implementation of this?
Before I start salvaging out code from Skencil, is there anything else
I might look at?

Thanks,

Schpok

Jan 8 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
sc****@gmail.com schrieb:
Does anyone know if there's an actual free implementation of this?
For the dom module in it, xml.dom.minidom should work. Depending on
your processing needs, that might be sufficient.

Regards,
Martin
Jan 8 '07 #2

P: n/a
Martin v. Löwis wrote:
sc****@gmail.com schrieb:
>Does anyone know if there's an actual free implementation of this?

For the dom module in it, xml.dom.minidom should work. Depending on
your processing needs, that might be sufficient.
I don't think it quite fits what the OP is asking for. SVG defines some non-XML
structure for some of its contents. For example:

<polyline points="100,200 100,100" />

The OP is asking for a module that would parse the "points" attribute into a list:

[(100.0, 200.0), (100.0, 100.0)]

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Jan 8 '07 #3

P: n/a
sc****@gmail.com wrote:
I'm looking for a module to load an SVG document so that I can read out
its contents in some graphics-centric way. For example, path elements
store their vertices in a long attribute string you need to parse. An
ideal module would get me these vertices in a list.

SVGdraw seems to only write, but not read.

I'm interested in a pretty simple subset of the actual spec, where SVG
Tiny is sufficient. W3C's python spec seems just what I want:
http://www.w3.org/TR/SVGMobile12/python-binding.html

Does anyone know if there's an actual free implementation of this?
Before I start salvaging out code from Skencil, is there anything else
I might look at?
Check out XIST, it seems to have some kind of SVG support.

http://www.livinglogic.de/Python/xist/
http://mail.python.org/pipermail/xml...ne/010325.html

In case you still end up wanting to write something yourself, you might
consider lxml's namespace implementation feature a good starting point.

http://codespeak.net/lxml/element_classes.html

Stefan
Jan 8 '07 #4

P: n/a
Robert Kern schrieb:
>>Does anyone know if there's an actual free implementation of this?
For the dom module in it, xml.dom.minidom should work. Depending on
your processing needs, that might be sufficient.

I don't think it quite fits what the OP is asking for. SVG defines some non-XML
structure for some of its contents. For example:

<polyline points="100,200 100,100" />

The OP is asking for a module that would parse the "points" attribute into a list:

[(100.0, 200.0), (100.0, 100.0)]
Sure, but he also specifically asked for an implementation of

http://www.w3.org/TR/SVGMobile12/python-binding.html

minidom *is* such an implementation (at least of a subset). If I
was to implement the entire thing, I'd base it on top of minidom:
SVGDocument needs to inherit from Document, and SVGSVGElement
needs to inherit from SVGLocatableElement needs to inherit from
SVGElement needs to inherit from Element.

Regards,
Martin
Jan 8 '07 #5

P: n/a
Robert Kern <ro*********@gmail.comwrote:
>Martin v. Lwis wrote:
>sc****@gmail.com schrieb:
>>Does anyone know if there's an actual free implementation of this?

For the dom module in it, xml.dom.minidom should work. Depending on
your processing needs, that might be sufficient.

I don't think it quite fits what the OP is asking for. SVG defines some non-XML
structure for some of its contents. For example:

<polyline points="100,200 100,100" />
Why is that non-XML?
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jan 9 '07 #6

P: n/a
Tim Roberts wrote:
Robert Kern <ro*********@gmail.comwrote:
>Martin v. Löwis wrote:
>>sc****@gmail.com schrieb:
Does anyone know if there's an actual free implementation of this?
For the dom module in it, xml.dom.minidom should work. Depending on
your processing needs, that might be sufficient.
I don't think it quite fits what the OP is asking for. SVG defines some non-XML
structure for some of its contents. For example:

<polyline points="100,200 100,100" />

Why is that non-XML?
Oh, it's valid XML, certainly. However, the data inside the attribute is not
just a bunch of arbitrary characters; it needs to be parsed with a non-XML
parser to get the actual list of points. And unfortunately, "for
space-efficiency" the grammar that describes that data is full of tricks and
shortcuts to save a few characters here and there (actually, I think point lists
are fine; path definitions, though are nuts). See the SVG spec for the full EBNF
grammar.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Jan 9 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.