Page 1 of 1

Refactoring framework files with XInclude

Posted: Mon Nov 30, 2015 3:08 pm
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

Re: Refactoring framework files with XInclude

Posted: Tue Dec 01, 2015 10:11 am
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

Re: Refactoring framework files with XInclude

Posted: Tue Dec 01, 2015 1:14 pm
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

Re: Refactoring framework files with XInclude

Posted: Wed Dec 02, 2015 12:16 pm
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

Re: Refactoring framework files with XInclude

Posted: Thu Dec 10, 2015 12:38 pm
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