예제 #1
0
  private void setNSDeclAsAttr(Attributes atts) {
    Enumeration keys = nsMap.keys();
    if (keys.hasMoreElements()) {
      if (!(atts instanceof AttributesImpl)) {
        atts = new AttributesImpl(atts);
      }
      while (keys.hasMoreElements()) {
        String prefix = (String) keys.nextElement();
        String uri = (String) nsMap.get(prefix);
        if ("".equals(prefix)) {
          int index = atts.getIndex("xmlns");
          if (index == -1) {

            ((AttributesImpl) atts).addAttribute("", "", "xmlns", "CDATA", uri);
          } else {
            ((AttributesImpl) atts).setAttribute(index, "", "", "xmlns", "CDATA", uri);
          }
        } else {
          int index = atts.getIndex("xmlns:" + prefix);
          if (index == -1) {
            ((AttributesImpl) atts).addAttribute("", "", "xmlns:" + prefix, "CDATA", uri);
          } else {
            ((AttributesImpl) atts).setAttribute(index, "", "", "xmlns:" + prefix, "CDATA", uri);
          }
        }
      }
      nsMap.clear();
    }
  }
 /**
  * @see nu.validator.checker.Checker#startElement(java.lang.String, java.lang.String,
  *     java.lang.String, org.xml.sax.Attributes)
  */
 @Override
 public void startElement(String uri, String localName, String name, Attributes atts)
     throws SAXException {
   if ("http://www.w3.org/1999/xhtml" == uri) {
     if ("img" == localName) {
       if (atts.getIndex("", "border") > -1) {
         warn(
             "The \u201Cborder\u201D attribute is obsolete."
                 + " Consider specifying \u201Cimg { border: 0; }\u201D"
                 + " in CSS instead.");
       }
     } else if ("script" == localName) {
       if (AttributeUtil.lowerCaseLiteralEqualsIgnoreAsciiCaseString(
           "javascript", atts.getValue("", "language"))) {
         String type = atts.getValue("", "type");
         if (type == null
             || AttributeUtil.lowerCaseLiteralEqualsIgnoreAsciiCaseString(
                 "text/javascript", type)) {
           warn(
               "The \u201Clanguage\u201D attribute on the"
                   + " \u201Cscript\u201D element is obsolete."
                   + " You can safely omit it.");
         }
       }
     } else if ("a" == localName) {
       if (atts.getIndex("", "name") > -1) {
         warn(
             "The \u201Cname\u201D attribute is obsolete."
                 + " Consider putting an \u201Cid\u201D attribute"
                 + " on the nearest container instead.");
       }
     }
   }
 }
