XSLT converts shapes to svg
This xslt will convert dia shapes to svg editable by inkscape. xsltproc shape2svg.xslt firewall.shape > firewall.svg (A lot of the .shape files are BAD svg subset, with the semi-colon seperator missing in the style attributes sometimes). The connection points are preserved in a "connections" layer, and the textbox position is also preserved. The width and height (which dia ingores) ARE used to set the document size. The plan is to be able to convert inkscape back to shape files, regenerating the connections etc (doing what we can about transforms etc) so that I can use inkscape to create shapes. The general problem is matching dia style assumptions to svg style assumptions (i.e. whether or not a closed shape defaults to fill, or not), but I've got that down to: fill:none stroke:#00 stroke-width:0.1 fill:default = fill:#ff fill:foreground = fill:#00 fill:background = fill:ff A larger problem is to do with line-width and coordinate handling; it seems like I need to divide the stroke-width by 10 when converting to inkscape. An example is the Network/firewall.shape which has lines with length 0.4 and stroke-width 1. dia renders that specific line with the stroke-width 1/4 of the line length. (from the shape file: ) Any comments? Sam shape2svg.xslt Description: application/xml ___ 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
XSLT converts svg to shapes
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 of the shape. 2. All items with an id that begins with "connector_" generate a 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 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
(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" 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
XSLT converts svg to shapes with basic transform handling.
This xslt converts svg to shapes and does basic transform handling. Skews and rotates are not handled but scales and offsets are. Transforms are not handled on groups, but any tag that has a @transform attribute will have scaling and offset applied to attributes x, x1, x2, y, y1, y2 and also to d, points. d, points are handled specially, the attribute value is split on white space and anything with a , in it is treated as an x-y pair, with the transform done on the x and y pair. Sam shape2svg.xslt Description: application/xml ___ 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 with basic transform handling.
I've now got a recursive transform apply-er. It accumulates transforms as it processes svg nodes and applies these to the nodes as it goes. It doesn't yet perform rotates because while rotating a rounded rect is merely awkward I haven't worked out how to rotate an ellipse without leaving in the transform attribute. I've also foun I need to scale stroke widths, also that draw strings cann use white space to separate coordinates and no white space around draw instructions. Parsin that in xslt is a joke. So can I ask how much will be needed? It may be easier to support transforms in dia directly... Sam -Original Message- From: "Sam Liddicott" <[EMAIL PROTECTED]> To: "discussions about usage and development of dia" Sent: 17/07/07 15:12 Subject: Re: XSLT converts svg to shapes with basic transform handling. In fact here is a shape I produced of an Extreme Networks 15000 Summit48. I printed page 12 of the Summit Switch hardware installation guide to file (postscript) and then converted that to svg with: pstoedit -f plot-svg /tmp/output.ps > svg/48.svg I then used inkscape to chop away all the text and extra rubbish and label the port connections as connection_XXX and converted that with: ./genshape svg/48.svg The attached shape works fine in dia! Sam * Sam Liddicott wrote, On 17/07/07 13:32: > This xslt converts svg to shapes and does basic transform handling. > > Skews and rotates are not handled but scales and offsets are. > > Transforms are not handled on groups, but any tag that has a @transform > attribute will have scaling and offset applied to attributes x, x1, x2, > y, y1, y2 and also to d, points. > > d, points are handled specially, the attribute value is split on white > space and anything with a , in it is treated as an x-y pair, with the > transform done on the x and y pair. > > Sam > > > ___ > 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
RE: XSLT converts svg to shapes with basic transform handling.
I'll try and do that. It's not pefect, I found I also need to scale the stroke width, luckily dia ignoes this for now. Scaling paths is hard because there are so many delimiters of draw operations and coordinates and xslt was not written for parsing text. So I concluded it would be better to just wait till dia more fully supports xslt, I.e. The workaround is more work than the fix. Sam -Original Message- From: "Lars Clausen" <[EMAIL PROTECTED]> To: "discussions about usage and development of dia" Sent: 28/10/07 16:59 Subject: Re: XSLT converts svg to shapes with basic transform handling. On Tue, 2007-07-17 at 15:12 +0100, Sam Liddicott wrote: > In fact here is a shape I produced of an Extreme Networks 15000 > Summit48. > I printed page 12 of the Summit Switch hardware installation guide to > file (postscript) and then converted that to svg with: > > pstoedit -f plot-svg /tmp/output.ps > svg/48.svg > > I then used inkscape to chop away all the text and extra rubbish and > label the port connections as connection_XXX and converted that with: > > ./genshape svg/48.svg > > The attached shape works fine in dia! I'm sorry I sat on this so long. I've added a page with your scripts and example as well as your explanations. If you or somebody else wants to clean up the page, it's at http://live.gnome.org/Dia/SvgToShapeXslt. -Lars ___ 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