Package org.apache.xerces.util

Examples of org.apache.xerces.util.XMLStringBuffer


        // spaces
        if (!skipSeparator(true, !scanningInternalSubset())) {
            // check for invalid ":"
            if(fNamespaces && fEntityScanner.peekChar() == ':') {
                fEntityScanner.scanChar();
                XMLStringBuffer colonName = new XMLStringBuffer(name);
                colonName.append(":");
                colonName.append(fEntityScanner.scanName());
                reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
                skipSeparator(true, !scanningInternalSubset());
            } else {
                reportFatalError("MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL",
                                new Object[]{name});
            }
View Full Code Here


                return;
            }
            else {
                if(fNamespaces && fEntityScanner.peekChar() == ':') {
                    fEntityScanner.scanChar();
                    XMLStringBuffer colonName = new XMLStringBuffer(target);
                    colonName.append(":");
                    String str = fEntityScanner.scanName();
                    if (str != null)
                        colonName.append(str);
                    reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
                    fEntityScanner.skipSpaces();
                } else {
                    // if there is data there should be some space
                    reportFatalError("SpaceRequiredInPI", null);
                }
View Full Code Here

        }
        // spaces
        if (!skipSeparator(true, !scanningInternalSubset())) {
            if(fNamespaces && fEntityScanner.peekChar() == ':') {
                fEntityScanner.scanChar();
                XMLStringBuffer colonName = new XMLStringBuffer(name);
                colonName.append(":");
                String str = fEntityScanner.scanName();
                if (str != null)
                    colonName.append(str);
                reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
                if (!skipSeparator(true, !scanningInternalSubset())) {
                    reportFatalError("MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL",
                             new Object[]{name});
                }
            } else {
View Full Code Here

       }

   }

  public void testReduceToContent() throws Exception {
    XMLStringBuffer buffer = new XMLStringBuffer("<!-- hello-->");
   
    HTMLScanner.reduceToContent(buffer, "<!--", "-->");
    assertEquals(" hello", buffer.toString());

    buffer = new XMLStringBuffer("  \n <!-- hello-->\n");
    HTMLScanner.reduceToContent(buffer, "<!--", "-->");
    assertEquals(" hello", buffer.toString());

    buffer = new XMLStringBuffer("hello");
    HTMLScanner.reduceToContent(buffer, "<!--", "-->");
    assertEquals("hello", buffer.toString());

    buffer = new XMLStringBuffer("<!-- hello");
    HTMLScanner.reduceToContent(buffer, "<!--", "-->");
    assertEquals("<!-- hello", buffer.toString());

    buffer = new XMLStringBuffer("<!--->");
    HTMLScanner.reduceToContent(buffer, "<!--", "-->");
    assertEquals("<!--->", buffer.toString());
  }
View Full Code Here

         * when feature {@link HTMLScanner#PARSE_NOSCRIPT_CONTENT} is set to false.
         * @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

            }
        }
       
        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

        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

        }
        // spaces
        if (!skipSeparator(true, !scanningInternalSubset())) {
            if(fNamespaces && fEntityScanner.peekChar() == ':') {
                fEntityScanner.scanChar();
                XMLStringBuffer colonName = new XMLStringBuffer(name);
                colonName.append(":");
                String str = fEntityScanner.scanName();
                if (str != null)
                    colonName.append(str);
                reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
                if (!skipSeparator(true, !scanningInternalSubset())) {
                    reportFatalError("MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL",
                             new Object[]{name});
                }
            } else {
View Full Code Here

        // spaces
        if (!skipSeparator(true, !scanningInternalSubset())) {
            // check for invalid ":"
            if(fNamespaces && fEntityScanner.peekChar() == ':') {
                fEntityScanner.scanChar();
                XMLStringBuffer colonName = new XMLStringBuffer(name);
                colonName.append(":");
                colonName.append(fEntityScanner.scanName());
                reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
                skipSeparator(true, !scanningInternalSubset());
            } else {
                reportFatalError("MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL",
                                new Object[]{name});
            }
View Full Code Here

                return;
            }
            else {
                if(fNamespaces && fEntityScanner.peekChar() == ':') {
                    fEntityScanner.scanChar();
                    XMLStringBuffer colonName = new XMLStringBuffer(target);
                    colonName.append(":");
                    String str = fEntityScanner.scanName();
                    if (str != null)
                        colonName.append(str);
                    reportFatalError("ColonNotLegalWithNS", new Object[] {colonName.toString()});
                    fEntityScanner.skipSpaces();
                } else {
                    // if there is data there should be some space
                    reportFatalError("SpaceRequiredInPI", null);
                }
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.