예제 #3
0
  @Override
  public void startElement(String uri, String localName, String name, Attributes attributes)
      throws SAXException {
    if (localName.equalsIgnoreCase(MAP)) {
      if (mRendererInfo != null) {
        if (attributes.getValue(ID).equalsIgnoreCase(mMapId)) {
          mRendererInfo.ID = attributes.getValue(ID);
          mRendererInfo.NAME = attributes.getValue(NAME);
          mRendererInfo.BASEURL = attributes.getValue(BASEURL);
          mRendererInfo.ZOOM_MINLEVEL = Integer.parseInt(attributes.getValue(ZOOM_MINLEVEL));
          mRendererInfo.ZOOM_MAXLEVEL = Integer.parseInt(attributes.getValue(ZOOM_MAXLEVEL));
          mRendererInfo.IMAGE_FILENAMEENDING = attributes.getValue(IMAGE_FILENAMEENDING);
          mRendererInfo.MAPTILE_SIZEPX = Integer.parseInt(attributes.getValue(MAPTILE_SIZEPX));
          mRendererInfo.URL_BUILDER_TYPE = Integer.parseInt(attributes.getValue(URL_BUILDER_TYPE));
          mRendererInfo.TILE_SOURCE_TYPE = Integer.parseInt(attributes.getValue(TILE_SOURCE_TYPE));
          mRendererInfo.PROJECTION = Integer.parseInt(attributes.getValue(PROJECTION));
          mRendererInfo.YANDEX_TRAFFIC_ON =
              Integer.parseInt(attributes.getValue(YANDEX_TRAFFIC_ON));

          mRendererInfo.LAYER = false;
          if (attributes.getIndex(LAYER) > -1)
            mRendererInfo.LAYER = Boolean.parseBoolean(attributes.getValue(LAYER));

          mRendererInfo.CACHE = "";
          if (attributes.getIndex(CACHE) > -1) mRendererInfo.CACHE = attributes.getValue(CACHE);
        }
      } else if (mSubmenu != null) {
        final int i = attributes.getIndex(LAYER);
        if (mSharedPreferences.getBoolean(
                MainPreferences.PREF_PREDEFMAPS_ + attributes.getValue(ID), true)
            && (i == -1 || !attributes.getValue(LAYER).equalsIgnoreCase(TRUE))) {
          final MenuItem item = mSubmenu.add(attributes.getValue(NAME));
          item.setTitleCondensed(attributes.getValue(ID));
        }
      } else if (mPrefMapsgroup != null) {
        final int i = attributes.getIndex(LAYER);
        if (i == -1 || !attributes.getValue(LAYER).equalsIgnoreCase(TRUE)) {
          CheckBoxPreference pref = new CheckBoxPreference(mPrefActivity);
          pref.setKey(MainPreferences.PREF_PREDEFMAPS_ + attributes.getValue(ID));
          pref.setTitle(attributes.getValue(NAME));
          pref.setSummary(attributes.getValue(DESCR));
          // [email protected]  this does set the pref on the pref page to not checked, but
          // cancels out any effect of behavior (they still show up, and checking them changes
          // nothing)
          pref.setDefaultValue(true);
          mPrefMapsgroup.addPreference(pref);
        }
      }
    }
    super.startElement(uri, localName, name, attributes);
  }
예제 #4
0
 @Override
 public void startElement(XMLElement element, Attributes attributes) {
   if (PersistenceTagNames.PROPERTY.equals(element.getQName())) {
     assert (attributes.getLength() == 2);
     assert (attributes.getIndex(PersistenceTagNames.PROPERTY_NAME) != -1);
     assert (attributes.getIndex(PersistenceTagNames.PROPERTY_VALUE) != -1);
     PersistenceUnitDescriptor persistenceUnitDescriptor =
         (PersistenceUnitDescriptor) getDescriptor();
     String propName = attributes.getValue(PersistenceTagNames.PROPERTY_NAME);
     String propValue = attributes.getValue(PersistenceTagNames.PROPERTY_VALUE);
     persistenceUnitDescriptor.addProperty(propName, propValue);
     return;
   }
   super.startElement(element, attributes);
 }
 /** {@inheritDoc} */
 public void startElement(String pUri, String pLocalName, String pQName, Attributes pAtts)
     throws SAXException {
   if (pLocalName.equalsIgnoreCase(TARGET_CONFIGURATION)) {
     targetConfiguration = true;
   } else if (pLocalName.equalsIgnoreCase(LOAD_MODULE)) {
     if (!targetConfiguration) {
       throw new SAXException(
           "\""
               + LOAD_MODULE
               + "\" element needs to be enclosed in \""
               + TARGET_CONFIGURATION
               + "\" element");
     }
     loadModuleEntry = new LoadModuleEntry();
   } else if (pLocalName.equalsIgnoreCase(SOURCE)) {
     if (loadModuleEntry == null) {
       throw new SAXException(
           "\"" + SOURCE + "\" element needs to be enclosed in \"" + LOAD_MODULE + "\" element");
     }
     stringBuffer = new StringBuffer();
   } else if (pLocalName.equalsIgnoreCase(SIGN)) {
     if (loadModuleEntry == null) {
       throw new SAXException(
           "\"" + SIGN + "\" element needs to be enclosed in \"" + LOAD_MODULE + "\" element");
     }
     if (pAtts.getIndex(ATTR_PLATFORM) == -1) {
       throw new SAXException(
           "Attribute \"" + ATTR_PLATFORM + "\" is required in \"" + SIGN + "\" element");
     }
     signEntry = new LoadModuleSignEntry(pAtts.getValue(ATTR_PLATFORM));
   } else if (pLocalName.equalsIgnoreCase(ATTRIBUTE)) {
     if (signEntry == null) {
       throw new SAXException(
           "\"" + ATTRIBUTE + "\" element needs to be enclosed in \"" + SIGN + "\" element");
     }
     if (pAtts.getIndex(ATTR_NAME) == -1) {
       throw new SAXException(
           "Attribute \"" + ATTR_NAME + "\" is required in \"" + ATTRIBUTE + "\" element");
     }
     attributeName = pAtts.getValue(ATTR_NAME);
     stringBuffer = new StringBuffer();
   }
 }
 @Override
 public void startElementFound(String uri, String localName, String qName, Attributes attributes)
     throws NumberFormatException, XMLStreamException {
   super.startElementFound(uri, localName, qName, attributes);
   if (localName.equals("entry")) {
     if (attributes.getIndex("branch_id") == -1) {
       writer.writeAttribute(
           "branch_id",
           String.valueOf(
               branchIdMap.get(Integer.parseInt(attributes.getValue("transaction_id")))));
     }
   }
 }
  @Override
  public void startElement(String uri, String localName, String qName, final Attributes attributes)
      throws SAXException {
    if (qName.equalsIgnoreCase(APP)) {
      final int index = attributes.getIndex(ID);

      if (index != -1) {
        appInfo =
            new AppInfo() {
              {
                setId(attributes.getValue(index));
              }
            };
      }
    }
  }
