Ejemplo n.º 1
0
  /**
   * Method for adding specified element as a child of this container.
   *
   * @param ns Namespace for the element (may be null if element is not to belong to a namespace)
   * @param localName Local name part of the element name; may not be null or empty
   */
  public SMOutputElement addElement(SMNamespace ns, String localName) throws XMLStreamException {
    final SMOutputContext ctxt = _context;

    /* First, need to make sure namespace declaration is appropriate
     * for this context
     */
    ns = _verifyNamespaceArg(ns);

    // Ok, let's see if we are blocked already
    boolean blocked = !_canOutputNewChild();
    SMOutputElement newElem = new SMOutputElement(ctxt, localName, ns);
    _linkNewChild(newElem);
    newElem.linkParent(this, blocked);

    return newElem;
  }
Ejemplo n.º 2
0
 /**
  * Convenience method for adding a child element (that has no attributes) to this container, and
  * adding specified text as child of that child element. This is functionally equivalent to
  * calling:
  *
  * <pre>
  *   container.addElement(ns, localName).addCharacters(text);
  * </pre>
  *
  * <p>Note: no attributes can be added to the returned child element, because textual content has
  * already been added.
  *
  * @since 2.0
  */
 public SMOutputElement addElementWithCharacters(SMNamespace ns, String localName, String text)
     throws XMLStreamException {
   SMOutputElement child = addElement(ns, localName);
   child.addCharacters(text);
   return child;
 }