Output PDF file name based on variables

Post here questions and problems related to editing and publishing DITA content.
oxygen-user
Posts: 6
Joined: Wed Jan 24, 2024 4:36 pm

Output PDF file name based on variables

Post by oxygen-user »

Hi,
How can I make sure the PDF output file name is based on the DITA bookmap title (or certain keywords)?

I tested various methods but none of them worked.

Best wishes.

Code: Select all

<!-- Overwrite file name, See
	https://www.oxygenxml.com/doc/versions/26.1/ug-pdf-css/topics/dcpp_parameters.html?hl=args.output.base
	https://www.oxygenxml.com/doc/versions/26.0/ug-editor/topics/editor-variables.html?hl=xpath_eval

	https://www.oxygenxml.com/forum/post71459.html#p71459 
	https://www.oxygenxml.com/forum/post54730.html#p54730 
	 -->
	
	<!--with rootmapURL https://www.oxygenxml.com/doc/versions/26.1/ug-editor/topics/editor-variables.html     -->

	<!--Transformation fails  -->
	<!-- <parameter name="args.output.base" value="${xpath_eval(doc('${rootMapURL}')//*[contains (@class, " front-page/front-page-title")]/*[contains(@class, " topic/title ")]/*[contains(@class, " topic/keyword ")][2])}"/> -->
	
	<!-- Transformation fails -->
	<!-- <parameter name="args.output.base" value="${xpath_eval(//*[contains (@class, " front-page/front-page-title")]/*[contains(@class, " topic/title ")]/*[contains(@class, " topic/keyword ")][2])}"/> -->

	<!-- static -->
	<!-- Transformation fails -->
	<!-- <parameter name="args.output.base" value="${xpath_eval(normalize-space(string-join(/*[contains(@class, 'topic/title')]//text())))}"/> -->

	<!-- Transformation fails -->
	<!-- <parameter name="args.output.base" value="${xpath_eval(normalize-space(string-join(/*[contains(@class, 'map/map')]/*[contains(@class, 'front-page/front-page-title')]//text())))}"/> -->

	<!-- Transformation fails -->
	<!-- <parameter name="args.output.base" value="${xpath_eval(normalize-space(string-join(/*[contains(@class, 'map/map')]/*[contains(@class, 'topic/title')]//text())))}"/> -->

	<!-- file name is identical to value -->
	<!--<parameter name="args.output.base" value="${xpath_eval(upper-case(substring('${cfn}', 1, 4)))}"/>-->
		 
	<!-- dynamic -->

	<!-- Transformation fails -->
	<!-- <parameter name="args.output.base" value="${ask('Set new ID attribute', generic, '${xpath_eval(normalize-space(string-join(/*[contains(@class, 'front-page/front-page-title')]//text())))}"/> -->

	<!-- <parameter name="args.output.base" value="${ask('Set new ID attribute', generic, '${xpath_eval(//*[contains (@class, " front-page/front-page-title")]/*[contains(@class, " topic/title ")]/*[contains(@class, " topic/keyword ")][2]}')}"/> -->

	<!-- file name is identical to value -->
	<!-- <parameter name="args.output.base" value="${ask('Message', input_type, '${cfn}')}"/> -->
xephon
Posts: 146
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

Re: Output PDF file name based on variables

Post by xephon »

I'd recommend to read the metadata from your map after preprocessing (after keyrefs are resolved) and then do the renaming in a new Ant target at the end of the processing.
stefan-jung.org – Your DITA/DITA-OT XML consultant
julien_lacour
Posts: 545
Joined: Wed Oct 16, 2019 3:47 pm

Re: Output PDF file name based on variables

Post by julien_lacour »

Hello,

You cannot use rootmapURL editor variable in args.output.base value, only the following ones:
image.png
image.png (55.82 KiB) Viewed 278 times
If you are using the DITA Map PDF - based on HTML5 & CSS scenario, you can debug the XPath expressions using the merged.html file.
If you still cannot make the transformation succeeds, could you copy the failure stacktrace here?

Regards,
Julien
Post Reply