XSLT converts svg to shapes

2007-07-13 Thread Sam Liddicott
This xslt will convert inkscape's PLAIN svg files to dia shapes.

  xsltproc svg2shape.xslt --stringparam icon-file firewall.icon \
  firewall.svg  firewall.shape

The attached bash script genshape will use inkscape to export the icon
and the simple svg and converts this to the shape file all in one go.

DIA-isms

Here is how the standard dia meta data is obtained:

1. The first text with id textbox is converted into the shape's
textbox and removed from the svg.

The text in this text becomes the name of the shape.

2. All items with an id that begins with connector_ generate a
connectionspoint tag with the connection point in the middle.

This is calculated by taking the average of the min and max x points and
the min and max y points.

The min and max taken from attributes x, x1, x2, width and pulling out
all the X coordinates in draw paths, or y, y1, y2, height or all of the
Y coordinates in the draw paths (@d attribute)

There are also some -isms to correlate the -isms in shape2svg, such that
the connections were put into a connections layer and the shape was
put into a shape layer.

inkscape is explicit about draw styles, so there was no need to fixup
assumptions when converting to shape.

BUGS:

Currently I do NOTHING about transforms or groups or other svg forms
that dia can't handle.

I don't preserve the order of connection points, ubt I don't think it
matters.

I still haven't worked out how to get xsltproc to generate the right
namespace prefixes.


So where does this leave us?

I can make simple drawings (and moderately complex ones) in SVG.

1. I just make sure the ID for visual connection points begins with
connection_,
2. I make sure there is a text area with id textbox and contents
Network -Firewall or whatever.

then I can convert and make a shape file really easily!

Sam



svg2shape.xslt
Description: application/xml

#! /bin/bash

PNG=`dirname $1`/`basename $1 .svg`.png
SHAPE=`dirname $1`/`basename $1 .svg`.shape

# generate png
inkscape -e $PNG -w 22 $1

# generate simple svg
inkscape --export-plain-svg=/dev/stdout $1 | \
xsltproc --stringparam icon-file `basename $PNG` xslt/svg2shape.xslt - \
   $SHAPE
___
Dia-list mailing list
Dia-list@gnome.org
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia



Re: XSLT converts svg to shapes

2007-07-13 Thread Steffen Macke
Hi Sam,

thanks a lot for these tools! I have to test them. Would it be
possible to include
them in the Dia distribution (=put them under the GPL)?

Maybe we can hook up the shape-svg thing with the XSLT plug-in. For the
svg-shape way, we would need an XSLT-import plug-in. Or add it to the Sheets
and Objects dialog...

Regards,

Steffen
___
Dia-list mailing list
Dia-list@gnome.org
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia



RE: XSLT converts svg to shapes

2007-07-13 Thread Sam Liddicott
(Sorry about top quoting and other sins of Pocket Outlook).

For sure. © 2007 Ufomechanic.
Licensed under GPL 2 or later.

If you use libxslt (part of gnome) it should work straight off.

Sheets and object diaglog is better than an import plugin I think. I guess when 
and svg sheet is loaded it should do what the bash script does - or rather it 
should be able to generate it's own icon.

I guess this means that sheet xml ought to b able to reference svg files as 
well as shape.

I'll get the svg2shape to take inkscape svg and filter out all the sodipodi 
stuff.

Sam


-Original Message-
From: Steffen Macke [EMAIL PROTECTED]
To: discussions about usage and development of dia dia-list@gnome.org
Sent: 13/07/07 19:05
Subject: Re: XSLT converts svg to shapes

Hi Sam,

thanks a lot for these tools! I have to test them. Would it be
possible to include
them in the Dia distribution (=put them under the GPL)?

Maybe we can hook up the shape-svg thing with the XSLT plug-in. For the
svg-shape way, we would need an XSLT-import plug-in. Or add it to the Sheets
and Objects dialog...

Regards,

Steffen
___
Dia-list mailing list
Dia-list@gnome.org
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia


___
Dia-list mailing list
Dia-list@gnome.org
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia