⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nonvalidator.java

📁 Nano的XML解析器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
         XMLUtil.skipTag(reader);         return;      }      XMLUtil.skipWhitespace(reader, null);      String str = XMLUtil.read(reader, '%');      char ch = str.charAt(0);      if (ch != '[') {         XMLUtil.skipTag(reader);         return;      }      Reader subreader = new CDATAReader(reader);      subreader.close();   }   /**    * Processes an ATTLIST element.    *    * @param reader         the reader to read data from.    * @param entityResolver the entity resolver.    *    * @throws java.lang.Exception    *     If something went wrong.    */   protected void processAttList(IXMLReader         reader,                                 IXMLEntityResolver entityResolver)      throws Exception   {      if (! XMLUtil.checkLiteral(reader,  "TTLIST")) {         XMLUtil.skipTag(reader);         return;      }      XMLUtil.skipWhitespace(reader, null);      String str = XMLUtil.read(reader, '%');      char ch = str.charAt(0);      while (ch == '%') {         XMLUtil.processEntity(str, reader,                               this.parameterEntityResolver);         str = XMLUtil.read(reader, '%');         ch = str.charAt(0);      }      reader.unread(ch);      String elementName = XMLUtil.scanIdentifier(reader);      XMLUtil.skipWhitespace(reader, null);            str = XMLUtil.read(reader, '%');      ch = str.charAt(0);      while (ch == '%') {         XMLUtil.processEntity(str, reader,                               this.parameterEntityResolver);         str = XMLUtil.read(reader, '%');         ch = str.charAt(0);      }      Properties props = new Properties();      while (ch != '>') {         reader.unread(ch);         String attName = XMLUtil.scanIdentifier(reader);         XMLUtil.skipWhitespace(reader, null);         ch = XMLUtil.readChar(reader, '%');         if (ch == '(') {            while (ch != ')') {               ch = XMLUtil.readChar(reader, '%');            }         } else {            reader.unread(ch);            XMLUtil.scanIdentifier(reader);         }         XMLUtil.skipWhitespace(reader, null);         ch = XMLUtil.readChar(reader, '%');         if (ch == '#') {            str = XMLUtil.scanIdentifier(reader);            XMLUtil.skipWhitespace(reader, null);            if (! str.equals("FIXED")) {               XMLUtil.skipWhitespace(reader, null);               str = XMLUtil.read(reader, '%');               ch = str.charAt(0);               while (ch == '%') {                  XMLUtil.processEntity(str, reader,                                        this.parameterEntityResolver);                  str = XMLUtil.read(reader, '%');                  ch = str.charAt(0);               }               continue;            }         } else {            reader.unread(ch);         }         String value = XMLUtil.scanString(reader, '%',                                           this.parameterEntityResolver);         props.put(attName, value);         XMLUtil.skipWhitespace(reader, null);         str = XMLUtil.read(reader, '%');         ch = str.charAt(0);         while (ch == '%') {            XMLUtil.processEntity(str, reader,                                  this.parameterEntityResolver);            str = XMLUtil.read(reader, '%');            ch = str.charAt(0);         }      }      if (! props.isEmpty()) {         this.attributeDefaultValues.put(elementName, props);      }   }   /**    * Processes an ENTITY element.    *    * @param reader         the reader to read data from.    * @param entityResolver the entity resolver.    *    * @throws java.lang.Exception    *     If something went wrong.    */   protected void processEntity(IXMLReader         reader,                                IXMLEntityResolver entityResolver)      throws Exception   {      if (! XMLUtil.checkLiteral(reader, "NTITY")) {         XMLUtil.skipTag(reader);         return;      }      XMLUtil.skipWhitespace(reader, null);      char ch = XMLUtil.readChar(reader, '\0');      if (ch == '%') {         XMLUtil.skipWhitespace(reader, null);         entityResolver = this.parameterEntityResolver;      } else {         reader.unread(ch);      }      String key = XMLUtil.scanIdentifier(reader);      XMLUtil.skipWhitespace(reader, null);      ch = XMLUtil.readChar(reader, '%');      String systemID = null;      String publicID = null;      switch (ch) {         case 'P':            if (! XMLUtil.checkLiteral(reader, "UBLIC")) {               XMLUtil.skipTag(reader);               return;            }            XMLUtil.skipWhitespace(reader, null);            publicID = XMLUtil.scanString(reader, '%',                                          this.parameterEntityResolver);            XMLUtil.skipWhitespace(reader, null);            systemID = XMLUtil.scanString(reader, '%',                                          this.parameterEntityResolver);            XMLUtil.skipWhitespace(reader, null);            XMLUtil.readChar(reader, '%');            break;         case 'S':            if (! XMLUtil.checkLiteral(reader, "YSTEM")) {               XMLUtil.skipTag(reader);               return;            }            XMLUtil.skipWhitespace(reader, null);            systemID = XMLUtil.scanString(reader, '%',                                          this.parameterEntityResolver);            XMLUtil.skipWhitespace(reader, null);            XMLUtil.readChar(reader, '%');            break;         case '"':         case '\'':            reader.unread(ch);            String value = XMLUtil.scanString(reader, '%',                                              this.parameterEntityResolver);            entityResolver.addInternalEntity(key, value);            XMLUtil.skipWhitespace(reader, null);            XMLUtil.readChar(reader, '%');            break;         default:            XMLUtil.skipTag(reader);      }      if (systemID != null) {         entityResolver.addExternalEntity(key, publicID, systemID);      }   }   /**    * Indicates that an element has been started.    *    * @param name       the name of the element.    * @param systemId   the system ID of the XML data of the element.    * @param lineNr     the line number in the XML data of the element.    */   public void elementStarted(String name,                              String systemId,                              int    lineNr)   {      Properties attribs         = (Properties) this.attributeDefaultValues.get(name);      if (attribs == null) {         attribs = new Properties();      } else {         attribs = (Properties) attribs.clone();      }      this.currentElements.push(attribs);   }   /**    * Indicates that the current element has ended.    *    * @param name       the name of the element.    * @param systemId   the system ID of the XML data of the element.    * @param lineNr     the line number in the XML data of the element.    */   public void elementEnded(String name,                            String systemId,                            int    lineNr)   {      // nothing to do   }   /**    * This method is called when the attributes of an XML element have been    * processed.    * If there are attributes with a default value which have not been    * specified yet, they have to be put into <I>extraAttributes</I>.    *    * @param name            the name of the element.    * @param extraAttributes where to put extra attributes.    * @param systemId        the system ID of the XML data of the element.    * @param lineNr          the line number in the XML data of the element.    */   public void elementAttributesProcessed(String     name,                                          Properties extraAttributes,                                          String     systemId,                                          int        lineNr)   {      Properties props = (Properties) this.currentElements.pop();      Enumeration enum = props.keys();      while (enum.hasMoreElements()) {         String key = (String) enum.nextElement();         extraAttributes.put(key, props.get(key));      }   }   /**    * Indicates that an attribute has been added to the current element.    *    * @param key        the name of the attribute.    * @param value      the value of the attribute.    * @param systemId   the system ID of the XML data of the element.    * @param lineNr     the line number in the XML data of the element.    */   public void attributeAdded(String key,                              String value,                              String systemId,                              int    lineNr)   {      Properties props = (Properties) this.currentElements.peek();      if (props.containsKey(key)) {         props.remove(key);      }   }   /**    * Indicates that a new #PCDATA element has been encountered.    *    * @param systemId the system ID of the XML data of the element.    * @param lineNr   the line number in the XML data of the element.    */   public void PCDataAdded(String systemId,                           int    lineNr)   {      // nothing to do   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -