Format and Indent options, preserving newlines in XML
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 2
- Joined: Tue Jan 27, 2009 8:40 pm
Format and Indent options, preserving newlines in XML
Hi,
I'm having trouble figuring out which Editor / Format / XML options I need to set/unset to preserve new line characters between tags.
Say I start with this code:
Ideally I'd like the result to look like this:
But what ends up happening is that the formatting tool gives me this:
This is still valid XML but these changes actually make things difficult to edit and parse with non-XML aware tools like grep. So I'd like the formatting tool to do something, I don't want to preserve the text, but I don't want it to get rid of the new lines.
Is there an option for this?
Thanks
I'm having trouble figuring out which Editor / Format / XML options I need to set/unset to preserve new line characters between tags.
Say I start with this code:
Code: Select all
<tag>
a1
b2
c3
</tag>
Code: Select all
<tag>
a1
b2
c3
</tag>
Code: Select all
<tag> a1 b2 c3 </tag>
Is there an option for this?
Thanks
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Format and Indent options, preserving newlines in XML
Post by sorin_ristache »
Hello,
The formatting options available in Preferences / Editor / Format / XML cannot help you to preserve only some whitespaces (the newlines) inside a text content. There is an option for preserving the text content as is but that option either preserves the text of some XML elements in the same form or normalizes the whitespaces. The XML normalization process transforms a sequence of whitespace characters to only one space and the result is what you obtained:
For preserving only some whitespace characters (in your case the newline characters) you need custom formatting with an XSLT stylesheet. You can develop an XSLT stylesheet that preserves the input XML document with the exception of the text nodes which are normalized according with your custom rules.
Regards,
Sorin
The formatting options available in Preferences / Editor / Format / XML cannot help you to preserve only some whitespaces (the newlines) inside a text content. There is an option for preserving the text content as is but that option either preserves the text of some XML elements in the same form or normalizes the whitespaces. The XML normalization process transforms a sequence of whitespace characters to only one space and the result is what you obtained:
Code: Select all
<tag> a1 b2 c3 </tag>
Regards,
Sorin
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
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