Refine search
try SAXBuilder builder = new SAXBuilder( false ); builder.setExpandEntities( false ); if ( ignoreDtd ) builder.setEntityResolver( new EntityResolver() throw new RuntimeException( "Error processing resource " + resource + ": " + e.getMessage(), e ); appendElement( r.getRootElement(), doc.getRootElement() ); Object source = path.selectSingleNode( r.getRootElement() ); if ( !( source instanceof Element ) )
throw new JDOMException("JDOM requires that XMLStreamReaders " + "are at their beginning when being processed."); document.setBaseURI(event.getLocation().getSystemId()); document.setProperty("ENCODING_SCHEME", ((javax.xml.stream.events.StartDocument)event).getCharacterEncodingScheme()); document.setProperty("STANDALONE", String.valueOf( ((javax.xml.stream.events.StartDocument)event).isStandalone())); final DocType dt = document.getDocType(); if (dt != null) { dt.setElementName(emt.getName()); current.addContent(emt); final Characters chars = event.asCharacters(); if (chars.isCData()) { current.addContent(factory.cdata( ((Characters)event).getData())); } else { throw new JDOMException("Unable to process XMLStream. See Cause.", xse);
try { errorHandler.error(new SAXParseException( exception.getMessage(), null, exception)); throw (JDOMException)(se.getException()); throw new JDOMException(se.getMessage(), se);
private Element readContentFromURL(java.net.URI uri) throws java.io.IOException { if (saxBuilder == null) saxBuilder = new SAXBuilder(); Document doc; try { doc = saxBuilder.build(uri.toURL()); } catch (JDOMException e) { throw new IOException(e.getMessage()); } return doc.getRootElement(); }
public TableConfig readConfigXML(String fileLocation, FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) throws IOException { org.jdom2.Document doc; try { SAXBuilder builder = new SAXBuilder(false); if (debugURL) System.out.println(" PointConfig URL = <" + fileLocation + ">"); doc = builder.build(fileLocation); } catch (JDOMException e) { throw new IOException(e.getMessage()); } if (debugXML) System.out.println(" SAXBuilder done"); if (showParsedXML) { XMLOutputter xmlOut = new XMLOutputter(); System.out.println("*** PointConfig/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******"); } Element configElem = doc.getRootElement(); String featureType = configElem.getAttributeValue("featureType"); Element tableElem = configElem.getChild("table"); TableConfig tc = parseTableConfig(ds, tableElem, null); tc.featureType = FeatureType.valueOf(featureType); return tc; }
private InputStream convert2XmlDecoder(InputStream is) throws IOException { org.jdom2.Document doc; try { SAXBuilder builder = new SAXBuilder(false); doc = builder.build(is); } catch (JDOMException e) { throw new IOException(e.getMessage()); } finally { if (is != null) is.close(); } if (debugConvert) { XMLOutputter xmlOut = new XMLOutputter(); System.out.println("***XMLStore.convert2XmlDecoder = \n" + xmlOut.outputString(doc) + "\n*******"); } Element root = doc.getRootElement(); org.jdom2.Document convertDoc = new Document(); Element convertRoot = new Element("java"); convertRoot.setAttribute("version", "1.4.1_01"); convertRoot.setAttribute("class", "java.beans.XMLDecoder"); convertDoc.setRootElement(convertRoot); add(root, convertRoot); XMLOutputter xmlOut = new XMLOutputter(); xmlOut.setFormat(Format.getPrettyFormat()); if (debugConvert) { System.out.printf("%n************************************%n"); System.out.println("***Convert2Version2 converted = \n" + xmlOut.outputString(convertDoc) + "\n*******"); } return new StringBufferInputStream(xmlOut.outputString(convertDoc)); }
private List<UrlRemapperBean> readUrlRemapFile(String path) { java.util.List<UrlRemapperBean> beans = new ArrayList<>(1000); ClassLoader cl = this.getClass().getClassLoader(); try (InputStream is = cl.getResourceAsStream(path)) { if (is == null) { System.out.println("Cant read file " + path); return null; } SAXBuilder builder = new SAXBuilder(); org.jdom2.Document doc = builder.build(is); org.jdom2.Element root = doc.getRootElement(); List<org.jdom2.Element> dsElems = root.getChildren("urlMap"); for (org.jdom2.Element dsElem : dsElems) { String dsType = dsElem.getAttributeValue("type"); List<org.jdom2.Element> params = dsElem.getChildren("urlPath"); for (org.jdom2.Element elem : params) { String oldUrlPath = elem.getAttributeValue("oldUrlPath"); String newUrlPath = elem.getAttributeValue("newUrlPath"); beans.add(new UrlRemapperBean(dsType,oldUrlPath,newUrlPath)); } } return beans; } catch (IOException ioe) { ioe.printStackTrace(); return null; } catch (JDOMException e) { e.printStackTrace(); return null; } }
/** * Parses the counter metadata file * @param metadata an <code>InputStream</code> for the counter metadata XML file * @throws org.jdom2.JDOMException */ public void parseCounterMetadataFile(InputStream metadata) throws JDOMException { SAXBuilder parser = new SAXBuilder(); try { // the root element will be the counter metadata element Document doc = parser.build(metadata); Element root = doc.getRootElement(); // read the counters if(root.getName().equals(counterMetadataElement)) { parseCounters(root); } } catch (IOException e) { e.printStackTrace(System.err); throw new JDOMException("Error reading the counter metadata", e); } }
this.spotQuality = spotQuality; this.edgeWeigth = edgeWeight; final SAXBuilder sb = new SAXBuilder(); Element r = null; try final Document document = sb.build( file ); r = document.getRootElement(); logger.error( "Problem parsing " + file.getName() + ", it is not a valid ICY tracks XML file.\nError message is:\n" + e.getLocalizedMessage() + '\n' ); if ( !root.getName().equals( "root" ) || root.getChild( "trackfile" ) == null )
SAXBuilder parser = new SAXBuilder(); Document doc = parser.build(metadata); org.jdom2.Element root = doc.getRootElement(); if(root.getName().equals(boardsFileElement)) { for(org.jdom2.Element e: root.getChildren()) { if(e.getName().equals(coreboardElement)){ for(org.jdom2.Element f: e.getChildren()) { if(f.getName().equals(boarddataType)) { throw new JDOMException("Error reading the v5boardVersions.xml metadata", e);
paramsMap = new HashMap<>(); SAXBuilder builder = new SAXBuilder(); try { Document doc = builder.build(inputStream); Element root = doc.getRootElement(); List<Element> list = root.getChildren(); Iterator<Element> it = list.iterator(); while (it.hasNext()) { Element e = (Element) it.next(); String k = e.getName(); Object v = EcSymbol.EMPTY; List<Element> children = e.getChildren(); if (children.isEmpty()) { v = e.getTextNormalize(); e.printStackTrace(); throw new RuntimeException(e);
String pluginListXml = IOUtils.toString(url); SAXBuilder builder = new SAXBuilder(); Document document = builder.build(new StringReader(pluginListXml)); List<Element> pluginList = document.getRootElement().getChildren("plugin"); update.setPluginId(element.getAttributeValue("id")); update.setVersion(element.getAttributeValue("version")); System.out.printf("Failed to parse plugin list from %s (%s)\n", url, e.getLocalizedMessage());
private boolean readParameterTableFromResource(String resource) { if (debugOpen) System.out.printf("readParameterTableFromResource from resource %s%n", resource); ClassLoader cl = this.getClass().getClassLoader(); try (InputStream is = cl.getResourceAsStream(resource)) { if (is == null) { log.info("Cant read resource " + resource); return false; } SAXBuilder builder = new SAXBuilder(); org.jdom2.Document doc = builder.build(is); Element root = doc.getRootElement(); paramMap = parseXml(root); // all at once - thread safe return true; } catch (IOException ioe) { ioe.printStackTrace(); return false; } catch (JDOMException e) { e.printStackTrace(); return false; } }
/** * Initialize this reader to read the file given in argument. */ public TmXmlReader( final File file ) { this.file = file; final SAXBuilder sb = new SAXBuilder(); Element r = null; try { document = sb.build( file ); r = document.getRootElement(); } catch ( final JDOMException e ) { ok = false; logger.error( "Problem parsing " + file.getName() + ", it is not a valid TrackMate XML file.\nError message is:\n" + e.getLocalizedMessage() + '\n' ); } catch ( final IOException e ) { logger.error( "Problem reading " + file.getName() + ".\nError message is:\n" + e.getLocalizedMessage() + '\n' ); ok = false; } this.root = r; }
ModInfo modInfo = new ModInfo(); String modTitle = root.getChildTextTrim( "title" ); if ( modTitle != null && modTitle.length() > 0 ) modInfo.setTitle( modTitle ); else throw new JDOMException( "Missing title." ); String modURL = root.getChildTextTrim( "threadUrl" ); if ( modURL != null && modURL.length() > 0 ) modInfo.setURL( modURL ); else throw new JDOMException( "Missing threadUrl." ); String modAuthor = root.getChildTextTrim( "author" ); if ( modAuthor != null && modAuthor.length() > 0 ) modInfo.setAuthor( modAuthor ); else throw new JDOMException( "Missing author." ); modInfo.setVersion( modVersion ); else throw new JDOMException( "Missing version." ); modInfo.setDescription( modDesc ); else throw new JDOMException( "Missing description." );
String error = "XML failed validation: " + jde.getMessage(); throw new ReaderException(error, jde); Element root = document.getRootElement(); String groupElemName = root.getName();
@Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); for (final Element call : selectNodesByName("CALL.")) { // If the call isn't a call to the mod routine then skip it if (!getCclName(call).equalsIgnoreCase("MOD")) continue; if (call.getChildren().size() != 3) throw new JDOMException("Unhandled number of child elements to call mod() statement at line [" + getLineNumber(call) + "]"); final Element param1 = call.getChildren().get(1); final Element param2 = call.getChildren().get(2); // The rule will assume that any hardcoded integer in the first parameter is an indication of reversed // parameters if (param1.getName().equalsIgnoreCase("INT")) { violations.add(new ReversedModuloParametersViolation(getLineNumber(param1))); } // If the second parameter to the modulo function is 1 then add a violation if (param2.getName().equalsIgnoreCase("INT") && param2.getAttributeValue("text").equalsIgnoreCase("1")) { violations.add(new ModuloByOneViolation(getLineNumber(param2))); } } return violations; }
public static void main(String[] args) { try { SAXBuilder b = new SAXBuilder(true); // true -> validate // Create a JDOM document. Document doc = b.build(new File("people+dtd.xml")); // Create an output formatter, and have it write the doc. new XMLOutputter().output(doc, System.out); } catch (JDOMException jex) { System.out.print("PARSE ERROR: " + jex.getMessage()); } catch (Exception ex) { ex.printStackTrace(); } } }
public QueryCapability readXML( String docAsString, URI uri ) throws IOException { // get ready for XML parsing warnMessages.setLength( 0 ); errMessages.setLength( 0 ); fatalMessages.setLength( 0 ); Document doc = null; try { doc = builder.build( new StringReader( docAsString ) ); } catch ( JDOMException e ) { fatalMessages.append( e.getMessage() ); // makes it invalid } return readXML( doc, uri ); }
throw new JDOMException("JDOM requires that the XMLStreamReader " + "is at the START_ELEMENT state when retrieving an " + "Element Fragment."); case START_ELEMENT: Element tmp = processElement(factory, reader); current.addContent(tmp); current = tmp; depth++; break; case END_ELEMENT: current = current.getParentElement(); depth--; break; case CDATA: current.addContent(factory.cdata(reader.getText())); break; throw new JDOMException("Unexpected XMLStream event " + reader.getEventType());