Page 1 of 1

Resolve image location programmaticaly

Posted: Wed Aug 31, 2011 7:19 pm
by nithril
Hello,

I have a DTD (a S1000D DTD) which declare graphics prior to use their in the content :

Code: Select all


<!-- declaration -->
<icns>
<icn id="icn1">
<icn-c>
<modelic>AAAA</modelic>
<sdc>A</sdc>
<chapnum>00</chapnum>
<section>0</section>
<subsect>0</subsect>
<subject>00</subject>
<manualcode>MM</manualcode>
<illnum>0001</illnum>
<illver>A</illver>
<language language="F"/>
</icn-c>
</icn>
</icns>
[...]
<!-- content -->
<graphic callicn="icn1"/>
I have to display the graphic at it's use point.

The graphic filename is the concatenation of the tags from "modelic" to "language" with an extension that is among a list of supported one : eg. AAAAA000000MM0001AF.(jpg|png|svg|...)

It's seems impossible to display the image using CSS (or I'm wrong). Is there another way to display the image ? Maybe programmaticaly ?


Thanks for your help,

Nicolas

Re: Resolve image location programmaticaly

Posted: Wed Aug 31, 2011 9:42 pm
by nithril
I may have solved my problem. I have create a new StylesFilter where I set dynamically the mixed content with a custom URIContent. I extract the icn nodes to construct the filename.

I wonder if there can be performance issue :?:

Re: Resolve image location programmaticaly

Posted: Thu Sep 01, 2011 12:23 pm
by Radu
Hi,

Your found solution is good.

There was one more solution by using a powerful Oxygen CSS extension function called "xpath":

http://www.oxygenxml.com/doc/ug-editor/ ... ction.html

which would have allowed you from the CSS to use as content for the image element a complex XPath expression which would have joined the required values from the target element. But this approach would have been more processor intensive than your approach.

Probably your approach has some problems when the target element (from which you take the values to compose the image) is modified. The image element will not update on its own as is has already cached its content.
You can use our API to add a node changed listener to the Author page:

ro.sync.ecss.extensions.api.AuthorDocumentController.addAuthorListener(AuthorListener)

and when such a node is modified you can refresh the image element forcefully:

ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.refresh(AuthorNode)

The second approach (the xpath function) would have refreshed the entire document automatically but because of this it is more processor intensive and is usually suitable only for XML documents under 500 KBs.

Regards,
Radu

Re: Resolve image location programmaticaly

Posted: Thu Sep 01, 2011 1:12 pm
by nithril
Hi Radu,

Thanks for your answer.


Nicolas