Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to add a use-when attribute to an <xsl:import> tag #231

Open
mmg-hinchey opened this issue Aug 10, 2022 · 4 comments
Open

Trying to add a use-when attribute to an <xsl:import> tag #231

mmg-hinchey opened this issue Aug 10, 2022 · 4 comments

Comments

@mmg-hinchey
Copy link

mmg-hinchey commented Aug 10, 2022

Hi,
I wanted to create a new dita2fo.xml file that would coorilate to a doc.type value. The goal is that when I set the doc.type publishing paramater to 'profile' my new file is included in the build. If doc.type is empty, or filled with another value, my new file is not included.

I've added a link to my new file in a xml:import tag in the dita2fo_import.xml file. That works well. However, when I added a @use-when attribute, one of the following things happen:

  • My expression is not static, so I recieve the following error message: "Error in variable expression. Variables (other than XSLT 3.0 static variables) cannot be used in a static expression"
  • My express is static, but it doesn't apply the filter. I assume that meens it couldn't find the doc type.

Is it possible to reference the publishing paramaters as a stactic expression in the @use-when attribute?

Thank you.

@ToshihikoMakita
Copy link
Contributor

Could you show me your code?

@mmg-hinchey
Copy link
Author

These are in the C:\DITA-OT-3x-WHR-PDF5-Beta\plugins\com.custom.pdf5.ml\xsl\dita2fo_import.xsl file:

    <xsl:variable name="DocTypeVer" static="yes" select="('doc.type')" ></xsl:variable>
<xsl:import href="dita2fo_markup.xsl" use-when="$DocTypeVer = 'profiling'"/>

Again, I'm trying to test against the doc.type publishing paramater. I've also added the value "profiling" to the doc.type in C:\DITA-OT-3x-WHR-PDF5-Beta\plugins\com.custom.pdf5.ml\plugin.xml.

      <param name="doc.type" desc="Specifies document type such as 'UM' (User's manual), 'IM' (Installation manual)" type="enum">
		<val default="true"></val>
		<val>IFU</val>
		<val>IFU10</val>
		<val>addendum</val>
		<val>CableMap</val>
		<val>profiling</val>
        </param>	

This configuration creates valid output, but the dita2fo_markup.xsl is not being used. If I remove the @use-when attribute, the dita2fo_markup.xsl is used (but, of course, I need it to be conditional).

Thank you!

@ToshihikoMakita
Copy link
Contributor

You are trying to reference ant property from xsl:variable/@select attribute. Usually, Saxon XSLT processor needs system-property() described in @select attribute.

Try following steps.

1. Add following line in your com.custom.pdf5.ml\plugin.xml.

<feature extension="com.antennahouse.pdf5.ml.param" value="params.xml" type="file"/>

2. Implement param.xml in your plug-in folder.

<?xml version="1.0" encoding="UTF-8"?>
<extension>
    <sysproperty key="doc.type" value="${doc.type}"/>
</extension>

3. Change your dita2fo_import.xsl as follows.

 <xsl:import href="dita2fo_markup.xsl" use-when="system-property('doc.type') eq 'profiling'"/>

I have not tried but I used this method in the following example.

com.antennahouse.pdf5.ml/build_transform_template.xml line 178.

<sysproperty key="use.i18n.index.lib" value="${use.i18n.index.lib}"/>

com.antennahouse.pdf5.ml\xsl\dita2fo_indexshell.xsl line 24.

<xsl:include href="dita2fo_indexi18n.xsl" use-when="system-property('use.i18n.index.lib') eq 'yes'"/>

Hope this helps your solution.

@kayal28
Copy link

kayal28 commented Sep 1, 2022

#231 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants