Adding support for more papersizes [fixed]

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
aapo
Posts: 626
Joined: Mon Oct 29, 2018 6:41 pm

Re: Adding support for more papersizes

Post by aapo »

chennes wrote: Sun Jan 24, 2021 3:13 pm As an alternative, our code could "sanitize" the incoming SVG to remove elements that are going to do this, but I'd guess that's more work than just tweaking these templates (though maybe @uwestoehr would disagree if he's already spent a lot of time on this!).
Uwe, in light of this, could you perhaps please remove the

Code: Select all

xml:space="default"
attributes from the new Arch templates? Or is it not feasible?


uwestoehr wrote: pinged by pinger macro
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Adding support for more papersizes

Post by uwestoehr »

For reference the xml:space tag exists since SVG 1.0. In SVG 2.0 however, they recommend to use it not further:
https://www.w3.org/TR/SVG2/struct.html# ... eAttribute

Nevertheless, it is valid SVG 1.x so we cannot throw an error saying it is wrong.
Last edited by uwestoehr on Sun Jan 24, 2021 5:00 pm, edited 1 time in total.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Adding support for more papersizes

Post by uwestoehr »

aapo wrote: Sun Jan 24, 2021 4:45 pm Uwe, in light of this, could you perhaps please remove the
See my last 2 posts, I will purposely not delete valid SVG tags. How would this end when FC is no longer respecting ISO standards that exists since years?
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Adding support for more papersizes

Post by chennes »

uwestoehr wrote: Sun Jan 24, 2021 4:50 pm Nevertheless, it is valid SVG 1.x so we cannot throw an error saying it is wrong.
I agree in principle: unfortunately, we are using Qt's old, unsupported DOM parser, and we should find some way to work around this bug. Do you have a suggestion for how to approach it? I mean, in the long term I suppose the answer is to migrate to Xerces-C, but that is a huge undertaking that we clearly aren't going to tackle until Qt actually EOLs their parser.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Adding support for more papersizes

Post by uwestoehr »

chennes wrote: Sun Jan 24, 2021 5:58 pm I agree in principle: unfortunately, we are using Qt's old, unsupported DOM parser, and we should find some way to work around this bug. Do you have a suggestion for how to approach it?
Just ignore the output of the parser when it complains about xml:space.
I have no knowledge in this respect but since there is no problem with a release build, I think the solution is already there: act like the release build when parsing SVG files. :)
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Adding support for more papersizes

Post by uwestoehr »

Just for further reference, here is an explanation of the xml:space entry:
http://www.xmlplease.com/xml/xmlspace/
(it is a 10 year old article, meanwhile all programs support this I guess)

Also SVG 2 is not yet released, so SVG 1.1 from 2008 is still the most recent SVG definition and there xml:space is defined.

However, here is an SVG testfile without xml:space, can you please test?:
Arch_E3_Portrait2.svg
SVG file to test
(76.61 KiB) Downloaded 46 times

Nevertheless I insist on calm down the parser since Inkscape is the most used SVG editing tool so users will get xml:space back when they modify templates.
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Adding support for more papersizes

Post by chennes »

uwestoehr wrote: Mon Jan 25, 2021 1:17 am Nevertheless I insist on calm down the parser since Inkscape is the most used SVG editing tool so users will get xml:space back when they modify templates.
That's fine with me, I don't really care how the issue gets resolved, I just don't want FC to crash when running in debug. It might just be a matter of setting something before parsing so that Qt knows about the "xml" namespace, I'm not sure.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Adding support for more papersizes

Post by uwestoehr »

For the meantime I removed the xml:space entries from the files to make the PR ready to be merged.
I also updated https://wiki.freecadweb.org/TechDraw_Te ... on_the_SVG accordingly.
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Adding support for more papersizes

Post by chennes »

uwestoehr wrote: Mon Jan 25, 2021 2:11 am For the meantime I removed the xml:space entries from the files to make the PR ready to be merged.
I figured out the problem, and it is in our code, not Qt's (which in this case is a good thing!). I think I can put together a patch, it turns out that the XML standard says that you don't have to explicitly state the URI for the "xml" namespace, it's defined by the standard. But our code doesn't create it if it's not in the list of xmlns's at the top of the file. So I think we just need to add a check when that list is created, and add it at the end if it's not there.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Adding support for more papersizes

Post by chennes »

I think PR 4314 solves the issue, but would appreciate other testers. Thanks!
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply