white-space:normal CSS selector doesn’t work with <lines>, apparently
Post here questions and problems related to editing and publishing DITA content.
white-space:normal CSS selector doesn’t work with <lines>, apparently
Folks,
As far as I understand the DITA norm, the <lines> tag preserves linefeeds but discards multiple spaces.
However, using the DITA/CSS transform, I find that both linefeeds and spaces are preserved, much like if white-space:pre was implied (or <codeblock> used).
I tried to override this behaviour using a dedicated CSS section:
But that doesn’t work. The <line> tag is transformed into:
and the xml:space property seems to take precedence over the CSS.
Any idea how I can fix this? Thanks a bunch in advance.
As far as I understand the DITA norm, the <lines> tag preserves linefeeds but discards multiple spaces.
However, using the DITA/CSS transform, I find that both linefeeds and spaces are preserved, much like if white-space:pre was implied (or <codeblock> used).
I tried to override this behaviour using a dedicated CSS section:
Code: Select all
.lines {
white-space: normal;
}
<lines class="- topic/lines " xml:space="preserve">
and the xml:space property seems to take precedence over the CSS.
Any idea how I can fix this? Thanks a bunch in advance.
Re: white-space:normal CSS selector doesn’t work with <lines>, apparently
Hi,
You are publishing DITA content to PDF using CSS or to WebHelp output?
The DITA specification DTDs defines the xml:space=preserve as a default attribute for the DITA <lines> element. And the DTDs are provided by the OASIS technical committee which is in charge of developing the standard, this is not something we control.
So this is why that attribute appears when you publish the content (probably you were looking in the temporary files folder).
And the xml:space attribute present in the XML is stronger than CSS rules.
Not sure what to advice in this case, I think you can either:
1) Create a DITA DTD specialization which no longer defines this attribute on <lines> which is quite hard to do and impractical to maintain:
https://www.oxygenxml.com/doc/versions/ ... ation.html
2) Add some sort of publishing XSLT customization which matches on the <lines> element and removes this xml:space attribute.
Regards,
Radu
You are publishing DITA content to PDF using CSS or to WebHelp output?
The DITA specification DTDs defines the xml:space=preserve as a default attribute for the DITA <lines> element. And the DTDs are provided by the OASIS technical committee which is in charge of developing the standard, this is not something we control.
So this is why that attribute appears when you publish the content (probably you were looking in the temporary files folder).
And the xml:space attribute present in the XML is stronger than CSS rules.
Not sure what to advice in this case, I think you can either:
1) Create a DITA DTD specialization which no longer defines this attribute on <lines> which is quite hard to do and impractical to maintain:
https://www.oxygenxml.com/doc/versions/ ... ation.html
2) Add some sort of publishing XSLT customization which matches on the <lines> element and removes this xml:space attribute.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: white-space:normal CSS selector doesn’t work with <lines>, apparently
Hi Radu,
thanks for your answer.
The norm seems contradictory to me, but, as you emphasised, this is not your fault
Isn't there a way to insert the execution of a small script (in Python, or just plain shell) just before FO begins to parse the expanded XML source?
Multumesc,
Vincent
thanks for your answer.
The norm seems contradictory to me, but, as you emphasised, this is not your fault

Isn't there a way to insert the execution of a small script (in Python, or just plain shell) just before FO begins to parse the expanded XML source?
Multumesc,
Vincent
-
- Posts: 433
- Joined: Wed Oct 16, 2019 3:47 pm
Re: white-space:normal CSS selector doesn’t work with <lines>, apparently
Post by julien_lacour »
Hello Vincent,
This issue has already been addressed to DITA-OT: https://github.com/dita-ot/dita-ot/issues/4108
To avoid this situation, you can for example create a Schematron file with the following content:
Then, add this file into a custom validation scenario or the DITA framework default validation.
A warning will appear for each <lines> with multiple spaces and the quickfix will correct the element directly.
Regards,
Julien
This issue has already been addressed to DITA-OT: https://github.com/dita-ot/dita-ot/issues/4108
To avoid this situation, you can for example create a Schematron file with the following content:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2" xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<pattern id="lines-spaces">
<rule context="lines">
<report test="contains(text(), '  ')" role="warn" sqf:fix="removeExtraSpaces">Lines contains multiple spaces.</report>
<sqf:fix id="removeExtraSpaces">
<sqf:description>
<sqf:title>Remove extra spaces.</sqf:title>
</sqf:description>
<sqf:stringReplace match="text()" regex="  " select="' '"/>
</sqf:fix>
</rule>
</pattern>
</schema>
A warning will appear for each <lines> with multiple spaces and the quickfix will correct the element directly.
Regards,
Julien
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)
- ↳ 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 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