Beispiel #1
0
    /**
     * Get the child elements for the named element.
     *
     * <p>PCData is returned as a "*" list entry.
     *
     * @param elementName Element name.
     * @return List of allowed element names ({@link String}s).
     */
    public List getChildElements(String elementName) {
      Vector childElements = (Vector) elementElements.get(elementName.toLowerCase());

      if (childElements == null) {
        DTDElement element = getElement(elementName);

        if (element != null) {
          childElements = new Vector();
          elementElements.put(elementName.toLowerCase(), childElements);
          if (element.content instanceof DTDContainer) {
            DTDContainer container = (DTDContainer) element.content;
            Vector itemsVec = container.getItemsVec();
            for (int i = 0; i < itemsVec.size(); i++) {
              Object item = itemsVec.elementAt(i);
              if (item instanceof DTDName) {
                childElements.add(((DTDName) item).getValue());
              }
            }
          }
        }
      }

      return childElements;
    }
Beispiel #2
0
  /**
   * Retieves a list containing the DTD elements of a given DTD container.
   *
   * @param container A DTD container.
   * @return A list containing the DTD elements of a given DTD container
   */
  public List<String> getOrderedDtdElements(DTDContainer container) {
    List<String> result = new ArrayList<String>();

    DTDItem[] items = container.getItems();

    for (DTDItem item : items) {
      if (item instanceof DTDContainer) {
        // recursively add container children
        result.addAll(getOrderedDtdElements((DTDContainer) item));
      } else if (item instanceof DTDName) {
        result.add(((DTDName) item).getValue());
      }
    }

    return result;
  }