Package org.apache.xerces.util

Examples of org.apache.xerces.util.XMLStringBuffer


        // time and memory. We should be reading chunks and reporting chunks instead
        // of reading characters individually and reporting all the characters in
        // one callback. Also, currently we don't provide any locator information:
        // line number, column number, etc... so if we report an error it will appear
        // as if the invalid XML character was in the include parent. -- mrglavas
        XMLStringBuffer buffer = new XMLStringBuffer();
        fReader = getReader(fSource);
        int ch;
        while((ch = fReader.read()) != -1) {
            if (isValid(ch)) {
                buffer.append((char)ch);
            }
            else if (XMLChar.isHighSurrogate(ch)) {
              int ch2 = fReader.read();
              if (XMLChar.isLowSurrogate(ch2)) {

                    // convert surrogates to a supplemental character
                    int sup = XMLChar.supplemental((char)ch, (char)ch2);

                    // supplemental character must be a valid XML character
                    if (!isValid(sup)) {
                        fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                                   "InvalidCharInContent",
                                                   new Object[] { Integer.toString(sup, 16) },
                                                   XMLErrorReporter.SEVERITY_FATAL_ERROR);
                        continue;
                    }                
                    buffer.append((char) ch);
                    buffer.append((char) ch2);
                }
                else {
                    fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                               "InvalidCharInContent",
                                               new Object[] { Integer.toString(ch, 16) },
View Full Code Here


        return;
      }
      if ((this.fNamespaces) && (this.fEntityScanner.peekChar() == 58))
      {
        this.fEntityScanner.scanChar();
        XMLStringBuffer localXMLStringBuffer = new XMLStringBuffer(paramString);
        localXMLStringBuffer.append(":");
        String str = this.fEntityScanner.scanName();
        if (str != null)
          localXMLStringBuffer.append(str);
        reportFatalError("ColonNotLegalWithNS", new Object[] { localXMLStringBuffer.toString() });
        this.fEntityScanner.skipSpaces();
      }
      else
      {
        reportFatalError("SpaceRequiredInPI", null);
View Full Code Here

      reportFatalError("MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL", null);
    if (!skipSeparator(true, !scanningInternalSubset()))
      if ((this.fNamespaces) && (this.fEntityScanner.peekChar() == 58))
      {
        this.fEntityScanner.scanChar();
        localObject = new XMLStringBuffer(str1);
        ((XMLStringBuffer)localObject).append(":");
        str2 = this.fEntityScanner.scanName();
        if (str2 != null)
          ((XMLStringBuffer)localObject).append(str2);
        reportFatalError("ColonNotLegalWithNS", new Object[] { ((XMLString)localObject).toString() });
View Full Code Here

      reportFatalError("MSG_NOTATION_NAME_REQUIRED_IN_NOTATIONDECL", null);
    if (!skipSeparator(true, !scanningInternalSubset()))
      if ((this.fNamespaces) && (this.fEntityScanner.peekChar() == 58))
      {
        this.fEntityScanner.scanChar();
        localObject = new XMLStringBuffer(str1);
        ((XMLStringBuffer)localObject).append(":");
        ((XMLStringBuffer)localObject).append(this.fEntityScanner.scanName());
        reportFatalError("ColonNotLegalWithNS", new Object[] { ((XMLString)localObject).toString() });
        skipSeparator(true, !scanningInternalSubset());
      }
View Full Code Here

      protected void scanComment() throws IOException {
         fCurrentEntity.debugBufferIfNeeded("(scanComment: ");
         fEndLineNumber = fCurrentEntity.getLineNumber();
         fEndColumnNumber = fCurrentEntity.getColumnNumber();
         fEndCharacterOffset = fCurrentEntity.getCharacterOffset();
         XMLStringBuffer buffer = new XMLStringBuffer();
         boolean eof = scanMarkupContent(buffer, '-');
         // no --> found, comment with end only with >
         if (eof) {
            fCurrentEntity.resetBuffer(buffer, fEndLineNumber, fEndColumnNumber,
                     fEndCharacterOffset);
            buffer = new XMLStringBuffer(); // take a new one to avoid
                                            // interactions
            while (true) {
               int c = fCurrentEntity.read();
               if (c == -1) {
                  if (fReportErrors) {
                     fErrorReporter.reportError("HTML1007", null);
                  }
                  eof = true;
                  break;
               } else if (c != '>') {
                  buffer.append((char) c);
                  continue;
               } else if (c == '\n' || c == '\r') {
                  fCurrentEntity.rewind();
                  int newlines = skipNewlines();
                  for (int i = 0; i < newlines; i++) {
                     buffer.append('\n');
                  }
                  continue;
               }
               eof = false;
               break;
View Full Code Here

         return (sb == null) ? content : sb.toString();
      }

      private void scanScriptContent() throws IOException {

         final XMLStringBuffer buffer = new XMLStringBuffer();
         boolean waitForEndComment = false;
         while (true) {
            int c = fCurrentEntity.read();
            if (c == -1) {
               break;
            } else if (c == '-' && endsWith(buffer, "<!-")) {
               waitForEndComment = endCommentAvailable();
            } else if (!waitForEndComment && c == '<') {
               final String next = nextContent(8) + " ";
               if (next.length() >= 8 && "/script".equalsIgnoreCase(next.substring(0, 7))
                        && ('>' == next.charAt(7) || Character.isWhitespace(next.charAt(7)))) {
                  fCurrentEntity.rewind();
                  break;
               }
            } else if (c == '>' && endsWith(buffer, "--")) {
               waitForEndComment = false;
            }

            if (c == '\r' || c == '\n') {
               fCurrentEntity.rewind();
               int newlines = skipNewlines();
               for (int i = 0; i < newlines; i++) {
                  buffer.append('\n');
               }
            } else {
               buffer.append((char) c);
            }
         }

         if (fScriptStripCommentDelims) {
            reduceToContent(buffer, "<!--", "-->");
View Full Code Here

       *
       * @param the tag for which content is scanned (one of "noscript", "noframes", "iframe")
       * @throws IOException
       */
      private void scanUntilEndTag(final String tagName) throws IOException {
         final XMLStringBuffer buffer = new XMLStringBuffer();
         final String end = "/" + tagName;
         final int lengthToScan = tagName.length() + 2;

         while (true) {
            int c = fCurrentEntity.read();
            if (c == -1) {
               break;
            }
            if (c == '<') {
               final String next = nextContent(lengthToScan) + " ";
               if (next.length() >= lengthToScan
                        && end.equalsIgnoreCase(next.substring(0, end.length()))
                        && ('>' == next.charAt(lengthToScan - 1) || Character.isWhitespace(next.charAt(lengthToScan - 1)))) {
                  fCurrentEntity.rewind();
                  break;
               }
            }
            if (c == '\r' || c == '\n') {
               fCurrentEntity.rewind();
               int newlines = skipNewlines();
               for (int i = 0; i < newlines; i++) {
                  buffer.append('\n');
               }
            } else {
               buffer.append((char) c);
            }
         }
         if (buffer.length > 0 && fDocumentHandler != null) {
            fEndLineNumber = fCurrentEntity.getLineNumber();
            fEndColumnNumber = fCurrentEntity.getColumnNumber();
View Full Code Here

TOP

Related Classes of org.apache.xerces.util.XMLStringBuffer

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.