Package net.n3.nanoxml

Examples of net.n3.nanoxml.IXMLReader


    }
   
    @SuppressWarnings("unused")
    private String extractElementValue(IXMLElement parent, String name)
        throws TestSpecificationException {
        IXMLElement elem = name == null ? parent : parent.getFirstChildNamed(name);
        if (elem == null) {
            throw new TestSpecificationException(
                    "Element '" + name + "' not found in '" + parent.getName() + "'");
        } else {
            String res = elem.getContent();
            return (res == null) ? "" : res;
        }
    }
View Full Code Here


            return (res == null) ? "" : res;
        }
    }

    private String extractElementValue(IXMLElement parent, String name, String dflt) {
        IXMLElement elem = name == null ? parent : parent.getFirstChildNamed(name);
        String content = elem == null ? null : elem.getContent();
        return content == null ? dflt : content;
    }
View Full Code Here

  public void load(Reader rdr, ClassLoader cl) throws XMLException
  {
    try
    {
      final IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
      parser.setReader(new StdXMLReader(rdr));
      IXMLElement element = (IXMLElement) parser.parse();
      // Bug 2942351 (Program doesn't launch)
      // looking at the source for StdXMLBuilder, it appears that parser.parse() could possibly return
      // null.  So check for null here and skip if necessary.
      if (element != null)
      {
View Full Code Here

        if (log.isDebugEnabled())
            log.debug(new String(out.toByteArray()));
        // #endif

        try {
            IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
            IXMLReader reader = StdXMLReader.stringReader(new String(out.toByteArray(), "UTF8")); //$NON-NLS-1$
            parser.setReader(reader);
            IXMLElement rootElement = (IXMLElement) parser.parse();

            if (!rootElement.getName().equalsIgnoreCase("multistatus")) //$NON-NLS-1$
                throw new IOException(Messages.getString("MultiStatusResponse.invalidDavRootElement") + rootElement.getName()); //$NON-NLS-1$

            // Now process the responses
View Full Code Here

     XMLElement el = null;
     boolean fileMissing = false;
     try {
       try{
         try {
           IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
           // IXMLReader reader = StdXMLReader.fileReader(file); // fails on pc
           BufferedReader breader = new BufferedReader(new FileReader(file));
           IXMLReader reader = new StdXMLReader(breader);
           parser.setReader(reader);
           el = (XMLElement) parser.parse();
           if (el == null) {
             el = promptToOverwrite(xmlFile, tag);
           } else {
             LogBuffer.println("created xml config from file " + file);
           }
View Full Code Here

        cbuf[0] = (char) ch;
        xmlText = xmlText + new String(cbuf);
        ch = st.read();
      }
IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
Reader breader = new StringReader(xmlText);
IXMLReader reader = new StdXMLReader(breader);
parser.setReader(reader);
el = (XMLElement) parser.parse();
      return el;
    }
View Full Code Here

    private XMLElement loadXML(final File file) throws ConfigureException {
        try {
            final FileReader r = new FileReader(file);
            try {
                StdXMLReader xr = new StdXMLReader(r);
                IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
                parser.setReader(xr);
                return (XMLElement) parser.parse();
            } finally {
                r.close();
            }
        } catch (FileNotFoundException ex) {
            throw new ConfigureException("Cannot open " + file, ex);
View Full Code Here

     * @throws Exception
     */
    public TestSetSpecification parse(TestHarness harness, InputStream in, String base)
        throws Exception {
        StdXMLReader xr = new StdXMLReader(in);
        IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
        parser.setReader(xr);
        TestSetSpecification res;
        IXMLElement root = (IXMLElement) parser.parse();
        if (root.getName().equals("testSpec")) {
            res = new TestSetSpecification("", base);
            res.addTestSpec(parseTestSpecification(root));
        } else if (root.getName().equals("testSet")) {
            String title = extractAttribute(root, "title");
View Full Code Here

    */
   public void parse(InputSource source)
      throws SAXException,
             IOException
   {
      IXMLParser parser = this.createParser();
      parser.setBuilder(this.adapter);
      parser.setResolver(this.entityResolver);
      Reader reader = source.getCharacterStream();

      if (reader != null) {
         parser.setReader(new StdXMLReader(reader));
      } else {
         InputStream stream = source.getByteStream();

         if (stream != null) {
            String encoding = source.getEncoding();

            if (encoding != null) {
               try {
                  reader = new InputStreamReader(stream, encoding);
                  parser.setReader(new StdXMLReader(reader));
               } catch (UnsupportedEncodingException exception) {
                  throw new SAXException(exception);
               }
            } else { // if encoding == null
               parser.setReader(new StdXMLReader(stream));
            }
         } else { // if stream == null
            parser.setReader(new StdXMLReader(source.getPublicId(),
                                              source.getSystemId()));
         }
      }

      try {
         parser.parse();
         this.adapter.endDocument();
      } catch (IOException exception) {
         throw exception;
      } catch (Exception exception) {
         throw new SAXException(exception);
View Full Code Here

    */
   public void parse(String systemId)
      throws SAXException,
             IOException
   {
      IXMLParser parser = this.createParser();
      parser.setBuilder(this.adapter);
      parser.setReader(new StdXMLReader(null, systemId));

      try {
         parser.parse();
         this.adapter.endDocument();
      } catch (IOException exception) {
         throw exception;
      } catch (Exception exception) {
         throw new SAXException(exception);
View Full Code Here

TOP

Related Classes of net.n3.nanoxml.IXMLReader

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.