Package org.jdom2.input

Examples of org.jdom2.input.SAXBuilder


    }

    private LinkedList<String> doFilter(String in, Set<String> xpaths) throws IOException {
        LinkedList<String> result = new LinkedList<String>();
        try {
            Document doc = new SAXBuilder(XMLReaders.NONVALIDATING).build(new StringReader(in));
            XMLOutputter out = new XMLOutputter();

            for (String xp : xpaths) {
                XPathExpression<Content> xpath = XPathFactory.instance().compile(xp, Filters.content());
                for (Content node : xpath.evaluate(doc)) {
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 attribute.getValue();
    }

    public static org.jdom2.Document loadInput(String html) throws LoadInputException {
        try {
            return new SAXBuilder().build(new StringReader(html));
        } catch (JDOMException e) {
            throw new LoadInputException("Unable to parse input", e);
        } catch (IOException e) {
            throw new LoadInputException("Unable to parse input", e);
        }
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

        .getResourceAsStream("/sniffingLogger.xml");
    if (settingIS == null) {
      logger.debug("file sniffingLogger.xml not found in classpath");
    } else {
      try {
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(settingIS);
        settingIS.close();
        Element rootElement = document.getRootElement();
        List<Element> sniffingloggers = rootElement
            .getChildren("sniffingLogger");
        for (Element sniffinglogger : sniffingloggers) {
View Full Code Here

   */
  public static List<Element> parse( String xml, String requestedNodes )
  {
    if( StringUtils.isNotEmpty( xml ) && StringUtils.isNotEmpty( requestedNodes ) ) {
      Set<Element> readed = new HashSet<Element>();
      SAXBuilder builder = new SAXBuilder();
      try {
        Enumeration< URL > resources = XmlUtil.class.getClassLoader().getResources( xml );
        while( resources.hasMoreElements() ) {
                  URL resource = resources.nextElement();
                  log.debug( "reading " + resource.toString() );
                  Document doc = builder.build( resource );
                  XPathFactory xpfac = XPathFactory.instance();
                  XPathExpression<Element> xp = xpfac.compile( requestedNodes, Filters.element() );
                  readed.addAll( xp.evaluate( doc ) ); // filter out repeated items
              }
        return new ArrayList<Element>( readed );
View Full Code Here

   * @return the requested nodes of the XML stream.
   */
  public static List<Element> parse( InputStream xmlStream, String requestedNodes )
  {
    if( xmlStream != null && StringUtils.isNotEmpty( requestedNodes ) ) {
      SAXBuilder builder = new SAXBuilder();
      try {
                Document doc = builder.build(xmlStream);
                XPathFactory xpfac = XPathFactory.instance();
                XPathExpression< Element > xp = xpfac.compile(requestedNodes,Filters.element());
        return xp.evaluate( doc );
      } catch ( IOException ioe ) {
        log.error( "Couldn't load all " + xmlStream + " resources", ioe );
View Full Code Here

     * @throws JDOMException if the deployment descriptor cannot be parsed correctly
     */
    protected Document getWebXml() throws JDOMException, IOException
    {
        URL url;
        SAXBuilder builder = new SAXBuilder();
        builder.setValidation( false );
        builder.setEntityResolver( new LocalEntityResolver() );
        Document doc = null;
        if ( m_engine.getServletContext() == null )
        {
            ClassLoader cl = WebContainerAuthorizer.class.getClassLoader();
            url = cl.getResource( "WEB-INF/web.xml" );
            if( url != null )
                log.info( "Examining " + url.toExternalForm() );
        }
        else
        {
            url = m_engine.getServletContext().getResource( "/WEB-INF/web.xml" );
            if( url != null )
                log.info( "Examining " + url.toExternalForm() );
        }
        if( url == null )
            throw new IOException("Unable to find web.xml for processing.");

        log.debug( "Processing web.xml at " + url.toExternalForm() );
        doc = builder.build( url );
        return doc;
    }
View Full Code Here

        this.fichier = fichier;
        this.coureurs = new HashMap<>();
        this.equipes = new HashMap<>();
       
        try {
            SAXBuilder saxBuilder = new SAXBuilder();
            this.document = saxBuilder.build(fichier);
           
        } catch (JDOMException | IOException ex) {
            if (ex instanceof JDOMParseException) {
                JDOMParseException exJDOMParse = (JDOMParseException) ex;
                System.out.println("colonne : " + exJDOMParse.getColumnNumber());
View Full Code Here

            String content = ReleaseUtil.readXmlFile(pomFile, ls);
            // we need to eliminate any extra whitespace inside elements, as JDOM will nuke it
            content = content.replaceAll( "<([^!][^>]*?)\\s{2,}([^>]*?)>", "<$1 $2>" );
            content = content.replaceAll( "(\\s{2,}|[^\\s])/>", "$1 />" );

            SAXBuilder builder = new SAXBuilder();
            Document document = builder.build( new StringReader( content ) );

            // Normalize line endings to platform's style (XML processors like JDOM normalize line endings to "\n" as
            // per section 2.11 of the XML spec)
            normaliseLineEndings( document );

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.