Remove Namespace from selected node
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 47
- Joined: Thu Jun 19, 2014 3:55 pm
Remove Namespace from selected node
Hi,
we are using the Eclipse Oxygen Author in Version 15.2.
My use case is to copy the content from a selected node and save it.
I get the node, which content will be copied from this method:
Then I create AuthorDocumentFragment with this method:
When I serialize the fragment there is an class attribute with the namespace from DITA on the node.
The problem is that the dtd do not allow this attribute on this node.
Is it possible to filter this attribute, before serializing it?
Best regards
Denis
we are using the Eclipse Oxygen Author in Version 15.2.
My use case is to copy the content from a selected node and save it.
I get the node, which content will be copied from this method:
Code: Select all
authorEditorPageBase.getFullySelectedNode()
Then I create AuthorDocumentFragment with this method:
Code: Select all
documentController.createDocumentFragment(authorNode, copyContent);
documentController.serializeFragmentToXML(fragment);
The problem is that the dtd do not allow this attribute on this node.
Is it possible to filter this attribute, before serializing it?
Best regards
Denis
Denis Zygann
KGU Consulting GmbH
http://www.kgu-consulting.com
KGU Consulting GmbH
http://www.kgu-consulting.com
-
- Posts: 47
- Joined: Thu Jun 19, 2014 3:55 pm
Re: Remove Namespace from selected node
Hi Dan
Is there another way to copy the content from a node and its childs without to generating the namespace?
From my point of view its seems to be an bug, because I only want to copy the content and the namespace will be set on your side silently.
Best regards,
Denis
Is there another way to copy the content from a node and its childs without to generating the namespace?
From my point of view its seems to be an bug, because I only want to copy the content and the namespace will be set on your side silently.
Best regards,
Denis
Denis Zygann
KGU Consulting GmbH
http://www.kgu-consulting.com
KGU Consulting GmbH
http://www.kgu-consulting.com
-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
Re: Remove Namespace from selected node
For the moment there is no way to do that.
I understand your use case. For instance, when serializing a 'p' element you get something like:
For sure you do not need the 'ditaarch' namespace declaration, as it not used at all.
The xmlns="" is also redundant, having it or not on a root element without prefix does not make any difference.
Just a note: When inserting such a fragment with redundant namespaces into another DITA document, the namespaces are automatically cleared, so you won't have a problem. For instance copying the above 'p' element from a Docbook document and pasting into a DITA topic will clear its declarations, because they are already defined by the root of the topic (default attibute values).
I will record an issue about filtering the namespace declarations that are not necessary or redundant.
We will notify you when this will be ready. Until then, please post-process the serialized result.
Thank you,
Dan
I understand your use case. For instance, when serializing a 'p' element you get something like:
Code: Select all
<p xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" xmlns=""> some text </p>
The xmlns="" is also redundant, having it or not on a root element without prefix does not make any difference.
Just a note: When inserting such a fragment with redundant namespaces into another DITA document, the namespaces are automatically cleared, so you won't have a problem. For instance copying the above 'p' element from a Docbook document and pasting into a DITA topic will clear its declarations, because they are already defined by the root of the topic (default attibute values).
I will record an issue about filtering the namespace declarations that are not necessary or redundant.
We will notify you when this will be ready. Until then, please post-process the serialized result.
Thank you,
Dan
-
- Posts: 47
- Joined: Thu Jun 19, 2014 3:55 pm
Re: Remove Namespace from selected node
Hi
In our case the user can also open the copied content. So if he does so, the root element is this one with the namespace declaration in it. So the opened document is not valid and he has to remove it. This is quite annoying for a user.
Best regards
Denis
In our case the user can also open the copied content. So if he does so, the root element is this one with the namespace declaration in it. So the opened document is not valid and he has to remove it. This is quite annoying for a user.
Best regards
Denis
Denis Zygann
KGU Consulting GmbH
http://www.kgu-consulting.com
KGU Consulting GmbH
http://www.kgu-consulting.com
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: Remove Namespace from selected node
Post by alex_jitianu »
Hi Denis,
Like my colleague Dan said, right now you have to post process the fragment. What I wanted to add is that you could just execute a replace on the existing string. Something like this:
Best regards,
Alex
Like my colleague Dan said, right now you have to post process the fragment. What I wanted to add is that you could just execute a replace on the existing string. Something like this:
Code: Select all
AuthorDocumentFragment fragment = documentController.createDocumentFragment(authorNode, copyContent);
String serialized = documentController.serializeFragmentToXML(fragment);
serialized = serialized.replace("xmlns:ditaarch=\"http://dita.oasis-open.org/architecture/2005/\" xmlns=\"\"", "");
Alex
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