Exclude XML data

Discuss SVG code, accessible via the XML Editor.
Sidar
Posts: 11
Joined: Fri Dec 25, 2009 10:37 am

Exclude XML data

Postby Sidar » Sun Oct 02, 2011 9:53 pm

Hi there,

I was wondering if there is a way to exclude certain data( like the actual vector points ) since I only need the position and custom attributes.
(Also I noticed not that all objects have an x and y attribute...Am I doing something wrong? )

thanks,

Sidar
Last edited by Sidar on Mon Oct 03, 2011 4:17 am, edited 1 time in total.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Exlude XML data

Postby ~suv » Mon Oct 03, 2011 1:28 am

Sidar wrote:I was wondering if there is a way to exclude certain data( like the actual vector points ) (…)
Exclude from what, where?
Sidar wrote:(Also I noticed not that all objects have an x and y attribute...Am I doing something wrong? )
You don't tell what you are doing - how should others know whether it's right or wrong? ;)

Hint: a minimal amount of context describing the task you are trying to achieve (with inkscape, with a script extension run from within inkscape, or possibly with external tools parsing SVG files created with Inkscape) might help to get useful answers.

Sidar
Posts: 11
Joined: Fri Dec 25, 2009 10:37 am

Re: Exlude XML data

Postby Sidar » Mon Oct 03, 2011 2:49 am

Exclude from what, where?

I think I was pretty sure we were talking about the XML generated by inkscapes interface. Hence the section SVG/XML Code.

I'm not sure how to question it different than I already have.
There is too much data in the SVG ( which is logical since it represents all the data ), but I have no use for all of it.
I just need the positions of each object created along side their custom attributes.

You don't tell what you are doing - how should others know whether it's right or wrong?


There isn't much to this is there?
Some object do have the X and Y attribute and some don't. All I did was create objects.
I'm asking whether this is normal or not.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Exlude XML data

Postby ~suv » Mon Oct 03, 2011 3:32 am

Sidar wrote:I think I was pretty sure we were talking about the XML generated by inkscapes interface. Hence the section SVG/XML Code.

I'm not sure how to question it different than I already have.
Sorry to have bothered you with my comment/questions then. I'm obviously not skilled to answer the first part of your question.

Sidar wrote:Some object do have the X and Y attribute and some don't. All I did was create objects.
I'm asking whether this is normal or not.
Yes, it is (it depends on what these "objects" are).

Among the objects created with the tools from Inkscape's toolbox
  • only the rectangles (basic SVG shape <rect>) do have x and y attributes [1].
  • The other shapes - special to Inkscape: ellipse/circle, star/polygon, spiral - have cx and cy attributes in the 'sodipodi' namespace (for internal use only - other SVG renderers use the regular path data present in the 'd' attribute). Note: these center coordinates do not yet have the transformations applied which might be present in a 'transform' attribute.
  • Text objects (<text>), clones (SVG: <use>) do have x and y coordinates, as do embedded or linked bitmap images (<image>)
  • For a complete list of which SVG objects can have an 'x' and 'y' attribute (<coordinate>), see this index page in the SVG specification: M.1 Regular attributes. Note that Inkscape itself does not necessarily 'write' all of those object types in its own files, but they can occur in foreign SVG files (even after editing in Inkscape).

You can convert rectangles (and other Inkscape shapes) into regular paths by applying Inkscape's menu command 'Path > Object to Path'. This will create regular SVG paths (<path>) - which do not have x and y attributes - or a group (<g>) of paths (when converting a text object aka outlining it).

[1] <rect> is the only one from the basic SVG shapes listed in the SVG 1.1 spec which Inkscape does create itself (though it can render all of them).

Sidar
Posts: 11
Joined: Fri Dec 25, 2009 10:37 am

Re: Exlude XML data

Postby Sidar » Mon Oct 03, 2011 3:48 am

Thanks.

I guess ill just have to keep all the other data. As well.

Would be nice if there is an option to exclude certain data ( I'm using inkscape as a "level" editor, so I don't really need all the numeral representation of the vector objects).
But there should be a way to create your own parser/exporter no?

User avatar
LiquidAsh
Posts: 71
Joined: Fri Apr 22, 2011 11:35 pm
Contact:

Re: Exclude XML data

Postby LiquidAsh » Sat Nov 05, 2011 2:23 pm

You can certainly write your own output extension to filter some of the data that you don't need.

Honestly, the logic won't be much different, if you'd prefer to start by just writing your own standalone application to strip out the extra information from saved svg files. If this is all your doing, XSL might be a quick way to describe this transformation and what data you are interested in keeping. I'll be putting together a little tutorial next week for a way to plug an executable (like this) into inkscape as an extension.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Exclude XML data

Postby ~suv » Sat Nov 05, 2011 3:15 pm

LiquidAsh wrote:If this is all your doing, XSL might be a quick way to describe this transformation and what data you are interested in keeping. I'll be putting together a little tutorial next week for a way to plug an executable (like this) into inkscape as an extension.
Inkscape can handle XSL-based transformations as extensions internally - there should be no need to use an external (Windows-only) executable. See for example the XAML extension shipping with Inkscape (svg2xaml, xaml2svg).


Return to “SVG / XML Code”