Page 1 of 1

xmlns attribute is getting added

Posted: Fri Nov 11, 2022 12:56 pm
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
Can you please let me know how can avoid it from getting added.

Thanks,
Smita

Re: xmlns attribute is getting added

Posted: Fri Nov 11, 2022 4:02 pm
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?

Re: xmlns attribute is getting added

Posted: Mon Nov 14, 2022 8:03 am
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

Re: xmlns attribute is getting added

Posted: Mon Nov 14, 2022 12:28 pm
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.