Page 1 of 1

Preventing Invalid Xml

Posted: Wed Jul 04, 2012 3:08 pm
by neon096
Is there a way of restricting the Author application to only allow actions which pass a given Schema (similar to what happens with the copy and paste actions)? So that we don’t have to code all the data model restrictions?

What we currently have is the following XML. However what we want is to allow the Author to delete <para/> but not allow deleting the section headings <content/> and <introduction/>. I’m currently using the AuthorDocumentFilter to restrict the delete. However the API I’m either misreading the API or the code is incorrect.

Code: Select all


<content>
<introduction>
<para/>
<para/>
<para/>
<para/>
</introduction>
<content>
The problems I am having is with the withBackspace parameter. The API says “withBackspace - true if BACKSPACE key was used for deleting the fragment”. However these are the values of withBackspace

Code: Select all


XML position             	    Key pressed	withBackspace value
Within text content of a para Backspace True
Within text content of a para Delete False
Start of a empty para Backspace False
Start of a empty para Delete True
Between para elements Backspace False
Between para elements Delete True

Re: Preventing Invalid Xml

Posted: Wed Jul 04, 2012 4:15 pm
by Radu
Hi,
Is there a way of restricting the Author application to only allow actions which pass a given Schema (similar to what happens with the copy and paste actions)? So that we don’t have to code all the data model restrictions?
No, currently only the insert operations are schema aware.
Maybe in a future version we will have schema-aware deletions as well.

Your other observations regarding the backspace key are correct, I will try to push a fix for this in one of the minor bug fix releases for Oxygen 14.0 which are announced here:

http://www.oxygenxml.com/rssBuildID.xml

Regards,
Radu

Re: Preventing Invalid Xml

Posted: Wed Jul 04, 2012 4:42 pm
by Radu
An alternative to use when trying to perform custom functionality when text is inserted/deleted would be to implement a "ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandlerAdapter".

You can look at the Java source for the "ro.sync.ecss.extensions.dita.DITASchemaAwareEditingHandler" which is instantiated on the method:

Code: Select all


ro.sync.ecss.extensions.dita.DITAExtensionsBundle.getAuthorSchemaAwareEditingHandler()
The handler also has useful callbacks like:

Code: Select all

ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandler.handleTyping(int, char, AuthorAccess)
and:

Code: Select all

ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandler.handleDelete(int, int, AuthorAccess, boolean)
The handler is at a higher level than the filter and it can be used to achieve similar functionality.

Regards,
Radu

Re: Preventing Invalid Xml

Posted: Thu Jul 05, 2012 10:41 am
by neon096
Thanks Radu,

Using the SchemaAwareHandler how would I handle a delete / prevent a delete. I've currently got the method which still allows a delete

Code: Select all


@Override
public boolean handleDelete(final int offset, final int deleteType, final AuthorAccess authorAcess, final boolean wordLevel) throws InvalidEditException {
System.out.println("Handle delete");
return false;
}

Re: Preventing Invalid Xml

Posted: Thu Jul 05, 2012 10:54 am
by Radu
Hi Neil,

Basically the Javadoc for the method's return type is like this:

Code: Select all

@return <code>true</code> if the event was handled.
So if you return false it basically means you are not interested in the event and the default processing should be performed.

In your case when you want to prevent an edit, you should return true and do nothing.

Regards,
Radu

Re: Preventing Invalid Xml

Posted: Tue Jul 10, 2012 4:08 pm
by adrian
Hello,

I just wanted to let you know that the backspace key problem has been resolved in the latest maintenance build of Oxygen 14.0, 2012070512 (released July 6th):
Author API: The AuthorDocumentFilter was notified with an incorrect flag when the backspace key was pressed.
You can download it from our web site:
http://www.oxygenxml.com/download.html

The list of bug-fixes can be found here:
http://www.oxygenxml.com/build_history.html#2012070512

You can follow the release/build RSS feed here:
http://www.oxygenxml.com/rssBuildID.xml

To upgrade:
- For Windows and Linux you can install the new build in the same folder as the previous installation, it will automatically upgrade it.
Before you upgrade, if you have added files or made changes to any of the files from the Oxygen installation folder(especially the frameworks folder), you may want to create a backup of them because they will be overwritten during the upgrade procedure. Custom frameworks will be preserved but we recommend backing them up anyway, just to be safe.
- For Mac OS X you will have to install in a different folder and copy any files you may have changed from the old folder (if any) to the new folder.
In all cases the Oxygen preferences will be preserved.

Let us know if you encounter further problems with this new build.

Regards,
Adrian

Re: Preventing Invalid Xml

Posted: Thu Sep 13, 2012 2:03 pm
by paul123
Hi,

