Insert cascade dependencies
Posted: 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:
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:
How can I do to insert also the <p> automatically when added the <glossdef> ?
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>
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);
}