Simple way to switch stylesheets for PDF?

Oxygen general issues.
anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Simple way to switch stylesheets for PDF?

Post by anderszvensson »

Hi,

I have custom.xsl stylesheets defined, and referenced through the demo/fo/Customization/catalog.xml file (Added under Preferences -> XML Catalog).

But I need to switch between different custom stylesheets for different documents. Of course I can edit the catalog.xml file, but it's kind of cumbersome to do that each time you render.

So my question is, is there a simple way to switch what stylesheets are used from within Oxygen?

Or if not, is there a way I can add a plugin of my own (using C#/.Net preferably...) to change it in the catalog file programmatically?

Regards,

Anders
anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Re: Simple way to switch stylesheets for PDF?

Post by anderszvensson »

A follow-up to this question:

I discovered that with two different transformation scenarios (both for DITA pdf), I get different custom stylesheets. But I can't figure out how...

The thing is, for scenario A, I had defined a particular Customization/catalog.xml file that pointed to a specific custom stylesheet that handles the specialization elements for certain files (test documents).

Code: Select all

<uri name="cfg:fo/xsl/custom.xsl" uri="file:///C:/DitaContent/Spacemetric/Customization/fo/xsl/custom_testdocs.xsl"/>
<uri name="cfg:fo/attrs/custom.xsl" uri="file:///C:/DitaContent/Spacemetric/Customization/fo/attrs/custom_attr.xsl"/>
This catalog was pointed to from Preferences -> XML Catalog, and it worked fine.

But then I needed to switch back to my regular custom.xsl for non-specialized topics, so I removed the setting for the catalog.xml that pointed to custom_testdocs.xsl, and only had the regular catalog.xml left pointing to custom.xsl:

Code: Select all

<uri name="cfg:fo/xsl/custom.xsl" uri="file:///C:/DitaContent/SteelwristCustomization/Customization/fo/xsl/custom.xsl"/>
<uri name="cfg:fo/attrs/custom.xsl" uri="file:///C:/DitaContent/SteelwristCustomization/Customization/fo/attrs/custom_attr.xsl"/>
However, if I ran the transformation scenario defined for the test documents, they still rendered fine, even though there should be no catalog.xml pointing to the correct custom stylesheets for it...

But if I switched to the transformation scenario for regular non-specialized topic files that ran fine (choosing the correct regular custom.xsl stylesheets).

It doesn't seem to matter if I have the two different catalog.xml files there or not, they seem to choose the right stylesheets (at the moment) anyway. But how is it possible that Oxygen should know to run the custom_testdocs.xsl unless the catalog.xml file is there to point to it? It's as if it were cached or something.

BTW, for the specialized version, I also have the transformation dialog set to a separate DITA OT.

I'm not sure what I'm missing, but I need to know where to set these Customization/catalog.xml files pointing to custom stylesheets, so that I have control over it. As it is now, I feel Oxygen is just doing as it pleases...

Regards,

Anders
anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Re: Simple way to switch stylesheets for PDF?

Post by anderszvensson »

Another follow-up...

After some more testing, it seems the Customization/catalog.xml in the currently used DITA OT applies no matter what is set in the Preferences XML Catalog setting...? I was surprised to find this, because I had previously heard in this forum that you needed to tell Oxygen about the Customization/catalog.xml file for it to be used. Is that not true anymore? Is it used by default with the DITA OT selected?

So, to sum up, have I understood this correctly, and if the Customization/catalog.xml file is selected automatically from the currently used DITA OT, is the only way to switch stylesheets also to use a different DITA OT for different transformation scenarios (unless you edit the Customization/catalog.xml file between transformations)?

Regards,

Anders
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: Simple way to switch stylesheets for PDF?

Post by Radu »

Hi Anders,

The DITA Open Toolkit publishing is run as an external ANT process which does not depend at all on the catalog entries in the Preferences XML Catalog page. Those entries are there only for editing and validation of files opened in Oxygen.

So how is the customization catalog.xml get taken into account by the DITA OT transformations?
In the OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/demo/fo/build.xml ANT build file there is a line which defines the used catalogs:

Code: Select all

 <property name="xml.catalog.files" value="${customization.dir}/catalog.xml;${basedir}/cfg/catalog.xml"/>
As you can see, the catalog from the customizations directory, if it exists is considered to have a higher priority over the one from the "cfg" directory. So this is coded in the build files, you cannot change options in the Oxygen Preferences for this.

But, in the Oxygen DITA Map Scenario Edit Dialog there is a Parameters tab. If you add a new parameter with the name xml.catalog.files and value ${basedir}/cfg/catalog.xml, then this parameter will overwrite the parameter specified in the build file by ignoring the customizations catalog completely.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Re: Simple way to switch stylesheets for PDF?

Post by anderszvensson »

Good, clear answer! Thanks for that!

But, to return to my original question: there is really no simple way to switch stylesheets for PDF then, seeing as the custom.xsl is selected by the catalog.xml file?

I understand that I could according to your answer define several catalog.xml files, all pointing to different custom.xsl stylesheets (and the custom_attrs.xsl that goes with it). But I was sort of hoping for some simple way of setting up stylesheets and be able to choose between them by simply selecting them in a dialog (preferably the transformation dialog). And that this selection would then override the settings in the catalog.xml file. But I suspect there is no such feature?

Regards,

Anders
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: Simple way to switch stylesheets for PDF?

Post by Radu »

Hi Anders,

No, sorry, as you suspect there is no GUI for this sort of customization.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Re: Simple way to switch stylesheets for PDF?

Post by anderszvensson »

Hi,

I tried setting the xml.catalog.files in the transformation scenario as you suggested. But when I did, I the cfg protocol is not recognized (I set it to ${customization.dir}/catalog-testdocs.xml;${basedir}/cfg/catalog.xml).

Here's the error message:

Code: Select all

     [java]   XTSE0165: javax.xml.transform.TransformerException: Malformed URL
[java] cfg:fo/attrs/custom.xsl(base
[java] file:/C:/DitaContent/Spacemetric/DITA-OT/demo/fo/xsl/fo/topic2fo_shell_1.0.xsl): unknown
[java] protocol: cfg
This does not happen when I just use the default Customization/catalog.xml (without setting the transformation scenario parameter). Then it has no problem with the cfg protocol.

What's going on here, and how can I fix it? Because setting the xml.catalog.files parameter to override which would have been a perfectly viable solution for me...

Regards,

Anders
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: Simple way to switch stylesheets for PDF?

Post by Radu »

Hi Anders,

So in the OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/demo/fo/build.xml build file the parameter is defined as:

Code: Select all


<property name="xml.catalog.files" value="${customization.dir}/catalog.xml;${basedir}/cfg/catalog.xml"/>
If you place an <echo> after the line:

Code: Select all


<echo>CATALOG FILES |${xml.catalog.files}|</echo>
you will find in the Oxygen console the value to which the parameter gets set.

The problem is that when the parameter takes its value in the build file, it can construct its value from other parameters like: ${customization.dir} or ${basedir} which get expanded to create the value of the parameter.

But, when you specify the parameter via the "Parameters" tab (via the ANT command line) the parameter cannot expand anymore the ANT parameters it depends on so its value is interpreted like a literal string.

So if I do not specify the parameter in the transformation scenario I get in the Oxygen console:

Code: Select all


CATALOG FILES  |D:\projects\eXml\frameworks\dita\DITA-OT\demo\fo/Customization/catalog.xml;D:\projects\eXml\frameworks\dita\DITA-OT\demo\fo/cfg/catalog.xml|
and if I specify it in the Parameters tab:

Code: Select all


CATALOG FILES  |${customization.dir}/catalog.xml;${basedir}/cfg/catalog.xml|
So the solution is either to give absolute paths in the value of the
xml.catalog.files in the Parameters tab or use Oxygen editor variables (which get expanded before being sent to the ANT process) in the value like:
${frameworksDir}/dita/DITA-OT/demo/fo/cfg/Customization/catalog.xml;${frameworksDir}/dita/DITA-OT/demo/fo/cfg/catalog.xml

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
anderszvensson
Posts: 71
Joined: Wed Jul 14, 2010 11:38 am

Re: Simple way to switch stylesheets for PDF?

Post by anderszvensson »

Thanks that worked perfectly, especially together with the custom editor variables feature, since I don't use the DITA-OT in the Oxygen frameworks directory.

Regards,

Anders
Post Reply