Package org.jdom2.input

Examples of org.jdom2.input.SAXBuilder


    private void replaceVersion(File originalPomFile, File newPomFile, String newVersion) throws IOException, JDOMException {

        //we assume that the version of "internal" dependencies are declared with ${project.version}
        FileWriter writer = new FileWriter(newPomFile);
        SAXBuilder parser = new SAXBuilder();
        XMLOutputter xmlOutput = new XMLOutputter();
        // display nice nice
        xmlOutput.setFormat(Format.getPrettyFormat());

        //parse the document
        Document doc = parser.build(originalPomFile);
        Element versionElem = findVersionElement(doc);
        versionElem.setText(newVersion);
        xmlOutput.output(doc, writer);
        writer.flush();
        writer.close();
View Full Code Here


  /**
   * Parse entry from reader.
   */
  public static Entry parseEntry(Reader rd, String baseURI) throws JDOMException, IOException, IllegalArgumentException, FeedException {
    // Parse entry into JDOM tree
    SAXBuilder builder = new SAXBuilder();
    Document entryDoc = builder.build(rd);
    Element fetchedEntryElement = entryDoc.getRootElement();
    fetchedEntryElement.detach();

    // Put entry into a JDOM document with 'feed' root so that Rome can handle it
    Feed feed = new Feed();
View Full Code Here

    return Collections.singleton(MAVEN_PROJECT);
  }

  public Object buildModel(final Map<String, Object> models) {
    final LocatedJDOMFactory locatedJDOMFactory = new LocatedJDOMFactory();
    final SAXBuilder saxBuilder = new SAXBuilder();
    saxBuilder.setJDOMFactory(locatedJDOMFactory);
   
    final MavenProject mavenProject = (MavenProject) models.get(MAVEN_PROJECT);
   
    try {
      Document document = saxBuilder.build(mavenProject.getFile());
      return document;
    } catch (JDOMException e) {
      throw new RuntimeException("Unable to build JDOM2 model", e);
    } catch (IOException e) {
      throw new RuntimeException("Unable to build JDOM2 model", e);
View Full Code Here

    this.annotatorNames = annotatorNames;
  }

  public Collection<KnowtatorAnnotation> parse(URI knowtatorXML) throws JDOMException, IOException {

    Element annotationsElem = new SAXBuilder().build(knowtatorXML.toURL()).getRootElement();

    // parse <annotation> elements
    Set<String> ignoredAnnotators = new HashSet<String>();
    Map<String, KnowtatorAnnotation> annotations = new HashMap<String, KnowtatorAnnotation>();
    for (Element annotationElem : annotationsElem.getChildren("annotation")) {
View Full Code Here

     */
    @Override
    public List<String> parseResponse(String resource, String requestUrl, Repository triples, InputStream in, String contentType) throws DataRetrievalException {
        // build a JDOM document
        try {
            SAXBuilder parser = new SAXBuilder(XMLReaders.NONVALIDATING);
            Document doc = parser.build(in);


            Set<Namespace> namespaces = new HashSet<Namespace>();
            for(Map.Entry<String,String> ns : getNamespaceMappings().entrySet()) {
                namespaces.add(Namespace.getNamespace(ns.getKey(), ns.getValue()));
View Full Code Here

        try {
            log.trace("PARSE {}", urlDecode(requestUrl).replaceFirst(".*=xml&", ""));

            parseParams(requestUrl);
            final Context context = Context.fromUrl(requestUrl);
            final Document doc = new SAXBuilder(XMLReaders.NONVALIDATING).build(in);

            ArrayList<String> followUp = new ArrayList<String>();
            final RepositoryConnection con = repository.getConnection();
            final ValueFactory valueFactory = con.getValueFactory();

View Full Code Here

                tmpDocString.append(content.getValue());
                tmpDocString.append("</tmpdoc>");
                StringReader tmpDocReader = new StringReader(tmpDocString.toString());
                Document tmpDoc;
                try {
                    SAXBuilder saxBuilder = new SAXBuilder();
                    tmpDoc = saxBuilder.build(tmpDocReader);
                }
                catch (Exception ex) {
                    throw new FeedException("Invalid XML",ex);
                }
                List children = tmpDoc.getRootElement().removeContent();
View Full Code Here

                tmpDocString.append("</tmpdoc>");
                StringReader tmpDocReader = new StringReader(tmpDocString.toString());
                Document tmpDoc;

                try {
                    SAXBuilder saxBuilder = new SAXBuilder();
                    tmpDoc = saxBuilder.build(tmpDocReader);
                }
                catch (Exception ex) {
                    throw new FeedException("Invalid XML",ex);
                }
View Full Code Here

        try {
            log.trace("PARSE {}", urlDecode(requestUrl).replaceFirst(".*=xml&", ""));

            parseParams(requestUrl);
            final Context context = Context.fromUrl(requestUrl);
            final Document doc = new SAXBuilder(XMLReaders.NONVALIDATING).build(in);

            ArrayList<String> followUp = new ArrayList<String>();
            final ValueFactory valueFactory = new ValueFactoryImpl();

            switch (context) {
View Full Code Here

        InputStream content = response.getEntity().getContent();
        if (content == null)
          return null;

        try {
          Document doc = new SAXBuilder().build(content);

          Element meta = doc.getRootElement();
          if (!"metadata".equals(meta.getName()))
            throw new IOException();
          Element vers = meta.getChild("versioning");
View Full Code Here

TOP

Related Classes of org.jdom2.input.SAXBuilder

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.