Exemplo n.º 1
0
 /**
  * Returns the the JDOM Attribute type value from the SAX 2.0 attribute type string provided by
  * the parser.
  *
  * @param typeName <code>String</code> the SAX 2.0 attribute type string.
  * @return <code>int</code> the JDOM attribute type.
  * @see Attribute#setAttributeType
  * @see Attributes#getType
  */
 private static int getAttributeType(String typeName) {
   Integer type = (Integer) (attrNameToTypeMap.get(typeName));
   if (type == null) {
     if (typeName != null && typeName.length() > 0 && typeName.charAt(0) == '(') {
       // Xerces 1.4.X reports attributes of enumerated type with
       // a type string equals to the enumeration definition, i.e.
       // starting with a parenthesis.
       return Attribute.ENUMERATED_TYPE;
     } else {
       return Attribute.UNDECLARED_TYPE;
     }
   } else {
     return type.intValue();
   }
 }
Exemplo n.º 2
0
  public void startEntity(String name) throws SAXException {
    entityDepth++;

    if (expand || entityDepth > 1) {
      // Short cut out if we're expanding or if we're nested
      return;
    }

    // A "[dtd]" entity indicates the beginning of the external subset
    if (name.equals("[dtd]")) {
      inInternalSubset = false;
      return;
    }

    // Ignore DTD references, and translate the standard 5
    if ((!inDTD)
        && (!name.equals("amp"))
        && (!name.equals("lt"))
        && (!name.equals("gt"))
        && (!name.equals("apos"))
        && (!name.equals("quot"))) {

      if (!expand) {
        String pub = null;
        String sys = null;
        String[] ids = (String[]) externalEntities.get(name);
        if (ids != null) {
          pub = ids[0]; // may be null, that's OK
          sys = ids[1]; // may be null, that's OK
        }
        /**
         * if no current element, this entity belongs to an attribute in these cases, it is an error
         * on the part of the parser to call startEntity but this will help in some cases. See
         * org/xml/sax/ext/LexicalHandler.html#startEntity(java.lang.String) for more information
         */
        if (!atRoot) {
          flushCharacters();
          EntityRef entity = factory.entityRef(name, pub, sys);

          // no way to tell if the entity was from an attribute or element so just assume element
          factory.addContent(getCurrentElement(), entity);
        }
        suppress = true;
      }
    }
  }
Exemplo n.º 3
0
 public MissionInfo getMission(String name) {
   return data.get(name);
 }