/** * Parses the instance data provided. This method assumes that the XML document is fully * described using XML Schemas. Failure to be fully described as Schemas will result in errors, * as opposed to a vid parse. * * @param desiredDocument * @param hints May be null. * @param level * @return Object * @throws SAXException * @see DocumentFactory#getInstance(URI, Map, Level, boolean) */ public static Object getInstance( URI desiredDocument, @SuppressWarnings("rawtypes") Map hints, Level level) throws SAXException { @SuppressWarnings("unchecked") SAXParser parser = getParser(hints); XMLSAXHandler xmlContentHandler = new XMLSAXHandler(desiredDocument, hints); XMLSAXHandler.setLogLevel(level); try { parser.parse(desiredDocument.toString(), xmlContentHandler); } catch (IOException e) { throw new SAXException(e); } return xmlContentHandler.getDocument(); }
/** * This contructor is intended to create an XMLSAXHandler to be used when parsing an XML * instance document. The instance document's uri is also be provided, as this will allow the * parser to resolve relative uri's. * * @param intendedDocument * @param hints DOCUMENT ME! */ public XMLSAXHandler(URI intendedDocument, Map hints) { instanceDocument = intendedDocument; init(hints); logger.setLevel(level); }
protected void init(Map<String, Object> hints) { if (hints == null) { hints = new HashMap<String, Object>(); } this.hints = hints; setEntityResolver(XMLHandlerHints.toEntityResolver(hints)); } /**
handleCharacters(); logger.fine("END: " + qName); XMLElementHandler handler = null; handler.endElement(uri, localName, hints); } catch (Exception e) { processException(e);
characters.setLength(0); checkStatus(); eh.startElement(new URI(namespaceURI), localName, atts); } catch (Exception e) { processException(e);
/** Handles the string chunks collected in {@link #characters}. */ private void handleCharacters() throws SAXException { if (characters.length() == 0) { return; } try { checkStatus(); String text = characters.toString(); characters.setLength(0); if ((text != null) && !"".equals(text)) { ((XMLElementHandler) handlers.peek()).characters(text); } } catch (SAXException e) { logger.warning(e.toString()); throw e; } }
/** * Parses the instance data provided. This method assumes that the XML document is fully * described using XML Schemas. Failure to be fully described as Schemas will result in errors, * as opposed to a vid parse. * * @param is * @param hints May be null. * @param level * @return Object * @throws SAXException * @see DocumentFactory#getInstance(InputStream, Map, Level, boolean) */ public static Object getInstance(InputStream is, Map<String, Object> hints, Level level) throws SAXException { SAXParser parser = getParser(hints); XMLSAXHandler xmlContentHandler = new XMLSAXHandler(hints); XMLSAXHandler.setLogLevel(level); try { parser.parse(is, xmlContentHandler); } catch (IOException e) { XMLSAXHandler.logger.warning(e.toString()); throw new SAXException(e); } return xmlContentHandler.getDocument(); }
/** * <p> * This contructor is intended to create an XMLSAXHandler to be used when * parsing an XML instance document. The instance document's uri is also * be provided, as this will allow the parser to resolve relative uri's. * </p> * * @param hints Hints as per {@link {@link XMLHandlerHints} */ public XMLSAXHandler(Map<String, Object> hints) { init(hints); logger.setLevel(level); }