/** * @param xml the xml to parse * @param streamer your fully created streamer of the xml * @param <T> the expected type of your parsed XML * @return your parsed XML as an object */ public static <T> T parse(InputStream xml, Streamer<T> streamer) { return parse(xml, streamer, getDefaultSEXPXMLReader()); }
/** * Report the original prefixed names and attributes used for namespace declarations. * * @param allowProcessing enables/disables the processing * @return XMLReaderBuilder * @throws XMLReaderCreationException */ public XMLReaderBuilder allowAttributeNamespaceProcessing(boolean allowProcessing) throws XMLReaderCreationException { withFeature(FEATURE_NAMESPACE_PREFIX, allowProcessing); return this; }
@Override public RootTag getRootTag() { return RootTag.create("novoda"); } }
/** * @param xml the xml to parse * @param instigator your fully created parser of the xml * @param xmlReader is the interface that an XML parser's SAX2 driver must implement , using this? _bad ass_ alert */ public static void parse(InputStream xml, Instigator instigator, XMLReader xmlReader) { RootTag rootTag = instigator.getRootTag(); RootElement rootElement = new RootElement(rootTag.getNamespace(), rootTag.getTag()); rootElement.setEndElementListener(instigator); instigator.create(rootElement); xmlReader.setContentHandler(rootElement.getContentHandler()); XmlParser xmlParser = new XmlParser(); xmlParser.parse(xml, xmlReader); }
@Override public void execute() { ElementFinderFactory factory = SimpleEasyXmlParser.getElementFinderFactory(); elementFinder = factory.getStringWrapperTypeListFinder("name", TeamMember.class); Instigator instigator = new TeamInstigator(elementFinder, finishWatcher); SimpleEasyXmlParser.parse(XML, instigator); }
public void parse(String xml) throws Exception { Instigator instigator = new FeedInstigator( parser, new FeedInstigator.Callback() { @Override public void onFinish(Feed feed) { System.out.println(SexpMediumXmlBenchmark.this.getClass().getSimpleName() + " " + feed); } } ); SimpleEasyXmlParser.parse(xml, instigator); }
public SexpMediumXmlBenchmark() { ElementFinderFactory factory = SimpleEasyXmlParser.getElementFinderFactory(); parser = new FeedParser(factory); }
private static XMLReader getDefaultSEXPXMLReader() { try { return new XMLReaderBuilder().allowNamespaceProcessing(true).build(); } catch (XMLReaderBuilder.XMLReaderCreationException e) { throw new RuntimeException(e); } }
@Override public void create(RootElement rootElement) { streamer.stream(rootElement); }
@Override public RootTag getRootTag() { return streamer.getRootTag(); }
public static RootTag create(String tag, String namespace) { return new RootTag(tag, namespace); }
@Override public RootTag getRootTag() { return RootTag.create("rss"); } }
/** * @param xml the xml to parse * @param instigator your fully created parser of the xml */ public static void parse(InputStream xml, Instigator instigator) { parse(xml, instigator, getDefaultSEXPXMLReader()); }
/** * Perform namespace processing: prefixes will be stripped off element and attribute names and * replaced with the corresponding namespace URIs. By default, the two will simply be concatenated, * but the namespace-sep core property allows the application to specify a delimiter string for * separating the URI part and the local part. * * @param allowProcessing enables/disables the processing * @return XMLReaderBuilder * @throws XMLReaderCreationException */ public XMLReaderBuilder allowNamespaceProcessing(boolean allowProcessing) throws XMLReaderCreationException { withFeature(FEATURE_NAMESPACE, allowProcessing); return this; }
@Override public RootTag getRootTag() { return RootTag.create("novoda"); } }
/** * @param xml the xml to parse * @param encoding the encoding of your xml * @param instigator your fully created parser of the xml * @throws UnsupportedEncodingException if the encoding you passed isn't suppored */ public static void parse(String xml, String encoding, Instigator instigator) throws UnsupportedEncodingException { parse(new ByteArrayInputStream(xml.getBytes(encoding)), instigator, getDefaultSEXPXMLReader()); }
@Override public RootTag getRootTag() { return RootTag.create("employee"); }
@Override public RootTag getRootTag() { return RootTag.create(elementTag); }
@Override public RootTag getRootTag() { return RootTag.create("feed"); }
public static RootTag create(String tag) { return create(tag, UNUSED_NAMESPACE); }