Completely disable Pretty-Print
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 2
- Joined: Thu Jun 04, 2009 10:17 pm
Completely disable Pretty-Print
Is there a way to completely disable Pretty-Print?
I want to edit a XML styled with a CSS then import it in InDesign but when Oxygen reformat to Pretty-Print is doesn't import properly in InDesign.
Thanks!
I want to edit a XML styled with a CSS then import it in InDesign but when Oxygen reformat to Pretty-Print is doesn't import properly in InDesign.
Thanks!
-
- Posts: 9439
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Completely disable Pretty-Print
Hi,
You are probably referring to the pretty-print which is done when the XML displayed in the Author page gets saved.
You can either set an "xml:space='preserve'" attribute on the XML root element or in the associated CSS file add a rule like:
Of course the rule can be more specific if you discover what elements need to be skipped from pretty-printing.
Regards,
Radu
You are probably referring to the pretty-print which is done when the XML displayed in the Author page gets saved.
You can either set an "xml:space='preserve'" attribute on the XML root element or in the associated CSS file add a rule like:
Code: Select all
* {
white-space:pre;
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 80
- Joined: Wed Jan 14, 2009 12:50 pm
Re: Completely disable Pretty-Print
Can you give clear step-by-step instructions for what to do?
In particular, I want to be able to switch back and forth between Text and Author views without any spaces being added anywhere at all. I am happy for Oxygen to generate line breaks between elements of my choice when switching from Author to Text view, so long as these are then ignored for display purposes when I switch back to Author view; I have the line breaks in my Author view generated by my CSS as generated content at present because I don't want my authors inserting any punctuation or linebreaks (they can't be relied upon to be consistent in these).
I have tried using xml:space='preserve' as an attribute in the Schema for the document; it is valid there, but seems to have no effect whatsoever. I then tried it as an attribute of elements in the document itself, and it was rejected there as invalid. What am I supposed to do with it? Or doesn't it work? Or is there some other work round?
Why is something which causes so much mayhem in simple text files (it doubles the size of my files and introduces spaces within the text content of elements), viz. pretty-print, not able to be enabled/disabled by a simple option in Oxygen?
Any help on this totally baffling point (since the manual offers none, it seems) would be appreciated.
In particular, I want to be able to switch back and forth between Text and Author views without any spaces being added anywhere at all. I am happy for Oxygen to generate line breaks between elements of my choice when switching from Author to Text view, so long as these are then ignored for display purposes when I switch back to Author view; I have the line breaks in my Author view generated by my CSS as generated content at present because I don't want my authors inserting any punctuation or linebreaks (they can't be relied upon to be consistent in these).
I have tried using xml:space='preserve' as an attribute in the Schema for the document; it is valid there, but seems to have no effect whatsoever. I then tried it as an attribute of elements in the document itself, and it was rejected there as invalid. What am I supposed to do with it? Or doesn't it work? Or is there some other work round?
Why is something which causes so much mayhem in simple text files (it doubles the size of my files and introduces spaces within the text content of elements), viz. pretty-print, not able to be enabled/disabled by a simple option in Oxygen?
Any help on this totally baffling point (since the manual offers none, it seems) would be appreciated.
-
- Posts: 9439
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Completely disable Pretty-Print
Hi,
You have 2 options:
1) Open the CSS used to render the XML file in Oxygen.
If you do not know where it is located, it is either associated with the XML via a processing instruction or it is associated via the document type used for the XML file.
In the CSS file for the elements for which you do not want indent or line breaks just add CSS rules like:
2) The xml:space='preserve' attribute specified on the root element of the XML file should work for what you need and no format and indent will be done when saving in the Author page.
If it is marked as invalid by the automatic validation then you can specify in the associated schema that the root element can accept "xml:space" as an attribute. Just add an import in the schema:
and then add an attribute reference on the root element like:
Regards,
Radu
You have 2 options:
1) Open the CSS used to render the XML file in Oxygen.
If you do not know where it is located, it is either associated with the XML via a processing instruction or it is associated via the document type used for the XML file.
In the CSS file for the elements for which you do not want indent or line breaks just add CSS rules like:
Code: Select all
element_name {
white-space:pre-wrap;
}
2) The xml:space='preserve' attribute specified on the root element of the XML file should work for what you need and no format and indent will be done when saving in the Author page.
If it is marked as invalid by the automatic validation then you can specify in the associated schema that the root element can accept "xml:space" as an attribute. Just add an import in the schema:
Code: Select all
<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
Code: Select all
<xs:attribute ref="xml:space"/>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 80
- Joined: Wed Jan 14, 2009 12:50 pm
Re: Completely disable Pretty-Print
OK. Thanks, I have now done both the things in (2) and it seems to work.
[In fact, I added not to the root but to relevant descendant elements, to allow some reformatting, i.e. inserting line breaks in helpful places, when switching to Text view and to ensure that Oxygen inserts the attribute automatically when adding a new relevant entity in Author view.]
[In fact, I added
Code: Select all
<xs:attribute ref="xml:space" fixed="preserve" use="required"/>
-
- Posts: 80
- Joined: Wed Jan 14, 2009 12:50 pm
Re: Completely disable Pretty-Print
My mistake - it only seemed to work. What in fact it did was to make the XML document valid against the Schema but then made the Schema itself invalid. The consequence of this seems to be that the XML document is not validated at all (hence no problems show up) because the Schema was unable to be validated. Here is the problematic part of the Schema:
When validated, the <xs:attribute ..> is underlined in red and the error produced is the following:
Can you indicate the correct formulation of this fragment so that it validates OK?
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xs:element name="rootelement">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="subelement"/>
</xs:sequence>
<xs:attribute ref="xml:space"/>
</xs:complexType>
</xs:element>
..
</xs:schema>
and alsoE [Xerces] src-resolve: Cannot resolve the name 'xml:space' to a(n) 'attribute declaration' component.
both referring to the relevant line.E [Xerces] s4s-elt-invalid-content.1: The content of '#AnonType_MLDFASC' is invalid. Element 'attribute' is invalid, misplaced, or occurs too often.
Can you indicate the correct formulation of this fragment so that it validates OK?
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Completely disable Pretty-Print
Post by sorin_ristache »
For example the following is a valid XML Schema:
Do you get validation errors for this schema in Oxygen? What Oxygen version do you use?
Regards,
Sorin
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xs:element name="rootelement">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="subelement"/>
</xs:sequence>
<xs:attribute ref="xml:space"/>
</xs:complexType>
</xs:element>
<xs:element name="subelement" type="xs:string"/>
</xs:schema>
Regards,
Sorin
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