Mapping DITA <image> to WebHelp <img>
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 37
- Joined: Wed Dec 23, 2009 6:13 am
Mapping DITA <image> to WebHelp <img>
I have a link to an SVG file using the <image> element:
<image href="images/linktographic2.svg" width="60" alt="Display graphics for gentext"/>
When I transform using standard WebHelp scenario, the resulting HTML markup is:
<embed class="image" src="images/linktographic2.svg" width="60">
I need the output to be similar to:
<img src="images/linktographic2.svg" width="60">
Can I change a specific parameter to generate <img> instead of <embed>, or is this handled by a stylesheet customization?
<image href="images/linktographic2.svg" width="60" alt="Display graphics for gentext"/>
When I transform using standard WebHelp scenario, the resulting HTML markup is:
<embed class="image" src="images/linktographic2.svg" width="60">
I need the output to be similar to:
<img src="images/linktographic2.svg" width="60">
Can I change a specific parameter to generate <img> instead of <embed>, or is this handled by a stylesheet customization?
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Mapping DITA <image> to WebHelp <img>
Post by sorin_ristache »
Hello,
You need an XSLT stylesheet customization for that. The template where the <img> and <embed> elements are created is located in file [Oxygen-install-dir]\frameworks\dita\DITA-OT\xsl\xslhtml\dita2htmlImpl.xsl and is called:
In this template you can force the <img> element for SVG images instead of <embed> by modifying the isSVG variable, for example by replacing the element that creates this variable with the following one in the above mentioned template:
For the DITA Webhelp transformation you should make this modification in a copy of this "topic-image" template that overrides the default one (from the file dita2htmlImpl.xsl) and that you should add in the file [Oxygen-install-dir]\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\xsl\dita\dita2webhelp.xsl.
Regards,
Sorin
You need an XSLT stylesheet customization for that. The template where the <img> and <embed> elements are created is located in file [Oxygen-install-dir]\frameworks\dita\DITA-OT\xsl\xslhtml\dita2htmlImpl.xsl and is called:
Code: Select all
<xsl:template name="topic-image">
Code: Select all
<xsl:variable name="isSVG" select="false()"/>
Regards,
Sorin
-
- Posts: 37
- Joined: Wed Dec 23, 2009 6:13 am
Re: Mapping DITA <image> to WebHelp <img>
Thanks Sorin. For the record, using <img> for SVG is preferable to <embed>. I experimented with both elements where I'd put a hyperlink on an SVG icon. For WebHelp and WebHelp Mobile, only the top half of the SVG was rendered with <embed> and the hyperlink didn't work. With <img>, the entire SVG icon is visible and linking works as expected.
Perhaps given that SVG is appearing more in technical documentation, there could be a parameter setting added for WebHelp transformation scenarious to select either <img> or <embed>.
Perhaps given that SVG is appearing more in technical documentation, there could be a parameter setting added for WebHelp transformation scenarious to select either <img> or <embed>.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Mapping DITA <image> to WebHelp <img>
Post by sorin_ristache »
The <embed> element was necessary for SVG images because older versions of the main browsers could not render SVG images included with <img> correctly. That is no longer true in recent versions so you are correct, <img> should be used now for SVG images too.
I added an issue to the DITA-OT project. I already patched the DITA-OT code so that starting with the next version of Oxygen the SVG images will be transformed to <img> insteead of <embed>.
Regards,
Sorin
I added an issue to the DITA-OT project. I already patched the DITA-OT code so that starting with the next version of Oxygen the SVG images will be transformed to <img> insteead of <embed>.
Regards,
Sorin
-
- Posts: 37
- Joined: Mon Jul 14, 2014 9:48 am
Re: Mapping DITA <image> to WebHelp <img>
Hi,
We are customizing the DITA-OT X2HTML output to support SVG images, but we do not know which class we have to extend:
We have added support for eps using the above template, Can you please tell me which template has to be extended for svg?
Regards,
Navaneetha
We are customizing the DITA-OT X2HTML output to support SVG images, but we do not know which class we have to extend:
Code: Select all
<xsl:template match="*[contains(@class,' topic/image')]/@href">
Regards,
Navaneetha
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Mapping DITA <image> to WebHelp <img>
Post by sorin_ristache »
SVG images are already supported in the DITA XHTML transformation. That means you don't have to do anything to support them because DITA-OT comes with built-in SVG support. Just insert a SVG image in your DITA XML topic file, for example:
and run the DITA XHTML transformation on the DITA map. The SVG image will be included in the XHTML output page and the .svg file will be automatically copied to the output directory together with the XHTML files.
Code: Select all
<image href="images/shapes.svg"/>
Regards,
Sorin
<oXygen/> XML Editor Support
Sorin
<oXygen/> XML Editor Support
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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