On this:
neon096 wrote:Is there a way of restricting the Author application to only allow actions which pass a given Schema (similar to what happens with the copy and paste actions)? So that we don’t have to code all the data model restrictions?
Radu wrote:No, currently only the insert operations are schema aware.
Maybe in a future version we will have schema-aware deletions as well.
We have all the schema-aware stuff in Oxygen (e.g. http://www.oxygenxml.com/doc/ug-authorE ... aware.html) - why doesn't this work in the Author Component?

We did try it anyway, e.g. adding this to our options.xml, but it didn't work...

Code: Select all


<entry>
<String>author.editing.mode</String>
<authorSchemaAwareOptions>
<field name="isVerifyDeleteElementTagsAction">
<Boolean>true</Boolean>
</field>

Re: Preventing Invalid Xml

Posted: Thu Sep 13, 2012 3:13 pm
by mihaela
Hi,

The value of the "isVerifyDeleteElementTagsAction" field is taken into consideration only if the "schemaAwareEditingMode" field value is set to "schema_aware_editing_custom". Make sure that you have this field set in your options.xml.

Code: Select all


	<entry>
<String>author.editing.mode</String>
<authorSchemaAwareOptions>
<field name="isVerifyDeleteElementTagsAction">
<Boolean>true</Boolean>
</field>
<field name="schemaAwareEditingMode">
<String>schema_aware_editing_custom</String>
</field>
Best regards,
Mihaela

Re: Preventing Invalid Xml

Posted: Thu Sep 13, 2012 3:55 pm
by paul123
mihaela wrote:The value of the "isVerifyDeleteElementTagsAction" field is taken into consideration only if the "schemaAwareEditingMode" field value is set to "schema_aware_editing_custom". Make sure that you have this field set in your options.xml.
Thanks for the quick reply! Yes, we had that in - we basically just pasted the whole thing in from exported preferences:

Code: Select all

<entry>
<String>author.editing.mode</String>
<authorSchemaAwareOptions>
<field name="isVerifyDeleteElementTagsAction">
<Boolean>true</Boolean>
</field>
<field name="enableSmartDelete">
<Boolean>true</Boolean>
</field>
<field name="isVerifyPasteAndDNDAction">
<Boolean>true</Boolean>
</field>
<field name="enableSmartPaste">
<Boolean>true</Boolean>
</field>
<field name="isVerifyTypingAction">
<Boolean>true</Boolean>
</field>
<field name="enableSmartTyping">
<Boolean>true</Boolean>
</field>
<field name="insertOnlyElemensFromCCList">
<Boolean>true</Boolean>
</field>
<field name="isVerifyJoinAction">
<Boolean>true</Boolean>
</field>
<field name="schemaAwareEditingMode">
<String>schema_aware_editing_custom</String>
</field>
<field name="isVerifyUnwrapAction">
<Boolean>true</Boolean>
</field>
</authorSchemaAwareOptions>
</entry>

Re: Preventing Invalid Xml

Posted: Thu Sep 13, 2012 4:06 pm
by mihaela
Hi,

Are you sure that any of your options set in options.xml are applied to the Author component? You can try to do a simple test with changing the Author background color for example. If you add the following entry to your oxygen.xml, is the background color changed to red in the Author component?

Code: Select all

		<entry>
<String>author.background-color</String>
<String>255,0,0</String>
</entry>
Regards,
Mihaela

Re: Preventing Invalid Xml

Posted: Thu Sep 13, 2012 4:17 pm
by paul123
mihaela wrote:Are you sure that any of your options set in options.xml are applied to the Author component?
Yep - that gives a lovely shade of red background...

Re: Preventing Invalid Xml

Posted: Thu Sep 13, 2012 4:40 pm
by mihaela
Hi,

By default, the "Schema Aware Editing" option is set to "ON". This means that if you remove the entire "author.editing.mode" entry from oxygen.xml all the operations should be schema-aware. Can you try this and tell me if this is happening?

Regards,
Mihaela

Re: Preventing Invalid Xml

Posted: Thu Sep 13, 2012 4:48 pm
by paul123
Yeah, that's what we had before. The behaviour in the Authoring Component doesn't seem to differ whether we have that whole <entry> in or not. i.e. we're able to do changes to make a document invalid, e.g. delete something with minOccurs="1" in the schema. Whereas within Oxygen itself, even in Author mode, it (correctly) stops you from doing the same edit.

Re: Preventing Invalid Xml

Posted: Fri Sep 14, 2012 12:10 pm
by mihaela
Hi,

Have you created a framework for your document or are you trying to edit a simple XML that has a schema associated?

What I suspect is that you have a schema directly associated with your document (not through a framework) and the schema does not apply when the document is opened in the Author Component. To check this, please try to invoke the content completion (press "Enter" key) inside an element that should have child elements and tell me if the list is populated with elements.

If this is your case, try to create a framework for your document (in oXygen XML Editor or Author) and associate the schema through this framework. Deploy this framework in your Author component environment and try to reproduce the problem again. Can you still do changes that make the document invalid?

Best regards,
Mihaela

Re: Preventing Invalid Xml

Posted: Fri Sep 14, 2012 12:21 pm
by paul123
Thanks Mihaela.
mihaela wrote:Have you created a framework for your document or are you trying to edit a simple XML that has a schema associated?
Yeah, we have a framework for the document, and code completion suggests the relevant elements, etc.

Re: Preventing Invalid Xml

Posted: Fri Sep 14, 2012 2:31 pm
by mihaela
Hi,

Can you send us a document sample and your framework (to our support email address: support AT oxygenxml DOT com)? This would help us to find the source of your problem.

Regards,
Mihaela

Re: Preventing Invalid Xml

Posted: Mon Sep 17, 2012 2:39 pm
by mihaela
Hi,

You said that you have a framework defined for your document type. Maybe you could check again that the framework is correctly deployed and it is up-to-date (it is similar with the framework that you are using in the oXygen standalone version).

Best regards,
Mihaela