Exception when insert XML Fragment in topicref element

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Ship
Posts: 5
Joined: Thu Jun 07, 2012 10:37 am

Exception when insert XML Fragment in topicref element

Post by Ship »

I have DITA map in custom Resolved mode as:

Code: Select all


<map>
<title>Some sections</title>
<topicref format="dita" href="topic_0601.dita" locktitle="yes" navtitle="06012">
<topic>
<title class="- topic/title " conaction="-dita-use-conref-target" conkeyref="">Some title</title>
<body class="- topic/body ">
<p>{placeToInsertImageElement}</p>
</body>
</topic>
</topicref>
</map>
XSD schema for resolved mode allows to insert "image" element inside "p" element.
But when I trying to do it on Author Editor Applet the exception is thrown:

Code: Select all

ro.sync.ecss.extensions.api.AuthorOperationException: Could not create an AuthorDocumentFragment. Cause: null
at ro.sync.ecss.e.e.createNewDocumentFragmentInContext(Unknown Source)
at ro.sync.ecss.action.SelectorImageAction.actionPerformed(SelectorImageAction.java:52)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.io.IOException
at ro.sync.io.bb.f(Unknown Source)
at ro.sync.io.bb.d(Unknown Source)
at ro.sync.io.bb$2.read(Unknown Source)
at java.io.PipedReader.read(Unknown Source)
at ro.sync.io.bb$2.read(Unknown Source)
at ro.sync.io.o.read(Unknown Source)
at ro.sync.io.lb.d(Unknown Source)
at ro.sync.io.lb.b(Unknown Source)
at ro.sync.io.lb.c(Unknown Source)
at ro.sync.io.d.g(Unknown Source)
at ro.sync.io.d.j(Unknown Source)
at ro.sync.io.d.x(Unknown Source)
at ro.sync.ecss.e.n.k(Unknown Source)
at ro.sync.ecss.e.n.r(Unknown Source)
at ro.sync.ecss.e.e.oc(Unknown Source)
... 38 more
I used API as:

Code: Select all


String xmlFragment = "<image href=\"1.jpg\" />";
int caretOffset = getAuthorAccess().getEditorAccess().getCaretOffset();
getAuthorAccess().getDocumentController().insertXMLFragmentSchemaAware(xmlFragment, caretOffset);
Do you have any suggestions for that problem?
Regards,
Ivan
Radu
Posts: 9449
Joined: Fri Jul 09, 2004 5:18 pm

Re: Exception when insert XML Fragment in topicref element

Post by Radu »

Hi Ivan,

The stack trace seems to indicate that from your custom action called SelectorImageOperation you directly call our API method:

Code: Select all

ro.sync.ecss.extensions.api.AuthorDocumentController.createNewDocumentFragmentInContext(String, int)
Could you double check in your code where this method gets invoked that the passed XML string is not NULL?

In the AuthorComponentSampleApplet class before the AuthorComponentSample constructor gets called you could add the following line:

org.apache.log4j.Logger.getRootLogger().setLevel(Level.ALL);

This line should enable full logging in the applet, making it work much slower.
The Java error console should then present a lot of verbose logging while the applet is loaded and then when the action is invoked you should also find in the console the stack trace of the original NullPointerException. If so, please post it here.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Ship
Posts: 5
Joined: Thu Jun 07, 2012 10:37 am

Re: Exception when insert XML Fragment in topicref element

Post by Ship »

Hi Radu,
I'm sure that invoked this method XML string is not NULL. Here is the source code in my called method:

Code: Select all


String xmlFragment = "<image id=\"new_image-"+System.nanoTime()+"\" href=\"\" />";
AuthorAccess authorAccess = authorComponent.getAuthorComponentProvider().getAuthorAccess();
int caretOffset = authorAccess.getEditorAccess().getCaretOffset();
authorAccess.getDocumentController().insertXMLFragmentSchemaAware(xmlFragment, caretOffset);
Hence there is no NullPointerException.
I noticed that when I am try adding an element inside topicref as last dita code example the similar exception is thrown.
I hope for your help.
Regards,
Ivan
Radu
Posts: 9449
Joined: Fri Jul 09, 2004 5:18 pm

Re: Exception when insert XML Fragment in topicref element

Post by Radu »

Hi Ivan,

We need more details.
You can contact us using the support@oxygenxml.com email address.
Either you enable logging in the applet as I stated in the previous post:
In the AuthorComponentSampleApplet class before the AuthorComponentSample constructor gets called you could add the following line:

org.apache.log4j.Logger.getRootLogger().setLevel(Level.ALL);

This line should enable full logging in the applet, making it work much slower.
The Java error console should then present a lot of verbose logging while the applet is loaded and then when the action is invoked you should also find in the console the stack trace of the original NullPointerException.
Then you send the entire content of the Java console to the email address mentioned above.

or even better:

We need a sample XML + XML Schema + sources of the SelectorImageAction operation to reproduce the problem on our side.

How is the XML Schema associated to the XML you are editing? Is it associated via an xsi:schemaLocation attribute or as a default schema via the defined document type association?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Ship
Posts: 5
Joined: Thu Jun 07, 2012 10:37 am

Re: Exception when insert XML Fragment in topicref element

Post by Ship »

Hi Radu,
Problem resolved in my source code, I'm sorry for the trouble.
Thanks for your help.
Regards,
Ivan
Post Reply