Page 1 of 1

How to use images declared with ENTITY and XLink

Posted: Wed Jun 23, 2021 7:56 pm
by egg4521
Hi, bit of a noob here using xml to create documents. For some context I'm trying to make a technical manual. I'm opting for a modularized approach. I'm using XLink to include "chapters" so to speak in my main production file because I ran into the multiple DOCTYPE inclusion issue described here:

https://www.oxygenxml.com/doc/versions/ ... clude.html

My problem is that my chapter xml files have images declared via ENTITY statements as well. My main production file seems to be skipping over them, because when I transform just the chapter file I see my images. My theory is that DOCTYPE statements are just skipped when including with XLink? But regardless, what's the suggested approach for images here?

Also if this is on the wrong board, apologies, first time poster.

Re: How to use images declared with ENTITY and XLink

Posted: Thu Jun 24, 2021 7:21 am
by Radu
Hi,

I think a small example with how the XML content looks like would have helped. Also what XML vocabulary are you using? Is it DocBook?
So if you have a DOCTYPE declaring image references using unparsed entities, we have a CSS function which can retrieve values for such entities, so maybe with a CSS customization for the Author visual editing mode you could show the images in place there:
https://www.oxygenxml.com/doc/versions/ ... ction.html

Regards,
Radu

Re: How to use images declared with ENTITY and XLink

Posted: Thu Jun 24, 2021 4:51 pm
by egg4521
Hi Radu,

Thanks for your reply. I'll try my best to recreate what I'm working with. Looking at my post I really didn't describe what I was working with here. Sorry about that.

Here's a snippet with some stuff changed/removed because I'm not sure what I'm allowed to post regarding the content of the manual.

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet href="A_stylesheet.xsl" type="text/xsl" media="print,pdf" alternate="yes"?>

<!DOCTYPE book SYSTEM "my_dtd.dtd"  [
    <!ENTITY % xinclude SYSTEM "http://www.docbook.org/xml/4.4/xinclude.mod%22">
    %xinclude;
]>

<book>
	<chapter1>
		<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Chap1-section1.xml"></xi:include>
	<chapter1/>
	<rest_of_book>...</rest_of_book>
</book>
Chapter 1 section 1 looks like:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet href="A_stylesheet.xsl" type="text/xsl" media="print,pdf" alternate="yes"?>

<!DOCTYPE section1 SYSTEM "my_dtd.dtd"  [
	 <!ENTITY chap1-sec1-img1 SYSTEM "images\chap1\sec1\fig1.png" NDATA PNG>
]>

<section1>
	<text>heres some text</text>
	<image entity_ref="chap1-sec1-img1"/>
	<!--rest of section 1-->
<section1/>

So just to reiterate, this isn't my xml exactly but I want to note a few things.

My DTD file requires that I embed images into the document via an attribute that links to an entity reference("entity_ref" in the image tag in my section1 example). Due to the requirements for this contract I'm not allowed to change the DTD(or the stylesheets).

I'm using Saxon-PE 9.9.1.7 to run an XSLT transformation using the XSLT stylesheet declaration at the top there. That is popping out XSL-FO I think. I'm then piping that into the FO Processor using the built in Apache FOP to build a wonky looking pdf, but not concerned about the wonkiness at the moment.

Hopefully that helps.

Re: How to use images declared with ENTITY and XLink

Posted: Mon Jun 28, 2021 8:10 am
by Radu
Hi,

So is your question about the publishing? Meaning that the final PDF does not contain the images inside?
Or is it about editing? Meaning that while you are editing XML documents in Oxygen's Author visual editing mode, the images do not appear?
If it's about editing, you probably already have a custom CSS used for editing your custom XML documents in Oxygen, you probably need to add to that custom CSS this selector:

Code: Select all

image[entity_ref]{
content: oxy_url(oxy_unparsed-entity-uri(attr(entity_ref))); 
}
Regards,
Radu