[idea] using XSL/XSLT to extend FreeCAD's XMLs

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
foadsf
Posts: 88
Joined: Fri Mar 06, 2015 10:02 pm
Contact:

[idea] using XSL/XSLT to extend FreeCAD's XMLs

Postby foadsf » Sat Oct 12, 2019 8:54 pm

Following this discussion, where I tried to explain the benefits of using FreeCAD XML files for programmatic CAD instead of Python API, I did some research. Marc Jeanmougin, one of the Inkscape developers, suggested using the XSLT to extend XMLs. So I'm no expert by any means but using XSL/XSLT to extend FreeCAD's native XMLs seems like a great idea. Basically, you can have document transclusion, variables, procedures, generative design... it seems to be a full-fledged programing language.

I know Lei Zheng (aka RealThunder) has already added Link to FreeCAD 19* but using XSLT one can transclude one XML into another even changing their internal parameters (as I have requested here). One can create templates and use them as classes inside other designs, Kind of like OOP but with XMLs. There are already Python libraries (e.g., lxml.etree) to pars XML+XSLT, so it shouldn't be impossible to implement.
Last edited by foadsf on Sat Oct 12, 2019 9:04 pm, edited 1 time in total.
chrisb
Posts: 19749
Joined: Tue Mar 17, 2015 9:14 am

Re: [idea] using XLS/XSLT to extend FreeCAD's XMLs

Postby chrisb » Sat Oct 12, 2019 9:04 pm

I don't see why you need this nesting inside of the xml file. Could you explain this a bit further? I would think it is enough to create xml files of the same structure as they have now.
foadsf
Posts: 88
Joined: Fri Mar 06, 2015 10:02 pm
Contact:

Re: [idea] using XLS/XSLT to extend FreeCAD's XMLs

Postby foadsf » Sat Oct 12, 2019 9:09 pm

chrisb wrote:
Sat Oct 12, 2019 9:04 pm
I don't see why you need this nesting inside of the xml file. Could you explain this a bit further? I would think it is enough to create xml files of the same structure as they have now.
TL;dr: because of assembly and modularization.

Consider the SolidWorks workflow: you first design the parts and then import them into different assemblies multiple times. Though you can save them as separate files or right inside the assembly. As far as I can see this is the reason why RealThunder is developing the Link functionality.
foadsf
Posts: 88
Joined: Fri Mar 06, 2015 10:02 pm
Contact:

Re: [idea] using XSL/XSLT to extend FreeCAD's XMLs

Postby foadsf » Sun Oct 13, 2019 10:14 am

Here I'm being told that there are other options to have XML transclusion. For example, using W3C Xinclude specification or W3C standard XProc XInclude step. Also for variables, as suggested here by Martin Owens (one of Inkscape developers/maintainer), one can use XML namespace. Another option for having variables accross the XML file are the Entity References. All in all, I think a lot can be achieved with the XMLs and their extensions/flavors. There seems to be a lot of untapped potential in this corner of FreeCAD.
Last edited by foadsf on Sun Oct 13, 2019 12:13 pm, edited 1 time in total.
chrisb
Posts: 19749
Joined: Tue Mar 17, 2015 9:14 am

Re: [idea] using XLS/XSLT to extend FreeCAD's XMLs

Postby chrisb » Sun Oct 13, 2019 10:44 am

foadsf wrote:
Sat Oct 12, 2019 9:09 pm
Consider the SolidWorks workflow: you first design the parts and then import them into different assemblies multiple times. Though you can save them as separate files or right inside the assembly. As far as I can see this is the reason why RealThunder is developing the Link functionality.
I'm not familiar with SolidWorks, but watching Celica_Supra's videos it does not seem to be all that different.
Link is already included in FreeCAD. There should be everything available to create a FreeCAD document. It doesn't have to have exactly the same structure as a SolidWorks file.
foadsf
Posts: 88
Joined: Fri Mar 06, 2015 10:02 pm
Contact:

Re: [idea] using XLS/XSLT to extend FreeCAD's XMLs

Postby foadsf » Sun Oct 13, 2019 11:45 am

chrisb wrote:
Sun Oct 13, 2019 10:44 am
I'm not familiar with SolidWorks, but watching Celica_Supra's videos it does not seem to be all that different.
I'm not familiar with "Celica_Supra's videos" but one of the major differences between SolidWorks and FreeCAD workflow has been modularization. In SW, one can basically modularize the design into parts and assemblies and save them in separate files. So far, FreeCAD didn't have this option, and one had to clone a body internally, and there was no option AFIK to transclude parts/bodies/sketches/variables...
chrisb wrote:
Sun Oct 13, 2019 10:44 am
Link is already included in FreeCAD. There should be everything available to create a FreeCAD document. It doesn't have to have exactly the same structure as a SolidWorks file.
Again I'm not sure how Link is implemented. But using XML transclusion, one should be basically able to include any aspects of one design into another. Including a sketch, a variable in a spreadsheet...

Please consider that I'm not asking for a feature, but this is an open discussion to explore the possibilities of XML extensions and standards. As I said in this Tweet, there seems to be a lot of untapped potential in XML, which could significantly improve FreeCAD's capabilities, from version control, assembly and modularization to generative design ...
User avatar
Kunda1
Posts: 5949
Joined: Thu Jan 05, 2017 9:03 pm

Re: [idea] using XSL/XSLT to extend FreeCAD's XMLs

Postby Kunda1 » Sun Oct 13, 2019 10:25 pm

Maybe @realthunder can shed some light/insight. He's the one behind App:Link
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
realthunder
Posts: 1236
Joined: Tue Jan 03, 2017 10:55 am

Re: [idea] using XSL/XSLT to extend FreeCAD's XMLs

Postby realthunder » Mon Oct 14, 2019 2:39 am

The XSL/XSLT idea may be useful if we are going to redesign FC, say build the document structure around XML DOM. In the current FC, we don't even use DOM. The XML semantic parsing is all hand written using SAX interface. For document persistence, Link simply stores the linked file path as a normal XML attribute, nothing special about it. The magic happens at a higher level, not at XML parsing.

foadsf wrote:
Sun Oct 13, 2019 11:45 am
I'm not familiar with "Celica_Supra's videos" but one of the major differences between SolidWorks and FreeCAD workflow has been modularization. In SW, one can basically modularize the design into parts and assemblies and save them in separate files. So far, FreeCAD didn't have this option, and one had to clone a body internally, and there was no option AFIK to transclude parts/bodies/sketches/variables...
Yes, with Link you can do that now. Of course, it is just the beginning. We can alway improve.
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
chrisb
Posts: 19749
Joined: Tue Mar 17, 2015 9:14 am

Re: [idea] using XLS/XSLT to extend FreeCAD's XMLs

Postby chrisb » Mon Oct 14, 2019 4:11 am

foadsf wrote:
Sun Oct 13, 2019 11:45 am
I'm not familiar with "Celica_Supra's videos"
Here is a link: https://forum.freecadweb.org/viewtopic.php?f=36&t=32131.