XMLParser parser = new XMLParser(titleRule); parser.parse(xmlStream);
XMLParser parser = new XMLParser(worker); parser.parse(new ByteArrayInputStream(buildTemplate().getBytes("UTF-8")), Charset.forName("UTF-8"));
XMLWorker worker = new XMLWorker(css, true); XMLParser p = new XMLParser(worker); p.parse(new FileInputStream(HTML), Charset.forName("UTF-8"));
InputStream is = hc.openInputStream(); InputStreamReader isr = new InputStreamReader(is, "utf-8"); XMLParser myParser = new XMLParser(); Element e = myParser.parse(isr); Vector tagVector = e.getChildrenByTagName("TagFromXML"); for(int i = 0; i<tagVector.size();i++){ Element singleTag = (Element) tagVector.elementAt(i); Element child = (Element) (singleTag.getChildrenByTagName("child")).elementAt(0); Element data = (Element) (child.getChildrenByTagName("data")).elementAt(0); System.out.println("DATA: " + data.getChildAt(0).getText()); }
final MyFontFactory fontFactory = new MyFontFactory(); //this sets the custom font factory for everything *but* the XMLWorker //(now that's amazing API design -.- ) FontFactory.setFontImp(fontFactory); //this is the trick to get our fontFactory into the XmlWorker: //build the processing pipeline manually and inject the factory along the way final HtmlPipelineContext htmlContext = new HtmlPipelineContext(new CssAppliersImpl(fontFactory)); final CSSResolver cssResolver = XMLWorkerHelper.getInstance().getDefaultCssResolver(true); final Pipeline<?> pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext, new PdfWriterPipeline(document, writer))); final XMLWorker worker = new XMLWorker(pipeline, true); final XMLParser p = new XMLParser(worker); p.parse(new StringReader(input));
XMLParser parser = new XMLParser(); JSONArray jsonRes = parser.parse(response.getEntity().getContent()); // response is the HTTPResponse object
// CSS CSSResolver cssResolver = new StyleAttrCSSResolver(); CssFile cssFile = XMLWorkerHelper.getCSS(new ByteArrayInputStream(CSS.getBytes())); cssResolver.addCss(cssFile); // HTML HtmlPipelineContext htmlContext = new HtmlPipelineContext(null); htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory()); // Pipelines PdfWriterPipeline pdf = new PdfWriterPipeline(document, writer); HtmlPipeline html = new HtmlPipeline(htmlContext, pdf); CssResolverPipeline css = new CssResolverPipeline(cssResolver, html); // XML Worker XMLWorker worker = new XMLWorker(css, true); XMLParser p = new XMLParser(worker); p.parse(new ByteArrayInputStream(sb.toString().getBytes()));
// CSS CSSResolver cssResolver = XMLWorkerHelper.getInstance().getDefaultCssResolver(true); // HTML HtmlPipelineContext htmlContext = new HtmlPipelineContext(null); htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory()); htmlContext.autoBookmark(false); // Pipelines ElementList elements = new ElementList(); ElementHandlerPipeline end = new ElementHandlerPipeline(elements, null); HtmlPipeline html = new HtmlPipeline(htmlContext, end); CssResolverPipeline css = new CssResolverPipeline(cssResolver, html); // XML Worker XMLWorker worker = new XMLWorker(css, true); XMLParser p = new XMLParser(worker); p.parse(new FileInputStream(HTML));
CSSResolver cssResolver = new StyleAttrCSSResolver(); CssFile cssFile = XMLWorkerHelper.getCSS(new ByteArrayInputStream(CSS.getBytes())); cssResolver.addCss(cssFile); // HTML HtmlPipelineContext htmlContext = new HtmlPipelineContext(null); htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory()); // Pipelines ElementList elements = new ElementList(); ElementHandlerPipeline pdf = new ElementHandlerPipeline(elements, null); HtmlPipeline html = new HtmlPipeline(htmlContext, pdf); CssResolverPipeline css = new CssResolverPipeline(cssResolver, html); // XML Worker XMLWorker worker = new XMLWorker(css, true); XMLParser p = new XMLParser(worker); p.parse(new ByteArrayInputStream(sb.toString().getBytes()));
public ElementList parseHtml(String html, String css) throws IOException { // CSS CSSResolver cssResolver = new StyleAttrCSSResolver(); CssFile cssFile = XMLWorkerHelper.getCSS(new ByteArrayInputStream(css.getBytes())); cssResolver.addCss(cssFile); // HTML CssAppliers cssAppliers = new CssAppliersImpl(FontFactory.getFontImp()); HtmlPipelineContext htmlContext = new HtmlPipelineContext(cssAppliers); htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory()); htmlContext.autoBookmark(false); // Pipelines ElementList elements = new ElementList(); ElementHandlerPipeline end = new ElementHandlerPipeline(elements, null); HtmlPipeline htmlPipeline = new HtmlPipeline(htmlContext, end); CssResolverPipeline cssPipeline = new CssResolverPipeline(cssResolver, htmlPipeline); // XML Worker XMLWorker worker = new XMLWorker(cssPipeline, true); XMLParser p = new XMLParser(worker); p.parse(new ByteArrayInputStream(html.getBytes())); return elements; }
XMLParser p = new XMLParser(); Element e = p.parse(); Vector children = e.getChildren(); Hashtable attributes = e.getAttributes();
public PdfPTable getTable(String cleanHTML) throws IOException { String CSS = "tr { text-align: center; } td { padding: 5px; }"; CSSResolver cssResolver = new StyleAttrCSSResolver(); CssFile cssFile = XMLWorkerHelper.getCSS(new ByteArrayInputStream(CSS.getBytes())); cssResolver.addCss(cssFile); // HTML HtmlPipelineContext htmlContext = new HtmlPipelineContext(null); htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory()); // Pipelines ElementList elements = new ElementList(); ElementHandlerPipeline pdf = new ElementHandlerPipeline(elements, null); HtmlPipeline html = new HtmlPipeline(htmlContext, pdf); CssResolverPipeline css = new CssResolverPipeline(cssResolver, html); // XML Worker XMLWorker worker = new XMLWorker(css, true); XMLParser p = new XMLParser(worker); p.parse(new ByteArrayInputStream(cleanHTML.getBytes())); return (PdfPTable) elements.get(0); }
/** * Parses the descriptor. * * @param input the input * @param preserveComments the preserve comments * @return the XM lizable * @throws InvalidXMLException the invalid XML exception */ public static XMLizable parseDescriptor(XMLInputSource input, boolean preserveComments) throws InvalidXMLException { // turn off environment variable expansion XMLParser.ParsingOptions parsingOptions = new XMLParser.ParsingOptions(false); parsingOptions.preserveComments = preserveComments; XMLParser parser = UIMAFramework.getXMLParser(); // disabled - error messages from XML validation not very helpful // parser.enableSchemaValidation(true); return parser.parse(input, "http://uima.apache.org/resourceSpecifier", urlForResourceSpecifierSchema, parsingOptions); }
/** * Parse a CpeDescription from a descriptor file. * * @param aInput * identifies the input file * * @return The CpeDescription object parsed from the input * * @throws InvalidXMLException * if the descriptor is invalid */ public static CpeDescription produceDescriptor(XMLInputSource aInput) throws InvalidXMLException { Object o; try { o = UIMAFramework.getXMLParser().parse(aInput); if (o instanceof CpeDescription) { return (CpeDescription) o; } } catch (Exception e) { throw new InvalidXMLException(e); } throw new InvalidXMLException(new Exception("Unexpected Object Type Produced By the XMLParser")); }
private static CAS createEmtpyCAS() { XMLInputSource xmlTypeSystemSource = new XMLInputSource( DocumentImportStructureProvider.class.getResourceAsStream("ts.xml"), new File("")); XMLParser xmlParser = UIMAFramework.getXMLParser(); TypeSystemDescription typeSystemDesciptor; try { typeSystemDesciptor = (TypeSystemDescription) xmlParser.parse(xmlTypeSystemSource); } catch (InvalidXMLException e1) { throw new TaeError("Integrated ts.xml typesystem descriptor is not valid!"); } try { return CasCreationUtils.createCas(typeSystemDesciptor, null, null); } catch (ResourceInitializationException e) { // should not happen throw new TaeError("Unexpected exception!"); } }
public static TypeSystemDescription createTypeSystemDescription(InputStream in) { // Note: // Type System location is not set correctly, // resolving a referenced type system will fail XMLInputSource xmlTypeSystemSource = new XMLInputSource(in, new File("")); XMLParser xmlParser = UIMAFramework.getXMLParser(); TypeSystemDescription typeSystemDesciptor; try { typeSystemDesciptor = (TypeSystemDescription) xmlParser .parse(xmlTypeSystemSource); typeSystemDesciptor.resolveImports(); } catch (InvalidXMLException e) { e.printStackTrace(); typeSystemDesciptor = null; } return typeSystemDesciptor; }
public static FlowControllerDescription getDescription() { URL descUrl = FixedFlowController.class .getResource("/org/apache/uima/flow/CapabilityLanguageFlowController.xml"); FlowControllerDescription desc; try { desc = (FlowControllerDescription) UIMAFramework.getXMLParser().parse( new XMLInputSource(descUrl)); } catch (InvalidXMLException e) { throw new UIMARuntimeException(e); } catch (IOException e) { throw new UIMARuntimeException(e); } return desc; }
public static FlowControllerDescription getDescription() { URL descUrl = FixedFlowController797182.class .getResource("/org/apache/uima/flow/FixedFlowController.xml"); FlowControllerDescription desc; try { desc = (FlowControllerDescription) UIMAFramework.getXMLParser().parse( new XMLInputSource(descUrl)); } catch (InvalidXMLException e) { throw new UIMARuntimeException(e); } catch (IOException e) { throw new UIMARuntimeException(e); } return desc; }
public static FlowControllerDescription getDescription() { URL descUrl = FixedFlowController.class .getResource("/org/apache/uima/flow/FixedFlowController.xml"); FlowControllerDescription desc; try { desc = (FlowControllerDescription) UIMAFramework.getXMLParser().parse( new XMLInputSource(descUrl)); } catch (InvalidXMLException e) { throw new UIMARuntimeException(e); } catch (IOException e) { throw new UIMARuntimeException(e); } return desc; }
public class FetchList extends AsyncTask<Void,Void,Byte>{ @Override protected Byte doInBackground1(Void... arg0){ // this was explained in first step Response res = new Response("url"); String response = res.getResponse(); XMLParser xml = new XMLParser(response); ArrayList<XMLParser> itemList = xml.getItemList(); return xml.parse(); } }