xmlns attribute is getting added

Having trouble installing Oxygen? Got a bug to report? Post it all here.
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

xmlns attribute is getting added

Post by SmitaPatil »

Hi Team,
I am using below InsertFragmentOperation class to insert tag into document.
this.editor.getActionsManager();
actionManager.invokeOperation('ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation', {
fragment:fragmentToInsert
//schemaAware :true
},
Tag is getting added but xmlns attriibute is getting added
image.png
image.png (6.89 KiB) Viewed 509 times
Can you please let me know how can avoid it from getting added.

Thanks,
Smita
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: xmlns attribute is getting added

Post by Bogdan Dumitru »

Hello Smita,

You may have missed specifying the namespace to the fragment that's inserted.
What is the namespace of the fragment to be inserted?
What is the namespace of the document's root element?
Bogdan Dumitru
http://www.oxygenxml.com
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Re: xmlns attribute is getting added

Post by SmitaPatil »

Hi Bogdan,
Actually I just want to add tag in document.
for example in below case its a <bold></bold>
not a document.
Can you suggest any method or class which I can call to insert a tag or element in document.

Thanks & Regards,
Smita
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: xmlns attribute is getting added

Post by Bogdan Dumitru »

Hi Smita,

Try adding the "xmlns" attribute to your fragment, somewhat like this:

Code: Select all

<b xmlns="[YOUR-NAMSEPACE]"></b>
For an in-depth understanding of how the InsertFragmentOperation works, see the Arguments of InsertFragmentOperation topic that describes how elements without a namespace are inserted:
If there is a default namespace declared in the document and the document fragment does not declare a namespace, the elements from the fragment are considered to be in no namespace.
Bogdan Dumitru
http://www.oxygenxml.com
Post Reply