Schematron: spacing before <ph> element
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 41
- Joined: Wed Jun 20, 2018 11:30 am
Schematron: spacing before <ph> element
Post by pieterjan_vdw »
I found a Schematron rule on Stack Overflow to check spaces before inline elements which is very handy.
https://stackoverflow.com/questions/375 ... schematron
It helps me to find spaces around <ph> tags.
However it doesn't work when the Indent inline elements is ticked in the preferences.
This is how it looks like in Author mode with Indent inline elements option ticked:
This is the same example in Text mode with Indent inline elements option ticked:
How can I update the rule in such a way that it doens't show this message when the Indent inline elements is ticked? Because in the Author mode I can see a space.
https://stackoverflow.com/questions/375 ... schematron
Code: Select all
<sch:pattern id="space-inline-elements-before">
<sch:rule context="ph">
<sch:assert test="ends-with(preceding::text()[1], ' ')"
role="warning"
sqf:fix="add-space-before-ph">Add space before <ph></sch:assert>
<sqf:fix id="add-space-before-ph">
<sqf:description>
<sqf:title>Add space before <ph></sqf:title>
</sqf:description>
<sqf:add position="before" match="." select="' '"/>
</sqf:fix>
</sch:rule>
</sch:pattern>
It helps me to find spaces around <ph> tags.
However it doesn't work when the Indent inline elements is ticked in the preferences.
- indent-line-elements.png (12.29 KiB) Viewed 975 times
- example-author-mode.png (5.84 KiB) Viewed 975 times
- example-text-mode.png (32.48 KiB) Viewed 975 times
Re: Schematron: spacing before <ph> element
Hi Pieterjan,
The Author mode does not present the content exactly as it is in the XML, if it did you would have a lot of indentation and line breaks in the visual editor. So it normalizes consecutive new lines and spaces in the XML content and presents them as a single space.
Your Schematron is applied on the serialized XML content so it needs to be flexible enough to take any case into account, maybe have the condition check if the string length of the previous text is > 0 but the string length of the "normalize-space()" of the previous text is 0.
Regards,
Radu
The Author mode does not present the content exactly as it is in the XML, if it did you would have a lot of indentation and line breaks in the visual editor. So it normalizes consecutive new lines and spaces in the XML content and presents them as a single space.
Your Schematron is applied on the serialized XML content so it needs to be flexible enough to take any case into account, maybe have the condition check if the string length of the previous text is > 0 but the string length of the "normalize-space()" of the previous text is 0.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 41
- Joined: Wed Jun 20, 2018 11:30 am
Re: Schematron: spacing before <ph> element
Post by pieterjan_vdw »
Thank you Radu. I'll try to update it with your suggestions.
Pieterjan
Pieterjan
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 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