Append XML content into root element

@param hrefValue    href of the topicref
@param parentResult XML content to insert into
@param tmpContent   XML content to insert
163291
private void insertAfter(final URI hrefValue, final StringBuffer parentResult, final CharSequence tmpContent) {
        int insertpoint = parentResult.lastIndexOf("</");
        final int end = parentResult.indexOf(">", insertpoint);

        if (insertpoint == -1 || end == -1) {
            logger.error(MessageUtils.getMessage("DOTJ033E", hrefValue.toString()).toString());
        } else {
            if (ELEMENT_NAME_DITA.equals(parentResult.substring(insertpoint, end).trim())) {
                insertpoint = parentResult.lastIndexOf("</", insertpoint - 1);
            }
            parentResult.insert(insertpoint, tmpContent);
        }
    }
1154538
public Xml addContent(Content content) {
        if(current == null) {
            throw new XmlModelException("Content can not be attached as root element: " + content.toString());
        }
        content.setParent(current);
        current.addChildElement(content);
        return this;
    }
291347
public static void updateXmlForHtmlValue(CmsLink link, String name, Element element) {

        // if element is not null
        if (element != null) {
            // update the additional attributes
            if (name != null) {
                updateAttribute(element, CmsLink.ATTRIBUTE_NAME, link.getName());
            }
            updateAttribute(element, CmsLink.ATTRIBUTE_INTERNAL, Boolean.toString(link.isInternal()));
            // update the common sub-elements and attributes
            updateXmlForVfsFile(link, element);
        }
    }
1299210
private void insertValueAfterReference(CmsEntity value, CmsAttributeValueView reference) {

        int valueIndex = -1;
        if (reference.getElement().getNextSiblingElement() == null) {
            m_entity.addAttributeValue(m_attributeName, value);
        } else {
            valueIndex = reference.getValueIndex() + 1;
            m_entity.insertAttributeValue(m_attributeName, value, valueIndex);
        }
        CmsAttributeValueView valueWidget = reference;
        if (reference.hasValue()) {
            valueWidget = new CmsAttributeValueView(
                this,
                m_widgetService.getAttributeLabel(m_attributeName),
                m_widgetService.getAttributeHelp(m_attributeName));
            CmsRenderer.setAttributeChoice(m_widgetService, valueWidget, getAttributeType());
            if (valueIndex == -1) {
                ((FlowPanel)reference.getParent()).add(valueWidget);
                m_attributeValueViews.remove(valueWidget);
                m_attributeValueViews.add(valueWidget);
            } else {
                ((FlowPanel)reference.getParent()).insert(valueWidget, valueIndex);
                m_attributeValueViews.remove(valueWidget);
                m_attributeValueViews.add(valueIndex, valueWidget);
                m_widgetService.addChangedOrderPath(getSimplePath(-1));
            }

        }
        valueIndex = valueWidget.getValueIndex();
        insertHandlers(valueIndex);
        I_CmsEntityRenderer renderer = m_widgetService.getRendererForAttribute(m_attributeName, getAttributeType());
        valueWidget.setValueEntity(renderer, value);
    }
542130
protected void initTemplates(Element root, CmsXmlContentDefinition contentDefinition) {

        String strEnabledByDefault = root.attributeValue(ATTR_ENABLED_BY_DEFAULT);
        m_allowedTemplates.setDefaultMembership(safeParseBoolean(strEnabledByDefault, true));
        List<Node> elements = root.selectNodes(APPINFO_TEMPLATE);
        for (Node elem : elements) {
            boolean enabled = safeParseBoolean(((Element)elem).attributeValue(ATTR_ENABLED), true);
            String templateName = elem.getText().trim();
            m_allowedTemplates.setContains(templateName, enabled);
        }
        m_allowedTemplates.freeze();
    }
820773
def append(self, parent, content):
        
        appender = self.default
        for matcher, candidate_appender in self.appenders:
            if matcher == content.value:
                appender = candidate_appender
                break
        appender.append(parent, content)
787030
function(item, parentNode) {
			if (!parentNode) {
				if (!this.domNode) {
					this.show();
				}
				parentNode = this.domNode;
			}
			var addCommand = this.itemConstructMap[item.type || 'item'];
			var node = addCommand.call(this, parentNode, item);
			item.domNode = node;
			this.items.push(item);
			return node;
		}
867133
public void addAttributeValuesToSaml1Attribute(final String attributeName,
                                                   final Object attributeValue,
                                                   final List<XMLObject> attributeList) {
        addAttributeValuesToSamlAttribute(attributeName, attributeValue, StringUtils.EMPTY,
            attributeList, AttributeValue.DEFAULT_ELEMENT_NAME);
    }
