SVG export results in invalid IDREF on a use element
Some of the diagrams created in Lucidchart by my team export to SVG with an invalid xlink href attribute value on a use element. For example, the href may refer to #i when there is no element in the SVG file with an ID attribute set to “i”. Deleting this use element “fixes” the invalidity.
Ideally, I would like Lucidchart to always export valid SVG XML. This is an enormous impediment to my team. While I’m investigating workarounds for fixing the invalid reference, the much better fix would be for Lucidchart not to export invalid SVG XML.
Page 1 / 1
After more troubleshooting, the issue seems to be isolated to a specific custom icon we’re using. We’ll be ferreting out which icon(s) introduce this error.
I’m still curious why Lucidchart wouldn’t see the issue with an href pointing to a non-existent ID.
Hi @Mark W , thanks for posting. Would you mind sending a temporary Support PIN for a document containing the icon in question so we can take a closer look? For more information on generating a Support PIN, check out this Help Center article.
Hi @Emma D After some further troubleshooting, I’ve discovered that the issue occurs with labels that have empty lines, such as unnecessary carriage returns at the start or end of a label.
When I export to SVG the example shown below, the result includes a use element with an attribute xlink:href=”#a”, but there is no element with id=”a”. The other use elements all have hrefs that refer to id attributes that do exist.
It would seem that LucidChart on SVG export is omitting “insignificant” whitespace but still referring to the omitted chunks of label when generating the use elements.
Extra CR above “Unit” results in SVG with invalid IDREF
PIN to example shown above: pdsx7MDTDMeU
@Mark W Thanks for getting back to me with that additional information! I have reported this to our development team. I apologize for any disruption this may cause.
In the meantime, would it be possible to hear more about your use-case so we can better understand the impact this is having on your team’s workflow?
Thank you, Emma.
We reference SVGs exported from Lucidchart in XML documents that we transform to PDFs by means of Apache FOP, which uses Apache Batik for rendering SVGs. Batik evidently expects valid SVG XML and fails to render the SVG entirely, so if we don’t address the issue, the PDF has a blank space where the SVG should appear.
We have a workaround, which is to use XSLT to copy every SVG, omitting use elements that refer to IDs that don’t exist.
It’s quite difficult to spot the extra carriage returns manually in Lucidchart. Selecting the label doesn’t reveal extra CRs. Even double clicking on the label to select the text doesn’t reliably reveal them either. The only way we’ve found that 100% works is to be in edit mode for the label and try to move the insertion cursor beyond the apparent start or end of the label. Not remotely scalable.
I’m also looking at whether Batik can be configured to just chill out and ignore validity errors. So far, no luck.
Thank you Mark for the helpful context! I’ve passed this on in the bug report and will be sure to notify this thread with any updates.
We have also ran into the same issue with generating Metanorma PDF and Word files, and found this ticket. The problem is definitely not fixed. A number of LucidChart-exported SVGs exhibit this problem and they are invalid.
The exported SVGs fail validation and also cause issues with Adobe Illustrator and when imported into Word. Is there any ETA for a fix for generating “valid SVG XML” files? Thanks!
I’ve posted a workaround script as a GitHub Gist here, hope it helps someone. Thank you Mark for the workaround!
A Lucid account is required to interact with the Community, and your participation is subject to the
Supplemental Lucid Community Terms.
You may not participate in the Community if you are under age 18. You will be redirected to the Lucid app to log in.
A Lucid account is required to interact with the Community, and your participation is subject to the
Supplemental Lucid Community Terms.
You may not participate in the Community if you are under age 18. You will be redirected to the Lucid app to log in.