Insert cascade dependencies

Post here questions and problems related to oXygen frameworks/document types.
damarislc
Posts: 5

Insert cascade dependencies

Wed Nov 07, 2018 7:34 pm

Hi,

I'm trying to insert various element levels, for example, if I enter the element <glossentry> it automatically should be fill like this:

Code: Select all

<glossentry>
<glossterm></glossterm>
<glossdef>
<p></p>
</glossdef>
</glossentry>
I'm using SchemaManagerFilter for doing this, I can insert the <glossterm> and <glossdef> sucessfuly, but due glossdef its auto inserted, the <p> element is not been added.

Here is my code:

Code: Select all

private static final List<String> ELEMENTS_WITH_MANDATORY_P_CHILD =
Arrays.asList(new String[] {"section", "note", "li", "context", "info", "stepresult", "entry", "stentry", "choice", "result", "glossdef"});

@Override
public List<CIElement> filterElements(final List<CIElement> elements,
final WhatElementsCanGoHereContext context) {

final List<CIElement> filteredElements = super.filterElements(elements, context);

if ((context != null) && (filteredElements != null)) {
for (final CIElement element : filteredElements) {
final String elementName = element.getQName();

//is the current element a glossentry?
if(elementName.equals("glossentry")) {
addGlossentryChilds(element);
}

// is the current element included in the list of elements with mandatory child p?
if (ELEMENTS_WITH_MANDATORY_P_CHILD.contains(elementName)) {
addChildPElement(element);
}

//here is where the glossdef subelement should be add the child <p>
final List<CIElement> childElements = element.getGuessElements();
// Verify in the child Elements if there are more elements that
// will be "auto" completed.
getSubElements(childElements);
}
}
return filteredElements;
}

void addGlossentryChilds(final CIElement parent) {
final CIElement glosstermElement = new GlosstermElement();
final CIElement glossdefElement = new GlossdefElement();

parent.addGuessElement(glosstermElement);
parent.addGuessElement(glossdefElement);
}
How can I do to insert also the <p> automatically when added the <glossdef> ?
alex_jitianu
Posts: 656

Re: Insert cascade dependencies

Thu Nov 08, 2018 1:46 pm

Hello,

In our SDK sample project, inside the oxygen-sample-framework module, thre is an implementation of an ro.sync.contentcompletion.xml.CIElement named simple.documentation.framework.SDFElement. After you copy this impllementation into your own project all you have to do is build the hierarchy:

Code: Select all


glossterm.setName("glossterm");
glossentry.addGuessElement(glossterm);

CIElement glossdef = new SDFElement();
glossdef.setName("glossdef");
glossentry.addGuessElement(glossdef);

CIElement p = new SDFElement();
p.setName("p");
glossdef.addGuessElement(p);
As an alternative, you can configure content completion through a configuration file. You can obtain the same result by adding these lines inside such a configuration file:

Code: Select all

<elementProposals path="glossentry" insertElements="glossterm glossdef"/>
<elementProposals path="glossdef" insertElements="p"/>
<elementProposals path="p" insertElements="b"/>
Best regards,
Alex
damarislc
Posts: 5

Re: Insert cascade dependencies

Thu Nov 08, 2018 11:27 pm

Awesome, the first solution worked perfectly.

Thanks!

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

Who is online

Users browsing this forum: No registered users and 0 guests