Esempio n. 1
0
  /**
   * Process the current node in the default manner, expanding entities in its attributes and
   * processing its children re-entrantly.
   */
  public final void expandCurrentNode() {
    ActiveNode node = input.getActive();
    if (node == null) return;

    // Crock for PI comments:
    if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE && node.getNodeName().equals("--"))
      return;

    // No need to check for an entity; active ones use EntityHandler.
    if (input.hasActiveAttributes()) {
      ActiveElement oe = node.asElement();
      ActiveElement e = oe.editedCopy(expandAttrs(oe.getAttrList()), null);
      output.startNode(e);
      if (input.hasChildren()) {
        processChildren();
      }
      output.endElement(e.isEmptyElement() || e.implicitEnd());
    } else if (input.hasChildren()) {
      output.startNode(node);
      if (input.hasChildren()) processChildren();
      output.endNode();
    } else {
      output.putNode(node);
    }
  }
Esempio n. 2
0
 /**
  * Look up a name and return its value.
  *
  * @param name the name to look up
  * @return the list of nodes associated with the name. If the binding is an Element (the typical
  *     case) its children are returned.
  */
 public ActiveNodeList getValueNodes(Context c, String name) {
   ActiveNode binding = getBinding(name);
   if (binding == null) {
     binding = getActiveAttr(name);
   }
   if (binding == null) return null;
   else if (binding instanceof Namespace) {
     return new TreeNodeList(((Namespace) binding).getBindings());
   } else {
     return binding.getValueNodes(c);
   }
 }
Esempio n. 3
0
 public void expandNodes(ActiveNodeList nl, Output dst) {
   int len = nl.getLength();
   for (int i = 0; i < len; ++i) {
     ActiveNode n = nl.activeItem(i);
     if (n.getNodeType() == Node.ENTITY_NODE) {
       expandEntity((ActiveEntity) n, dst);
     } else if (n.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
       expandEntityRef((EntityReference) n, dst);
     } else {
       dst.putNode(n);
     }
   }
 }
Esempio n. 4
0
 /**
  * Process the current node by expanding entities in its attributes, but blindly copying its
  * children (content).
  */
 public final void expandCurrentAttrs() {
   ActiveNode node = input.getActive();
   if (input.hasActiveAttributes()) {
     ActiveElement oe = node.asElement();
     ActiveElement e = new TreeElement(oe, expandAttrs(oe.getAttrList()));
     output.startNode(e);
     if (input.hasChildren()) {
       copyChildren();
     }
     output.endElement(e.isEmptyElement() || e.implicitEnd());
   } else if (input.hasChildren() && !node.hasChildNodes()) {
     copyCurrentNode(node);
   } else {
     output.putNode(node);
   }
 }