Insert with Schema Aware behavior issue

Post here questions and problems related to oXygen frameworks/document types.
Isabelle
Posts: 142
Joined: Fri Jan 20, 2017 1:11 pm

Insert with Schema Aware behavior issue

Post by Isabelle »

Hello,

We work with Oxygen SDK 24.0.0.2

We want to insert element (String fragment or AuthorDocumentFragment) with the following method
insertFragmentSchemaAware(int insertOffset, AuthorDocumentFragment frag)
insertXMLFragmentSchemaAware(java.lang.String xmlFragment, int offset)
insertXMLFragmentSchemaAware(java.lang.String xmlFragment, int offset, boolean replaceSelection)
insertXMLFragmentSchemaAware(java.lang.String xmlFragment, int offset, int actionID, boolean replaceSelection)
insertXMLFragmentSchemaAware(java.lang.String xmlFragment, java.lang.String xpathLocation, java.lang.String relativePosition)
insertXMLFragmentSchemaAware(java.lang.String xmlFragment, java.lang.String xpathLocation, java.lang.String relativePosition, boolean insertEvenIfInvalid)
But the result is not efficient.
Sometimes it inserted well in the good node but sometimes, it looks to the siblings and insert the new fragment in other node, which it is not what we asked for.

Is it possible to force the schema aware to insert at caret position, no matters siblings ?
We want to keep the notion of schema aware to secure our fragment insertion and drag & drop.
But the curent behavior is actually not efficient for us, as we can not garante where the fragment will be inserted.

Otherwise is there a way for us to simulate schema aware notion ?
For exemple, I want to insert the element <picture/> into the element <topic/>
but the element <topic/> has the following structure :

Code: Select all

<topic>
	<topicContent>
		<picture/>
	</topicContent>
</topic>
I tried to build something with AuthorSchemaManager interface, with whatElementsCanGoHere and getElementToParentsMap methods,
to generate a new fragment <topicContent><picture/></topicContent>
and then insert it without schemareAware, but it is really complicated.

Thanks for any help.
Regards.
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Insert with Schema Aware behavior issue

Post by Radu »

Hi Isabelle,
But the result is not efficient.
The schema aware insertion strategies were created to work over any XML document as long as a schema is provided for it, it may be possible that for particular xml + schema situations for it to not produce exactly what you want.
Sometimes it inserted well in the good node but sometimes, it looks to the siblings and insert the new fragment in other node, which it is not what we asked for.
If you give us a small XML + schema sample and precise steps to reproduce the problem maybe we can improve the current functionality.
Is it possible to force the schema aware to insert at caret position, no matters siblings ?
Well if you want to force insertion at the caret position, you can just plain insert, without schema ware.
We want to keep the notion of schema aware to secure our fragment insertion and drag & drop.
But the curent behavior is actually not efficient for us, as we can not garante where the fragment will be inserted.
The schema aware insertion behavior is not random, at a certain offset in the XML it will always have a certain behavior.
Otherwise is there a way for us to simulate schema aware notion ?
For exemple, I want to insert the element <picture/> into the element <topic/>
but the element <topic/> has the following structure :
.......
I tried to build something with AuthorSchemaManager interface, with whatElementsCanGoHere and getElementToParentsMap methods,
to generate a new fragment <topicContent><picture/></topicContent>
and then insert it without schemareAware, but it is really complicated.
This would have been also my proposed workaround, use Oxygen's AuthorSchemaManager API to detect what elements are available at a certain offset and change (at least in some situations) how the content should be inserted. It should be not that difficult if you identity only the situations where you want to take control and for all others keep inserting schema aware.

You should try to make a precise list of cases when the schema aware insertion does not do what you want, it would be useful for you and if you share with us a sample xml + schema and the list of situations maybe we could also work to improve the behavior.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Isabelle
Posts: 142
Joined: Fri Jan 20, 2017 1:11 pm

Re: Insert with Schema Aware behavior issue

Post by Isabelle »

Hi Radu,

How can I send you xml and schema for test ?

Regards,
Isabelle
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Insert with Schema Aware behavior issue

Post by Radu »

Hi Isabell,

You can send us a zip via email (support@oxygenxml.com) if it is small or use our tech support form to attach a larger zip file: https://www.oxygenxml.com/technical_support_policy.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Isabelle
Posts: 142
Joined: Fri Jan 20, 2017 1:11 pm

Re: Insert with Schema Aware behavior issue

Post by Isabelle »

Hello,

I have just send you a zip file and the description of our use case.

Hope it will help you to understand our problem.

Regards,
isabelle
Post Reply