EmptyStackException

Post here questions and problems related to oXygen frameworks/document types.
Denis
Posts: 47

EmptyStackException

Fri Nov 07, 2014 4:52 pm

Hi,

we are using the Eclipse Oxygen Author in Version 15.2.

I use this method:

Code: Select all

  whatPossibleValuesHasAttributeContext = authorSchemaManager
                        .createWhatPossibleValuesHasAttributeContext(
                                authorElement, attributeAtIndex);


I get a EmptyStackException sometimes.

Code: Select all

   at java.util.Stack.peek(Stack.java:85)
   at java.util.Stack.pop(Stack.java:67)
   at ro.sync.ecss.contentcompletion.b.e(Unknown Source)
   at ro.sync.ecss.strictediting.k.createWhatPossibleValuesHasAttributeContext(Unknown Source)
   at de.kgucms.kgu.tps.client.oxygen.integration.adapter.AuthorNodePropertySource.handleAlreadyDeclaredAttributes(AuthorNodePropertySource.java:480)


Best regards,
Denis
Denis Zygann
KGU Consulting GmbH
http://www.kgu-consulting.com
Radu
Posts: 5751

Re: EmptyStackException

Fri Nov 07, 2014 4:58 pm

Hi Denis,

Could you add some logging like System.err.println(String.valueOf(authorElement)) to see for what element this fails?
Also, the node for which you call the method should always be a part of the current document (so you should not call the method for a node located in an AuthorDocumentFragment for example).

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Denis
Posts: 47

Re: EmptyStackException

Mon Nov 10, 2014 11:59 am

Hi Radu,

the error.println get this information

Code: Select all

<#reference href="file:path/To/Reference" ,> (3678, 3678)


The method works often without a problem, but sometimes I get the exception and I do not see the difference between the element which throws the exception and the elements, which not.

Best regards,
Denis
Denis Zygann
KGU Consulting GmbH
http://www.kgu-consulting.com
alex_jitianu
Posts: 649

Re: EmptyStackException

Mon Nov 10, 2014 5:10 pm

Hello Denis,

My colleague Radu is currently away on a conference so I will try to help you while he's not here.

This node is a reference not so you are probably inside a conref-ed content. I tried the same scenario and I didn't get an exception. This exception can happen if this node is not part of the document, if it comes from an AuthorDocumentFragment (like my colleague Radu also said). To test that you can use something like this:

Code: Select all

while (node != null) {
  System.out.println("Node " + node);
  node = node.getParent();
}


If you are not seeing all the elements up to the root, then you are in a fragment and you can't use this API for such nodes.

Also, you don't really need schema information for such a reference node. You most likely need it for its parent element, the one that has the conref attribute. These references nodes are transparent for the code that queries the schema, but just to see if it's any different, could you try something like this and see if you still get the exception?

Code: Select all

if (authorElement.getType() == AuthorNode.NODE_TYPE_REFERENCE) {
      authorElement = authorElement.getParent();
    }
   
    whatPossibleValuesHasAttributeContext = authorSchemaManager
        .createWhatPossibleValuesHasAttributeContext(
                authorElement, attributeAtIndex);


Best regards,
Alex

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 1 guest