示例#1
0
  @Override
  protected void finishOpen() throws IOException {
    try {
      final AttributesImpl attrs = new AttributesImpl();
      final int as = attributes.size();
      for (int a = 0; a < as; a++) {
        final byte[] name = attributes.name(a);
        final String uri = string(namespaces.get(prefix(name)));
        final String lname = string(local(name));
        final String rname = string(name);
        final String value = string(attributes.value(a));
        attrs.addAttribute(uri, lname, rname, null, value);
      }

      final String uri = string(namespaces.get(elem.prefix()));
      final String lname = string(elem.local());
      final String rname = string(elem.string());
      contentHandler.startElement(uri, lname, rname, attrs);

    } catch (final SAXException ex) {
      throw new IOException(ex);
    }
  }
示例#2
0
  @Override
  protected void attribute(final byte[] name, final byte[] value, final boolean standalone) {
    byte[] prefix = null;
    if (startsWith(name, XMLNS)) {
      if (name.length == 5) {
        prefix = EMPTY;
      } else if (name[5] == ':') {
        prefix = substring(name, 6);
      }
    }

    if (prefix != null) {
      namespaces.put(prefix, value);
    } else {
      attributes.add(name, value);
    }
  }
示例#3
0
 /**
  * Stores a new prefix and namespace.
  *
  * @param prefix prefix
  * @param uri namespace uri
  */
 private void put(final byte[] prefix, final byte[] uri) {
   if (decls == null) decls = new Atts();
   decls.add(prefix, uri);
 }
示例#4
0
 @Override
 protected void startOpen(final QNm name) {
   namespaces = new NSDecl(namespaces);
   attributes.clear();
 }