예제 #8
0
 /*     */ static JaxBeanInfo parseXsiType(
     UnmarshallingContext.State state, TagName ea, @Nullable JaxBeanInfo defaultBeanInfo)
     throws SAXException {
   /*  69 */ UnmarshallingContext context = state.getContext();
   /*  70 */ JaxBeanInfo beanInfo = null;
   /*     */
   /*  73 */ Attributes atts = ea.atts;
   /*  74 */ int idx = atts.getIndex("http://www.w3.org/2001/XMLSchema-instance", "type");
   /*     */
   /*  76 */ if (idx >= 0)
   /*     */ {
     /*  79 */ String value = atts.getValue(idx);
     /*     */
     /*  81 */ QName type = DatatypeConverterImpl._parseQName(value, context);
     /*  82 */ if (type == null) {
       /*  83 */ reportError(Messages.NOT_A_QNAME.format(new Object[] {value}), true);
       /*     */ } else {
       /*  85 */ if ((defaultBeanInfo != null) && (defaultBeanInfo.getTypeNames().contains(type)))
       /*     */ {
         /*  92 */ return defaultBeanInfo;
         /*     */ }
       /*  94 */ beanInfo = context.getJAXBContext().getGlobalType(type);
       /*  95 */ if (beanInfo == null) {
         /*  96 */ String nearest = context.getJAXBContext().getNearestTypeName(type);
         /*  97 */ if (nearest != null)
           /*  98 */ reportError(
               Messages.UNRECOGNIZED_TYPE_NAME_MAYBE.format(new Object[] {type, nearest}), true);
         /*     */ else {
           /* 100 */ reportError(
               Messages.UNRECOGNIZED_TYPE_NAME.format(new Object[] {type}), true);
           /*     */ }
         /*     */
         /*     */ }
       /*     */
       /*     */ }
     /*     */
     /*     */ }
   /*     */
   /* 112 */ return beanInfo;
   /*     */ }
예제 #9
0
  /**
   * 依存先
   *
   * <p>
   *
   * @param namespace 名前空間 URI
   * @param localName ローカル名
   * @param name 修飾名
   * @param attr 属性
   */
  @Override
  public void startElement(String namespace, String localName, String name, Attributes attr) {

    // 名前空間が一致しなければ何もしない
    if (!this.namespaceUri.equals(namespace)) {
      return;
    }

    // ローカル名が一致し href 属性を持つ場合
    if (this.localNames.contains(localName) && attr.getIndex("href") >= 0) {
      String href = attr.getValue("href");
      try {
        URI uri = new URI(href);
        if (!uri.isAbsolute()) {
          uri = baseUri.resolve(uri);
        }
        this.dependUri.add(uri);
      } catch (URISyntaxException ex) {
        logger.finest("unrecognized uri: " + href + "; " + ex);
      }
    }
    return;
  }
 public int getIndex(String uri, String localName) {
   return core.getIndex(uri, localName);
 }
 public int getIndex(String qName) {
   return core.getIndex(qName);
 }