Preventing Invalid Xml
Oxygen general issues.
-
- Posts: 45
- Joined: Wed May 23, 2012 11:20 am
Preventing Invalid Xml
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.
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
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>
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
-
- Posts: 9436
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Preventing Invalid Xml
Hi,
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
No, currently only the insert operations are schema aware.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?
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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9436
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Preventing Invalid Xml
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:
The handler also has useful callbacks like:
and:
The handler is at a higher level than the filter and it can be used to achieve similar functionality.
Regards,
Radu
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()
Code: Select all
ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandler.handleTyping(int, char, AuthorAccess)
Code: Select all
ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandler.handleDelete(int, int, AuthorAccess, boolean)
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 45
- Joined: Wed May 23, 2012 11:20 am
Re: Preventing Invalid Xml
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
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;
}
-
- Posts: 9436
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Preventing Invalid Xml
Hi Neil,
Basically the Javadoc for the method's return type is like this:
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
Basically the Javadoc for the method's return type is like this:
Code: Select all
@return <code>true</code> if the event was handled.
In your case when you want to prevent an edit, you should return true and do nothing.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Preventing Invalid Xml
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):
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
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):
You can download it from our web site:Author API: The AuthorDocumentFilter was notified with an incorrect flag when the backspace key was pressed.
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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 5
- Joined: Thu Sep 13, 2012 1:55 pm
Re: Preventing Invalid Xml
Hi,
On this:
We did try it anyway, e.g. adding this to our options.xml, but it didn't work...
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?
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?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 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>
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Preventing Invalid Xml
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.
Best regards,
Mihaela
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>
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Posts: 5
- Joined: Thu Sep 13, 2012 1:55 pm
Re: Preventing Invalid Xml
Thanks for the quick reply! Yes, we had that in - we basically just pasted the whole thing in from exported preferences: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.
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>
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Preventing Invalid Xml
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?
Regards,
Mihaela
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>
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Preventing Invalid Xml
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
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
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Posts: 5
- Joined: Thu Sep 13, 2012 1:55 pm
Re: Preventing Invalid Xml
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.
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Preventing Invalid Xml
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
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
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Posts: 5
- Joined: Thu Sep 13, 2012 1:55 pm
Re: Preventing Invalid Xml
Thanks Mihaela.
Yeah, we have a framework for the document, and code completion suggests the relevant elements, etc.mihaela wrote:Have you created a framework for your document or are you trying to edit a simple XML that has a schema associated?
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Preventing Invalid Xml
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
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
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Preventing Invalid Xml
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
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
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
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