In Writer, images (and other objects) can be given a title <svg:title> and a description <svg:description>. When exporting ODT documents to XHTML, the title should end up in the alt attribute of the image element. (<svg:desc> should be handled differently, but I keep that separate).
Steps to reproduce the issue:
1. Create a document in Writer and insert three images; give the first one only a title, give the second one only a description and give the third one both a title and a description. (Process: right-click on each image and go to Description...)
2. Save the file and export it to XHTML.
3. Open the XHTML file in a source code editor and verify that the Title is not available in the alt attribute of the img elements.
This is easy to fix:
in the stylesheet body.xsl for XHTML export, replace the lines
(I did this in my own installation of LibreOffice and it works.)
* In my tests, the <xsl:otherwise> statement that produces a warning when there is no <svg:title> was never triggered.
* The title attribute on HTML img elements is used for tooltips, not for accessible text alternatives.
Additional information from "Open Document Format for Office Applications
(OpenDocument) v1.1", the OASIS standard.
From section 9.2.20: Title and Description:
"The <svg:title> and <svg:desc> elements specify text-only description strings
for graphical objects as specified in §5.4 of [SVG].
The <svg:title> element is used as a short accessible name.
The <svg:desc> element is used for the long description in support of
See appendix E for guidelines how to use these elements."
So <svg:title> needs to be exported as text alternative in the img element's alt attribute.
Please attach the original odt-file. I get nothing, which fit to your description. If I insert an image, I get an img-Element and nothing with svg. If I insert a drawing object, for example a rectangle, in an odt-document, I get no element in xhtml at all.
Are you sure, you are exporting to XHTML? Or do you save as HTML?
In case of an image, the xhtml-text is indeed wrong. The alternative text in LO (given in the picture property dialog in the tab 'Option') should go to the alt-attribute, the title in LO should go to the title-attribute and the description in LO should go to a longdesc-attribute in xhtml.
Created attachment 49607 [details]
ODF test file with three images, one with only title, one with only description, one with both
(In reply to comment #1)
> Please attach the original odt-file. I get nothing, which fit to your
> description. If I insert an image, I get an img-Element and nothing with svg.
> If I insert a drawing object, for example a rectangle, in an odt-document, I
> get no element in xhtml at all.
When you create an ODT file following the procedure I described, the image is wrapped in a <draw:frame> element which contains:
* a <draw:image> element for the image itself,
* a <svg:title> element if the image has been given a title,
* a <svg:desc> element if the image has been given a description.
To verify this, unpack the ODT-file with an unzip utility, and view the file 'content.xml' in a source code editor.
> Are you sure, you are exporting to XHTML? Or do you save as HTML?
In Writer, I went to File > Export...; in the Export dialog I chose the option "XHTML (.html,xhtml)".
(When you choose File > Save as... and select "HTML Document (OpenOffice.org Writer) (.html)" in the Save As dialog, you get a different output, and <svg:title> is converted to the alt attribute of the img element. However, this bug is about the XHTML export.)
> In case of an image, the xhtml-text is indeed wrong. The alternative text
> in LO
> (given in the picture property dialog in the tab 'Option') should go to the
> alt-attribute, the title in LO should go to the title-attribute and the
> description in LO should go to a longdesc-attribute in xhtml.
This is not correct:
* <svg:title> should go to the alt attribute (consult the ODF and HTML specifications);
* <svg:desc> cannot go to the longdesc attribute because the longdesc attribute must contain a URL or a fragment identifier, not plain text (so the content of <svg:desc> should go in a separate file or to a separate section in the same HTML file, the longdesc would then point to it)
* the title attribute in HTML is not read by screen readers; it is not used for accessible text alternatives.
PS: The alternative text in the 'Option' tab for an image is the same text as the Title in the Description dialog.
Created attachment 49616 [details]
Export of the test file to XHTML
The attached file is the result of my export to XHTML. There is nothing with "svg". I have used LO3.4.2RC1 on WinXP.
(In reply to comment #4)
> Created an attachment (id=49616) [details]
> Export of the test file to XHTML
> The attached file is the result of my export to XHTML. There is nothing with
> "svg". I have used LO3.4.2RC1 on WinXP.
Indeed, there is no <svg:xxx> in the OUTPUT. I never made that claim.
The issue is that <svg:title> in the INPUT (the content.xml that you can extract from ODF with an unzip tool) is not converted to img/@alt in the output.
In other words:
* the current XHTML export converts <svg:desc> from the INPUT into img/@alt in the OUTPUT,
* the XHTML export should convert <svg:title> from the INPUT into img/@alt in the OUTPUT.
Created attachment 49870 [details]
Patch as unified diff file
Patch for body.xsl as discussed in the original post. Changes just three lines.
Christophe, could you please send your patch, generated from git format-patch, to the developer mailing list instead?
For the instruction, see http://wiki.documentfoundation.org/Development#Preparing_patches
Created attachment 49917 [details]
Patch generated with git diff.
Added a patch generated with git diff. This patch has been sent to the developer mailing list.
Shouldn't this problem be marked as resolved? As I see there is already a patch for it.
I don't know the exact process. I assume the patch should be accepted before the bug is closed, and I have not received news about acceptance of the patch (although that should be trivial).
fixed for 3.5
Migrating Whiteboard tags to Keywords: (EasyHack DifficultyBeginner)