Refactoring framework files with XInclude

Post here questions and problems related to oXygen frameworks/document types.
Johann
Posts: 199
Joined: Wed Jun 17, 2015 12:46 pm

Refactoring framework files with XInclude

Post by Johann »

Hello everyone,

I'm using Oxygen component (SDK 17.1) and I have multiple .framework files.
Several parts are in common in these frameworks, so I would like to refactor them.

I tried to use XInclude like this :

Code: Select all


<field name="toolbarDescriptor">
<xi:include href="toolbarDescriptor.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
</field>
The "toolbarDescriptor.xml" (in the same folder as my framework files) only contains the XML part I have just cut.

Unfortunately, it does not work. I have no error. My framework loads because I see the custom Author display but my toolbar is not loaded.

What is wrong in my framework file ? Or is it not possible to use XInclude ?

Thanks for your help,

Johann
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Refactoring framework files with XInclude

Post by Radu »

Hi Johann,

Unfortunately the code which parses the frameworks on our side is not xi:include aware.

Maybe as possible workarounds you could:

1) Use entity references instead.
2) Generate the final ".framework" files from your own set of ".framework" files by applying an XSLT stylesheet (which properly processes xi:includes).
3) You could have a base framework and you could extend it with the individual frameworks. In an Oxygen standalone Preferences->Document Type Association page you can extend a framework instead of duplicating it.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Johann
Posts: 199
Joined: Wed Jun 17, 2015 12:46 pm

Re: Refactoring framework files with XInclude

Post by Johann »

Hi Radu,

Thanks for your tips.

1) I tried using entity references but it seems not to work too. The framework does not load, my author view does not display.
In my ..\AppData\Roaming\com.oxygenxml.author.component\...\ApplID\frameworks folder I have my framework file containing these lines :

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE framework [
<!ENTITY menubarDescriptor SYSTEM "./menubarDescriptor.txt">
]>
<serialized version="17.0" xml:space="preserve">...

Code: Select all


<field name="menubarDescriptor">
&menubarDescriptor;
</field>
And in the same folder, I have the menubarDescriptor.txt file :

Code: Select all


<menu>
<field name="label">
<String>My label</String>
</field>
<field name="accessKey">
<String/>
</field>
<field name="iconPath">
<String/>
</field>
...
</menu>
2) I cannot generate my framework files through XSL in my application.

3) I tried to create extended frameworks from a base framework. The output extended framework copies common parts from the base framework and I just wanted to avoid this in order to have frameworks programmatically maintainable.

Did I miss something about the entities ?

Thanks.

Johann
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: Refactoring framework files with XInclude

Post by alex_jitianu »

Hello Johann,

1) You've done everything right. I've tested myself and the conclusion is that it is an issue on our side. When loading the *.framework file we don't provide a base system Id and as a result menubarDescriptor.txt is looked for in the application installation directory (not in the framework directory). Unfortunately, an eventual fix would only be possible in the next Oxygen version so perhaps we can find a solution using the other alternatives my colleague has suggested.
2) So XSLT is not an option. But how about other programming/scripting languages. Maybe ANT?
3) The extension actually creates just a patch. It's true that it also keeps the original framework but only as a read-only information it uses when applying the patch on newer version of the framework. If you look inside the *.framework file, the patch is this element:

Code: Select all

<field name="extensionPatch">
All other fields come from the original framework and, as I said, are only used in the algorithm that applies the extension patch. Sort of a three-way-diff.

Best regards,
Alex
Johann
Posts: 199
Joined: Wed Jun 17, 2015 12:46 pm

Re: Refactoring framework files with XInclude

Post by Johann »

Hello Alex,

Finally, I succeeded in performing an XSLT transformation on my .framework files. So I was able to use entities or xi:include elements to refactor my files.

Regards,

Johann
Post Reply