1093493
private void updateEditorValues(
        CmsEntity previous,
        CmsEntity updated,
        CmsEntity target,
        List<String> parentPathElements) {

        for (String attributeName : m_entityBackend.getType(target.getTypeName()).getAttributeNames()) {
            CmsAttributeHandler handler = getAttributeHandler(attributeName, parentPathElements);
            if (handler == null) {
                // non visible attribute, skip it
                continue;
            }
            if (previous.hasAttribute(attributeName)
                && updated.hasAttribute(attributeName)
                && target.hasAttribute(attributeName)) {
                CmsEntityAttribute updatedAttribute = updated.getAttribute(attributeName);
                CmsEntityAttribute previousAttribute = previous.getAttribute(attributeName);
                CmsEntityAttribute targetAttribute = target.getAttribute(attributeName);
                if (updatedAttribute.isSimpleValue()) {
                    if ((updatedAttribute.getValueCount() == previousAttribute.getValueCount())
                        && (updatedAttribute.getValueCount() == targetAttribute.getValueCount())) {
                        for (int i = 0; i < updatedAttribute.getValueCount(); i++) {
                            if (!updatedAttribute.getSimpleValues().get(i).equals(
                                previousAttribute.getSimpleValues().get(i))
                                && previousAttribute.getSimpleValues().get(i).equals(
                                    targetAttribute.getSimpleValues().get(i))) {

                                changeSimpleValue(
                                    attributeName,
                                    i,
                                    updatedAttribute.getSimpleValues().get(i),
                                    parentPathElements);
                            }
                        }
                    } else {
                        if (targetAttribute.getValueCount() == previousAttribute.getValueCount()) {
                            // only act, if the value count has not been altered while executing the server request
                            if (updatedAttribute.getValueCount() > previousAttribute.getValueCount()) {
                                // new values have been added
                                for (int i = 0; i < updatedAttribute.getValueCount(); i++) {
                                    if (i >= previousAttribute.getSimpleValues().size()) {
                                        handler.addNewAttributeValue(updatedAttribute.getSimpleValues().get(i));
                                    } else if (!updatedAttribute.getSimpleValues().get(i).equals(
                                        previousAttribute.getSimpleValues().get(i))
                                        && previousAttribute.getSimpleValues().get(i).equals(
                                            targetAttribute.getSimpleValues().get(i))) {
                                        changeSimpleValue(
                                            attributeName,
                                            i,
                                            updatedAttribute.getSimpleValues().get(i),
                                            parentPathElements);
                                    }
                                }
                            } else {
                                // values have been removed
                                for (int i = previousAttribute.getValueCount() - 1; i >= 0; i--) {
                                    if (i >= updatedAttribute.getSimpleValues().size()) {
                                        handler.removeAttributeValue(i);
                                    } else if (!updatedAttribute.getSimpleValues().get(i).equals(
                                        previousAttribute.getSimpleValues().get(i))
                                        && previousAttribute.getSimpleValues().get(i).equals(
                                            targetAttribute.getSimpleValues().get(i))) {
                                        changeSimpleValue(
                                            attributeName,
                                            i,
                                            updatedAttribute.getSimpleValues().get(i),
                                            parentPathElements);
                                    }
                                }
                            }
                        }
                    }
                } else {
                    if (targetAttribute.getValueCount() == previousAttribute.getValueCount()) {
                        // only act, if the value count has not been altered while executing the server request
                        if (updatedAttribute.getValueCount() > previousAttribute.getValueCount()) {
                            // new values have been added
                            for (int i = 0; i < updatedAttribute.getValueCount(); i++) {
                                if (i >= previousAttribute.getSimpleValues().size()) {
                                    handler.addNewAttributeValue(
                                        m_entityBackend.registerEntity(
                                            updatedAttribute.getComplexValues().get(i),
                                            true));
                                } else {
                                    List<String> childPathElements = new ArrayList<String>(parentPathElements);
                                    childPathElements.add(attributeName + "[" + i + "]");
                                    updateEditorValues(
                                        previousAttribute.getComplexValues().get(i),
                                        updatedAttribute.getComplexValues().get(i),
                                        targetAttribute.getComplexValues().get(i),
                                        childPathElements);
                                }
                            }
                        } else {
                            // values have been removed
                            for (int i = previousAttribute.getValueCount() - 1; i >= 0; i--) {
                                if (i >= updatedAttribute.getValueCount()) {

                                    handler.removeAttributeValue(i);
                                } else {
                                    List<String> childPathElements = new ArrayList<String>(parentPathElements);
                                    childPathElements.add(attributeName + "[" + i + "]");
                                    updateEditorValues(
                                        previousAttribute.getComplexValues().get(i),
                                        updatedAttribute.getComplexValues().get(i),
                                        targetAttribute.getComplexValues().get(i),
                                        childPathElements);
                                }
                            }
                        }
                    }
                }
            } else if (previous.hasAttribute(attributeName) && target.hasAttribute(attributeName)) {
                for (int i = target.getAttribute(attributeName).getValueCount() - 1; i >= 0; i--) {
                    handler.removeAttributeValue(i);
                }

            } else if (!previous.hasAttribute(attributeName)
                && !target.hasAttribute(attributeName)
                && updated.hasAttribute(attributeName)) {
                CmsEntityAttribute updatedAttribute = updated.getAttribute(attributeName);
                for (int i = 0; i < updatedAttribute.getValueCount(); i++) {
                    if (updatedAttribute.isSimpleValue()) {
                        handler.addNewAttributeValue(updatedAttribute.getSimpleValues().get(i));
                    } else {
                        handler.addNewAttributeValue(
                            m_entityBackend.registerEntity(updatedAttribute.getComplexValues().get(i), true));
                    }
                }
            }
        }
    }
