How to retreive the xml file encoding ?
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 124
- Joined: Tue May 29, 2012 5:42 pm
How to retreive the xml file encoding ?
Post by sebastienlavandier »
Hi,
I want to know if a getter exist in the Oxygen Author API for find the xml file encoding ?
Something like: authorAccess.getDocumentController().getDoctype();
Thanks for your help.
Sébastien
I want to know if a getter exist in the Oxygen Author API for find the xml file encoding ?
Something like: authorAccess.getDocumentController().getDoctype();
Thanks for your help.
Sébastien
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How to retreive the xml file encoding ?
Hi Sébastien,
We do not have such an API. Could you elaborate on the use case? Maybe we could add such API in the future.
If you use our "editorComponentProvider.getWSEditorAccess().save()" API the document will be saved with the proper encoding detected when it was opened.
But indeed if you create a reader over the document and then construct a file output stream on it you would need to know the proper encoding for saving the document.
One workaround would be to create the reader over the document's content and look in it for the XML
declaration:
If it contains an encoding, it can be used for save. But it's more complicated because the encoding specified in the XML declaration is a IANA encoding and it needs to be converted to a Java encoding to be used when creating an OutputStreamWriter over the file output stream. The code we use to detect the proper encoding on save is quite large.
If there is no XML declaration or if it does not contain an encoding you fall-back to UTF-8.
Regards,
Radu
We do not have such an API. Could you elaborate on the use case? Maybe we could add such API in the future.
If you use our "editorComponentProvider.getWSEditorAccess().save()" API the document will be saved with the proper encoding detected when it was opened.
But indeed if you create a reader over the document and then construct a file output stream on it you would need to know the proper encoding for saving the document.
One workaround would be to create the reader over the document's content and look in it for the XML
declaration:
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
If there is no XML declaration or if it does not contain an encoding you fall-back to UTF-8.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 124
- Joined: Tue May 29, 2012 5:42 pm
Re: How to retreive the xml file encoding ?
Post by sebastienlavandier »
Hi Radu,
Ok, it's my conclusion too.
Thanks for your help again.
Sébastien.
Ok, it's my conclusion too.
Thanks for your help again.
Sébastien.
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How to retreive the xml file encoding ?
Hi Sébastien,
I will also add an issue on our list so that in the future besides the API WSEditor.createContentReader() we could also add some API like WSEditor.createContentInputStream().
Regards,
Radu
I will also add an issue on our list so that in the future besides the API WSEditor.createContentReader() we could also add some API like WSEditor.createContentInputStream().
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How to retreive the xml file encoding ?
Hi Sébastien,
Oxygen 15.2 and the corresponding Author Component Project were released about a week ago.
In it we added the API:
ro.sync.exml.workspace.api.editor.WSEditorBase.createContentInputStream()
which should create an input stream with the proper encoding over the edited XML contents.
Regards,
Radu
Oxygen 15.2 and the corresponding Author Component Project were released about a week ago.
In it we added the API:
ro.sync.exml.workspace.api.editor.WSEditorBase.createContentInputStream()
which should create an input stream with the proper encoding over the edited XML contents.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “General XML Questions”
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