Inserting figures

Post here questions and problems related to editing and publishing DITA content.
AlastairDent
Posts: 21
Joined: Wed May 18, 2016 6:52 pm

Inserting figures

Post by AlastairDent »

When adding a figure, Oxygen will either insert the figure within tags (<p> <fig> </fig></p>) or outside tags (<p> </p><fig> </fig>, depending on the exact position of the cursor at the time of insertion. It isn't possible to opt for a position at insertion time, it depends on the precise location of the cursor, and can be down to being one character one way or another.

The location of the figure has a profound impact on processing. A figure that is inside tags is processed (by DITA-OT for pdf) as an inline block and inherits positioning from the parent. This overrides alignment specified in plugin attributes.

Would it be possible to amend oxygen so that on insertion of a figure a prompt asks if the user wants it to be inside or outside of the current tags?

I have not tested this but suspect the same thing applies to tables.
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: Inserting figures

Post by alex_jitianu »

Hello,

If I understand correctly the situation, sometimes the users accidentally position themselves at the end of a paragraph (instead of positioning after it) and insert the figure there. If the correct position is always "after" a paragraph, then I would suggest to create a Schematron rule + Quick fix:

Code: Select all

    <pattern id="check.figure.location">
<rule context="p/fig">
<report test="true()" role="warn" sqf:fix="moveAfter"> A figure inside a paragraph doesn't transform well into PDF. </report>
<sqf:fix id="moveAfter">
<sqf:description>
<sqf:title>Move after the paragraph.</sqf:title>
</sqf:description>
<let name="figToMove" value="."/>
<sqf:add match="parent::p" select="$figToMove" position="after"/>
<sqf:delete match="."/>
</sqf:fix>
</rule>
</pattern>
The user will see the warning as soon as it performs the insert operation and it will have a quick fix to move the figure after the paragraph. Please let me know if you find this solution appropriate. If not, you could chain an XSLT operation after the figure is inserted (using an ExecuteMultipleActionsOperation). This additional XSLT operation will present the question to the user (by invoking JAVA code) and afterwards it can move the newly inserted figure. If you think this second approach is preferable I can send you a sample script.

Best regards,
Alex
AlastairDent
Posts: 21
Joined: Wed May 18, 2016 6:52 pm

Re: Inserting figures

Post by AlastairDent »

The schematron rule seems a sensible thing to start with - if only the Oxygen help actually stated how to locate the current Schematron file.

I wasn't being sarcastic. The oxygen help doesn't tell you how to open the current Schematron file in order to edit it.

https://www.oxygenxml.com/doc/versions/ ... uick-fixes
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: Inserting figures

Post by alex_jitianu »

Hello,

Oops, my bad! I forgot to mention where you should put the rule... A good place to put it would be {oxygenInstallDir}\frameworks\dita\resources\dita-1.2-for-xslt2-mandatory.sch

To inspect the schema that are used when validating DITA you can go to Options->Preferences..., on the Document Type Association page and edit the DITA framework. Go to the Validation Tab and edit the DITA scenario and you will see all used Schematron files. An even better approach would be to create a new Schematron file and save it inside {oxygenInstallDir}\frameworks\dita and put the rule there (over time you could develop additional rules). In the scenario edit dialog add a reference to this newly created file.

I'll also have a look at the documentation to decide how to improve it.

Best regards,
Alex
AlastairDent
Posts: 21
Joined: Wed May 18, 2016 6:52 pm

Re: Inserting figures

Post by AlastairDent »

Thanks for your assistance - that seems an acceptable solution for now.
Post Reply