Widow/Orphan Control
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 30
- Joined: Fri Dec 10, 2010 9:43 pm
Widow/Orphan Control
Hello,
Using DITA, I'm trying to find out how to force an image to stay with the previous element on the same page.
I modified the following in commons-attr.xsl but to no avail:
<xsl:attribute-set name="image">
<xsl:attribute name="keep-with-previous.within-page">always</xsl:attribute>
</xsl:attribute-set>
Any ideas?
John
Using DITA, I'm trying to find out how to force an image to stay with the previous element on the same page.
I modified the following in commons-attr.xsl but to no avail:
<xsl:attribute-set name="image">
<xsl:attribute name="keep-with-previous.within-page">always</xsl:attribute>
</xsl:attribute-set>
Any ideas?
John
-
- Posts: 9445
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Widow/Orphan Control
Hi,
I think it is best for you to try and see how the generated FO file looks like.
Edit the Oxygen DITA Map transformation scenario and in the Parameters tab add a new parameter:
retain.topic.fo with the value yes.
At the end of the transformation you should have in the output directory a FO file called topic.fo which you can open in Oxygen.
Also, the XSLT stylesheet which generates the FO elements for images is this one:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/demo/fo/xsl/fo/commons.xsl
Search in it for the XSL template called:
<xsl:template match="*[contains(@class,' topic/image ')]">
That template uses the attribute sets you are modifying in the commons-attr.xsl.
In the generated FO file you can search after each transformation for fo:external-graphic and see how the attributes are set to them.
So I don't know exactly if you are using simple images or images embeded inside figures but for the first case the generated FO file should look like:
Your approach of using keep-with-previous.within-page should work BUT:
From what I've tested it should be set on the fo:block and not on the internal fo:inline or fo:external-graphic elements. The idea would be that the fo:block to which it is set has a previous sibling block which contains one of the previous paragraphs.
I don't think this can be done only modifying the commons-attr.xsl. You will probably have to edit the commons.xsl and set the value hard-coded to some fo:block there.
You can add some xsl:message's to see how the image FO content is generated for your case (depending also on the attributes set on the image from the DITA XML).
Sorry I cannot help further. Maybe you can also write on the DITA Users list about this:
http://tech.groups.yahoo.com/group/dita-users/
Regards,
Radu
I think it is best for you to try and see how the generated FO file looks like.
Edit the Oxygen DITA Map transformation scenario and in the Parameters tab add a new parameter:
retain.topic.fo with the value yes.
At the end of the transformation you should have in the output directory a FO file called topic.fo which you can open in Oxygen.
Also, the XSLT stylesheet which generates the FO elements for images is this one:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/demo/fo/xsl/fo/commons.xsl
Search in it for the XSL template called:
<xsl:template match="*[contains(@class,' topic/image ')]">
That template uses the attribute sets you are modifying in the commons-attr.xsl.
In the generated FO file you can search after each transformation for fo:external-graphic and see how the attributes are set to them.
So I don't know exactly if you are using simple images or images embeded inside figures but for the first case the generated FO file should look like:
Code: Select all
<fo:block id="" space-after="0.6em" space-after.optimum="3pt"
space-before="0.6em" text-indent="0em">
<fo:inline id="">
<fo:external-graphic
content-width="50%" keep-with-previous.within-page="always" src="url(images\Iris_sanguinea.jpg)"/>
</fo:inline>
</fo:block>
From what I've tested it should be set on the fo:block and not on the internal fo:inline or fo:external-graphic elements. The idea would be that the fo:block to which it is set has a previous sibling block which contains one of the previous paragraphs.
I don't think this can be done only modifying the commons-attr.xsl. You will probably have to edit the commons.xsl and set the value hard-coded to some fo:block there.
You can add some xsl:message's to see how the image FO content is generated for your case (depending also on the attributes set on the image from the DITA XML).
Sorry I cannot help further. Maybe you can also write on the DITA Users list about this:
http://tech.groups.yahoo.com/group/dita-users/
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 30
- Joined: Fri Dec 10, 2010 9:43 pm
Re: Widow/Orphan Control
Thanks Radu!
I followed your fix down to that last paragraph. Then I resorted to the dita-users Yahoo group as you suggested.
Don Day recommended to modify the commons.xsl file. You can read the thread here, http://tech.groups.yahoo.com/group/dita ... sage/20909.
Basically, I added the keep-with-previous.within-page property as follows in the commons.xsl file:
<xsl:when test="not(@placement = 'inline')">
<!-- <fo:float xsl:use-attribute-sets="image__float">-->
<fo:block xsl:use-attribute-sets="image__block" id="{@id}" keep-with-previous.within-page="always">
That worked on my test files; however, I have to test it on all my doc sets to make sure it doesn't disrupt images in other contexts.
Thanks very much for your help
John
I followed your fix down to that last paragraph. Then I resorted to the dita-users Yahoo group as you suggested.
Don Day recommended to modify the commons.xsl file. You can read the thread here, http://tech.groups.yahoo.com/group/dita ... sage/20909.
Basically, I added the keep-with-previous.within-page property as follows in the commons.xsl file:
<xsl:when test="not(@placement = 'inline')">
<!-- <fo:float xsl:use-attribute-sets="image__float">-->
<fo:block xsl:use-attribute-sets="image__block" id="{@id}" keep-with-previous.within-page="always">
That worked on my test files; however, I have to test it on all my doc sets to make sure it doesn't disrupt images in other contexts.
Thanks very much for your help

John
-
- Posts: 9445
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Widow/Orphan Control
Hi John,
Thanks for updating this post.
I also followed the discussion on the DITA Users list.
For the fix you finally settled with you also could have modified in the commons-attr.xsl the attribute set for the image__block.
I did not propose this fix directly because it did not work for me. I tested with simple images (and not with fig's).
You probably have fig's in your DITA topics and just wanted to keep the title and the image on the same page.
Regards,
Radu
Thanks for updating this post.
I also followed the discussion on the DITA Users list.
For the fix you finally settled with you also could have modified in the commons-attr.xsl the attribute set for the image__block.
I did not propose this fix directly because it did not work for me. I tested with simple images (and not with fig's).
You probably have fig's in your DITA topics and just wanted to keep the title and the image on the same page.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service