473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Module to read svg

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
6 3538
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
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
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
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
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?
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jan 9 '07 #6
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter Åstrand | last post by:
There's a new PEP available: PEP 324: popen5 - New POSIX process module A copy is included below. Comments are appreciated. ---- PEP: 324 Title: popen5 - New POSIX process module
8
by: Philippe C. Martin | last post by:
Hi, I'm getting pretty desperate here: The code below crashes on the last line (but works from a shell). The class 'BC' exists and the loop on self.__BC_EXEC_LIST passes fine. It's got to...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
3
by: JimF | last post by:
I need to scan a couple of hundred databases in several directories to locate all code that uses a particular function, but cannot figure out how to read the Form or Module text itself. I am...
8
by: Floris van Haaster | last post by:
Hi All! I have a question, i have a web application and I store some member information in a variable i declared in a module like: Public some_info_variable as string in module1.vb But...
14
by: ccdetail | last post by:
http://www.tiobe.com/index.htm?tiobe_index Python is the 7th most commonly used language, up from 8th. The only one gaining ground besides VB in the top 10. We're glad, our app is written in...
13
by: André | last post by:
Hi, i'm developping asp.net applications and therefore i use VB.net. I have some questions about best practises. According what i read about class and module and if i understand it right, a...
9
by: flebber | last post by:
I was working at creating a simple program that would read the content of a playlist file( in this case *.k3b") and write it out . the compressed "*.k3b" file has two file and the one I was trying...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
8
by: Derek Martin | last post by:
I'd like to know if it's possible to code something in Python which would be equivalent to the following C: ---- debug.c ---- #include <stdio.h> bool DEBUG;
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.