285138
@Override
    public void processOtherContent(Wrapper<Content> content) {
        if (parentElement != null) {
            parentElement.addContent(content.getContent());
        }
    }
866547
public function addNode($parentNode, $name, $value = false)
    {
        // if $parentNode is a string, it is likely to be
        // an XPath expression. If so, it is converted
        // into a DOMElement.
        if (is_string($parentNode)) {
            if ($parentNode == "/") {
                $parentNode = $this->domDocument;
            } else {
                $parentNode = $this->getNode($parentNode);
            }
        }

        if ($parentNode) {
            try {
                $newNode = $this->domDocument->createElement($name);
                if (!is_array($value) && !is_resource($value)) {
                    $newNode->appendChild(
                        $this->domDocument->createTextNode($value)
                    );
                }

                return $parentNode->appendChild($newNode);
            } catch (\DOMException $exception) {
                throw new Dom\Exception("Could not add node named '$name'.");
            }
        } else {
            throw new Dom\Exception("Parent node not found: " . $parentNode);
        }
    }
696376
public void insertNewAttributeValue(CmsEntity value, int index, Panel container) {

        // make sure not to add more values than allowed
        int maxOccurrence = getEntityType().getAttributeMaxOccurrence(m_attributeName);
        CmsEntityAttribute attribute = m_entity.getAttribute(m_attributeName);
        boolean mayHaveMore = ((attribute == null) || (attribute.getValueCount() < maxOccurrence));
        if (mayHaveMore && value.getTypeName().equals(m_attributeType.getId())) {
            m_entity.insertAttributeValue(m_attributeName, value, index);
            int valueIndex = index;
            CmsAttributeValueView valueView = null;
            if ((m_attributeValueViews.size() == 1) && !m_attributeValueViews.get(0).hasValue()) {
                valueView = m_attributeValueViews.get(0);
            } else {
                valueView = new CmsAttributeValueView(
                    this,
                    m_widgetService.getAttributeLabel(m_attributeName),
                    m_widgetService.getAttributeHelp(m_attributeName));
            }
            CmsRenderer.setAttributeChoice(m_widgetService, valueView, getAttributeType());
            m_attributeValueViews.remove(valueView);
            m_attributeValueViews.add(index, valueView);

            ((FlowPanel)container).insert(valueView, index);

            insertHandlers(valueIndex);

            I_CmsEntityRenderer renderer = m_widgetService.getRendererForAttribute(m_attributeName, getAttributeType());
            valueView.setValueEntity(renderer, value);

            CmsUndoRedoHandler handler = CmsUndoRedoHandler.getInstance();
            if (handler.isIntitalized()) {
                handler.addChange(m_entity.getId(), m_attributeName, valueIndex, ChangeType.add);
            }
        }
    }
963107
Node insertChildAt(Node newChild, int index) throws DOMException {
        if (newChild instanceof DocumentFragment) {
            NodeList toAdd = newChild.getChildNodes();
            for (int i = 0; i < toAdd.getLength(); i++) {
                insertChildAt(toAdd.item(i), index + i);
            }
            return newChild;
        }

        LeafNodeImpl toInsert = (LeafNodeImpl) newChild;
        if (toInsert.document != null && document != null && toInsert.document != document) {
            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, null);
        }
        if (toInsert.isParentOf(this)) {
            throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, null);
        }

        if (toInsert.parent != null) {
            int oldIndex = toInsert.index;
            toInsert.parent.children.remove(oldIndex);
            toInsert.parent.refreshIndices(oldIndex);
        }

        children.add(index, toInsert);
        toInsert.parent = this;
        refreshIndices(index);

        return newChild;
    }
854122
private void ensureParentValues(CmsObject cms, String valuePath, Locale locale) {

        if (valuePath.contains("/")) {
            String parentPath = valuePath.substring(0, valuePath.lastIndexOf("/"));
            if (!hasValue(parentPath, locale)) {
                ensureParentValues(cms, parentPath, locale);
                int index = CmsXmlUtils.getXpathIndexInt(parentPath) - 1;
                addValue(cms, parentPath, locale, index);
            }
        }
    }
1059164
private void relink(DOMOutputElement parent, Element element)
    {
        super.relink(parent);
        mParent = parent;
        mElement = element;
        parent.appendNode(element);
        mDefaultNsSet = false;
    }
875584
public Builder link(String href, String textContent) {
       text.a(textContent).a(" : ").a(href);
       tag("a", "href='" + href + "' target='_blank'");
       html.a(textContent);
       return end();
   }
547917
public static Element appendCDATAElement(Element parent, String tagName,
            String value) {
        Element child = appendElement(parent, tagName);
        if (value == null) { // avoid "null" word in the XML payload
            value = "";
        }

        Node cdata = child.getOwnerDocument().createCDATASection(value);
        child.appendChild(cdata);
        return child;
    }