Package org.allcolor.xml.parser.dom

Examples of org.allcolor.xml.parser.dom.CAttr


      if (listAttributes.getLength() > 0) {
        result.append(" ");
      } // end if
 
      for (int i=0;i<listAttributes.getLength();i++) {
        CAttr attr = (CAttr) listAttributes.item(i);
        result.append(attr.toString());
 
        if (i < listAttributes.getLength()-1) {
          result.append(" ");
        } // end if
      } // end while
View Full Code Here


      if (elem.listAttributes == null) {
    elem.listAttributes = new CNamedNodeMap(elem);
    elem.listAttributes.list = attributes;
    elem.listAttributes.count = count;
    for (int i = 0; i < count; i++) {
        CAttr attr = attributes[i];
        attr.parentNode = elem;
        attr.ownerDocument = document;
        if (attr.name == "xmlns" || attr.prefix == "xmlns") {
      elem.notifyNSChange(attr.localName);
        }
    }
      } else {
    for (int i = 0; i < count; i++) {
        CAttr attr = attributes[i];
        attr.parentNode = elem;
        attr.ownerDocument = document;
        if (attr.name == "xmlns" || attr.prefix == "xmlns") {
      elem.notifyNSChange(attr.localName);
        }
View Full Code Here

      if (elem.listAttributes == null) {
    elem.listAttributes = new CNamedNodeMap(elem);
    elem.listAttributes.list = attributes;
    elem.listAttributes.count = count;
    for (int i = 0; i < count; i++) {
        CAttr attr = attributes[i];
        attr.parentNode = elem;
        attr.ownerDocument = document;
        if (attr.name == "xmlns" || attr.prefix == "xmlns") {
      elem.notifyNSChange(attr.localName);
        }
    }
      } else {
    for (int i = 0; i < count; i++) {
        CAttr attr = attributes[i];
        attr.parentNode = elem;
        attr.ownerDocument = document;
        if (attr.name == "xmlns" || attr.prefix == "xmlns") {
      elem.notifyNSChange(attr.localName);
        }
View Full Code Here

      if (listAttributes.getLength() > 0) {
        result.append(" ");
      } // end if
 
      for (int i=0;i<listAttributes.getLength();i++) {
        CAttr attr = (CAttr) listAttributes.item(i);
        result.append(attr.toString());
 
        if (i < listAttributes.getLength()-1) {
          result.append(" ");
        } // end if
      } // end while
View Full Code Here

    final String qName, final Attributes atts) throws SAXException {
      if (currentElement.getNodeType() != Node.ENTITY_REFERENCE_NODE) {
    CElement elem = new CElement(qName, document);

    for (int i = 0; i < atts.getLength(); i++) {
        CAttr attr = new CAttr(atts.getQName(i), atts.getValue(i),
          document, currentElement, true);
        if (currentElement.listAttributes == null) {
      currentElement.listAttributes = new CNamedNodeMap(
        currentElement);
        }
View Full Code Here

                    final String name = this.tagcontent
                        .toString();
                    if (attrs == null) {
                      attrs = new CAttr[2];
                    }
                    attrs[count++] = new CAttr(name, name,
                        null, null, true);
                    attrs[count - 1].needToDecode = false;
                    this.parseSTARTTag(tag, attrs, count,
                        indexSep);
                    this.tagcontent.reset();
                    has1stLetter = false;
                    continue;
                  }
                  continue;
                } // end if
                else if (CXmlParser
                    .VALID_XML11_FIRST_LETTERS(n)
                    || (n == '=')) {
                  has1stLetter = false;
                  // attribute found
                  if (n != '=') {
                    this.tagcontent.append(n);
                    while ((ic = this.read()) != -1) {
                      n = (char) ic;
                      if ((n == ' ') || (n == '\r')
                          || (n == '\n')
                          || (n == '\t')
                          || (n == '=') || (n == 160)) {
                        break;
                      } // end if
                      this.tagcontent.append(n);
                    }
                  }
                  // bon on a le nom
                  final String name = this.tagcontent
                      .toString();
                  this.tagcontent.reset();
                  if (ic == -1) {
                    if (attrs == null) {
                      attrs = new CAttr[1];
                    }
                    attrs[count++] = new CAttr(name, name,
                        null, null, true);
                    attrs[count - 1].needToDecode = false;
                    this.parseSTARTTag(tag, attrs, count,
                        indexSep);
                    break;
                  }
                  while ((n == ' ') || (n == '\r')
                      || (n == '\n') || (n == '\t')
                      || (n == 160)) {
                    if ((ic = this.read()) == -1) {
                      break;
                    }
                    n = (char) ic;
                  }
                  if (ic == -1) {
                    break;
                  }
                  if (n == '=') {
                    // go to read value
                    if ((ic = this.read()) == -1) {
                      break;
                    }
                    n = (char) ic;
                    while ((n == ' ') || (n == '\r')
                        || (n == '\n') || (n == '\t')
                        || (n == 160)) {
                      if ((ic = this.read()) == -1) {
                        break;
                      }
                      n = (char) ic;
                    }
                    if (ic == -1) {
                      break;
                    }
                    if (n == '\"') {
                      // read till next "
                      if ((ic = this.read()) == -1) {
                        break;
                      }
                      n = (char) ic;
                      boolean needToDecode = false;
                      if (n == '&') {
                        needToDecode = true;
                      }
                      while (n != '\"') {
                        this.tagcontent.append(n);
                        if ((ic = this.read()) == -1) {
                          break;
                        }
                        n = (char) ic;
                        if (n == '&') {
                          needToDecode = true;
                        }
                      }
                      if (attrs == null) {
                        attrs = new CAttr[2];
                      }
                      if (count == attrs.length) {
                        final CAttr[] nattrs = new CAttr[attrs.length * 2 + 2];
                        System.arraycopy(attrs, 0,
                            nattrs, 0, count);
                        attrs = nattrs;
                      }
                      attrs[count++] = new CAttr(name,
                          this.tagcontent.toString(),
                          null, null, true);
                      if (!needToDecode) {
                        attrs[count - 1].needToDecode = false;
                      }
                      this.tagcontent.reset();
                      continue;
                    } else if (n == '\'') {
                      // read till next '
                      if ((ic = this.read()) == -1) {
                        break;
                      }
                      n = (char) ic;
                      boolean needToDecode = false;
                      if (n == '&') {
                        needToDecode = true;
                      }
                      while (n != '\'') {
                        this.tagcontent.append(n);
                        if ((ic = this.read()) == -1) {
                          break;
                        }
                        n = (char) ic;
                        if (n == '&') {
                          needToDecode = true;
                        }
                      }
                      if (attrs == null) {
                        attrs = new CAttr[2];
                      }
                      if (count == attrs.length) {
                        final CAttr[] nattrs = new CAttr[attrs.length * 2 + 2];
                        System.arraycopy(attrs, 0,
                            nattrs, 0, count);
                        attrs = nattrs;
                      }
                      attrs[count++] = new CAttr(name,
                          this.tagcontent.toString(),
                          null, null, true);
                      if (!needToDecode) {
                        attrs[count - 1].needToDecode = false;
                      }
                      this.tagcontent.reset();
                      continue;
                    } else {
                      this.tagcontent.append(n);
                      boolean needToDecode = false;
                      if (n == '&') {
                        needToDecode = true;
                      }
                      while ((ic = this.read()) != -1) {
                        n = (char) ic;
                        if ((n == ' ') || (n == '\r')
                            || (n == '\n')
                            || (n == '\t')
                            || (n == '>')
                            || (n == 160)) {
                          break;
                        }
                        this.tagcontent.append(n);
                        if (n == '&') {
                          needToDecode = true;
                        }
                      }
                      if (attrs == null) {
                        attrs = new CAttr[2];
                      }
                      if (count == attrs.length) {
                        final CAttr[] nattrs = new CAttr[attrs.length * 2 + 2];
                        System.arraycopy(attrs, 0,
                            nattrs, 0, count);
                        attrs = nattrs;
                      }
                      attrs[count++] = new CAttr(name,
                          this.tagcontent.toString(),
                          null, null, true);
                      if (!needToDecode) {
                        attrs[count - 1].needToDecode = false;
                      }
                      this.tagcontent.reset();
                      if (n == '>') {
                        break;
                      }
                      continue;
                    }
                  } else if (n == '/') {
                    if (attrs == null) {
                      attrs = new CAttr[1];
                    }
                    if (count == attrs.length) {
                      final CAttr[] nattrs = new CAttr[attrs.length * 2 + 2];
                      System.arraycopy(attrs, 0, nattrs,
                          0, count);
                      attrs = nattrs;
                    }
                    attrs[count++] = new CAttr(name, name,
                        null, null, true);
                    attrs[count - 1].needToDecode = false;
                    this.parseEMPTYTag(tag, attrs, count,
                        indexSep);
                    ic = this.read();
                    break;
                  } else if (n == '<') {
                    // struct.hasprev = true;
                    this.iprev = n;
                    break;
                  } else {
                    if (attrs == null) {
                      attrs = new CAttr[2];
                    }
                    if (count == attrs.length) {
                      final CAttr[] nattrs = new CAttr[attrs.length * 2 + 2];
                      System.arraycopy(attrs, 0, nattrs,
                          0, count);
                      attrs = nattrs;
                    }
                    attrs[count++] = new CAttr(name, name,
                        null, null, true);
                    // struct.hasprev = true;
                    this.iprev = n;
                    continue;
                  }
View Full Code Here

    if (attributes != null) {
      String sLevel = new CStringBuilder().append('$').append(this.level)
          .toString();

      for (int i = 0; i < count; i++) {
        CAttr attr = attributes[i];
        String attName = attr.name;

        if ((attName.length() >= 5) && (attName.charAt(0) == 'x')
            && (attName.charAt(1) == 'm')
            && (attName.charAt(2) == 'l')
            && (attName.charAt(3) == 'n')
            && (attName.charAt(4) == 's')) {
          String value = attr.deferredValue;
          String prefix = (attName.length() > 5) ? attName
              .substring(6) : "";
          CNamespace ns = new CNamespace(prefix, value);

          if (this.cHandler != null) {
            try {
              this.cHandler.startPrefixMapping(ns.getPrefix(), ns
                  .getNamespaceURI());
            }
            catch (SAXException e){}
          } // end if

          if (this.level > this.maxLevel) {
            this.maxLevel = this.level;
          }

          this.nsMap.put(new CStringBuilder().append(ns.getPrefix())
              .append(sLevel).toString(), ns);
        } // end if
      } // end for
    } // end if

    CNamespace ns = null;

    if (prefixTag != null) {
      int i = (this.maxLevel < this.level) ? this.maxLevel : this.level;
      prefixTag = new CStringBuilder().append(prefixTag).append('$')
          .toString();

      while ((i > 0) && (ns == null)) {
        ns = (CNamespace) this.nsMap.get(new CStringBuilder().append(
            prefixTag).append(i).toString());
        i--;
      } // end while
    } // end if
    else {
      int i = (this.maxLevel < this.level) ? this.maxLevel : this.level;

      while ((i > 0) && (ns == null)) {
        ns = (CNamespace) this.nsMap.get(new CStringBuilder().append(
            '$').append(i).toString());
        i--;
      } // end while
    } // end else

    if (attributes != null) {
      for (int li = 0; li < count; li++) {
        CAttr attr = attributes[li];
        String attName = attr.name;
        String value = attr.deferredValue;

        if (value == null) {
          value = "";
View Full Code Here

 
  protected final void setAttributeAsDefault(
      final String name,
      final String value)
      throws DOMException {
      CAttr attr = new CAttr(name, value, ownerDocument,this, false);
      attr.setDefaults(true);
      setAttributeNode(attr);
      if ("xmlns".equals(attr.getPrefix()) ||
        "xmlns".equals(name)) {
        ((ANode)attr).notifyNSChange(attr.getLocalName());
      }
    } // end setAttribute()
View Full Code Here

   */
  public final void setAttribute(
    final String name,
    final String value)
    throws DOMException {
    CAttr attr = new CAttr(name, value, ownerDocument,this, true);
    if (!ownerDocument.isBuildStage && !"xmlns".equals(name)) attr.dom1Nullify();
    setAttributeNode(attr);
  } // end setAttribute()
View Full Code Here

        } // end if
      } // end for

      if (ns != null && ns.getPrefix() == null) {
        if (ns.getNamespaceURI().trim().length() > 0)
          return new CAttr("xmlns", ns.getNamespaceURI(),
            ownerDocument,this,hasAttribute(name));
      } // end if
    } // end if
    return attr;
  } // end getAttributeNode()
View Full Code Here

TOP

Related Classes of org.allcolor.xml.parser.dom.CAttr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.