Welcome to yEd Q&A!
Here you can ask questions and receive answers from other members of the community and yEd developers. And you can tell us your most wanted feature requests.

assign id to elements during svg export for interop with sozi

0 votes

I had raised an issue with the sozi team regarding its interop with svg files created using yed.

The issue and their response is available at https://github.com/senshu/Sozi/issues/295#issuecomment-209060648

I am copying it here for reference, please look into the issue and fix it if possible.

 

I wish there was some way for the tool to remember the zoom level of each frame and its position with respect to a key element in the frame.

This is exactly how Sozi works. If you reopen the same SVG, Sozi should remember the geometry of all frames even if some elements have moved. However, it requires that the key elements are still there and that they have the same identifier.

If I understand your situation correctly, it seems that YEd does not assign the same ids to the SVG elements when you reexport your diagram.

I have tried yEd and actually it does not assign ids to the generated SVG elements.
There is no easy way for Sozi to keep track of key elements@senshu

 

asked Apr 13, 2016 in Feature Requests by anonymous

1 Answer

0 votes

yEd uses Apache Batik's generic rendering interface for SVG export. Unfortunately, I am not aware of any way to generate IDs for SVG elements through this interface.

answered Apr 13, 2016 by thomas.behr [yWorks] (119,790 points)
Can you please push the feature request upstream to the Batik project team?

I do not think that automatically generating IDs would help you much because changing the document in yEd and then exporting to SVG once more would almost certainly result in different IDs even for elements that were not changed.

That said, there might be a workaround for your problem, though:
Each node and/or edge in yEd may have an associated URL property (see the "Data" section in the properties view for selected elements). This property does not check if the entered value is a valid URL. Thus you may enter arbitrary text. If you enter textual IDs for your elements in this field and enable option "Export URL" on tab "Links and Descritpions" of the SVG Export settings, the resulting SVG documents will have additional <g> and <a> elements wrapped around the graphical elements that represent nodes and edges. Moreover, the <a> elements will have an xlink:href attribute whose value is the ID you entered as URL. It should be possible to use XSLT to transform such an SVG document into a new SVG document without those additional <g> and <a> elements but with the xlink:href values used as sensible IDs for the child elements of the removed <g> and <a> elements.

Imprint | Privacy Policy