Java Code Examples for org.dom4j.io.SAXReader#setFeature()

The following examples show how to use org.dom4j.io.SAXReader#setFeature() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmlParserFactoryProducer.java    From hop with Apache License 2.0 6 votes vote down vote up
public static SAXReader getSAXReader( final EntityResolver resolver ) {
  SAXReader reader = new SAXReader();
  if ( resolver != null ) {
    reader.setEntityResolver( resolver );
  }
  try {
    reader.setFeature( XMLConstants.FEATURE_SECURE_PROCESSING, true );
    reader.setFeature( "http://xml.org/sax/features/external-general-entities", false );
    reader.setFeature( "http://xml.org/sax/features/external-parameter-entities", false );
    reader.setFeature( "http://apache.org/xml/features/nonvalidating/load-external-dtd", false );
  } catch ( SAXException e ) {
    logger.error( "Some parser properties are not supported." );
  }
  reader.setIncludeExternalDTDDeclarations( false );
  reader.setIncludeInternalDTDDeclarations( false );
  return reader;
}
 
Example 2
Source File: XMLParserFactoryProducer.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static SAXReader getSAXReader( final EntityResolver resolver ) {
  SAXReader reader = new SAXReader();
  if ( resolver != null ) {
    reader.setEntityResolver( resolver );
  }
  try {
    reader.setFeature( FEATURE_SECURE_PROCESSING, true );
    reader.setFeature( "http://xml.org/sax/features/external-general-entities", false );
    reader.setFeature( "http://xml.org/sax/features/external-parameter-entities", false );
    reader.setFeature( "http://apache.org/xml/features/nonvalidating/load-external-dtd", false );
  } catch ( SAXException e ) {
    logger.error( "Some parser properties are not supported." );
  }
  reader.setIncludeExternalDTDDeclarations( false );
  reader.setIncludeInternalDTDDeclarations( false );
  return reader;
}
 
Example 3
Source File: DefaultDocumentFormater.java    From moql with Apache License 2.0 6 votes vote down vote up
public T importObject(InputStream is) throws XmlAccessException {
	SAXReader reader = new SAXReader();
	if (encoding != null)
		reader.setEncoding(encoding);
	Document document;
	try {
		if (validation) {
			// specify the schema to use
	        reader.setValidation(true);
	        reader.setFeature("http://apache.org/xml/features/validation/schema",true);
	        // add error handler which turns any errors into XML
	        ErrorChecker checker = new ErrorChecker();
	        reader.setErrorHandler(checker);
		}
		document = reader.read(is);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		throw new XmlAccessException("Read failed!", e);
	}
	return formater.importObjectFromElement(document.getRootElement());
}
 
Example 4
Source File: ConfigurationServiceImpl.java    From studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Document getConfigurationAsDocument(@ProtectedResourceId(SITE_ID_RESOURCE_ID) String siteId, String module,
                                           String path, String environment)
        throws DocumentException, IOException {
    String content = getEnvironmentConfiguration(siteId, module, path, environment);
    Document retDocument = null;
    if (StringUtils.isNotEmpty(content)) {
        SAXReader saxReader = new SAXReader();
        try {
            saxReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
            saxReader.setFeature("http://xml.org/sax/features/external-general-entities", false);
            saxReader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
        } catch (SAXException ex) {
            logger.error("Unable to turn off external entity loading, this could be a security risk.", ex);
        }
        try (InputStream is = IOUtils.toInputStream(content)) {
            retDocument = saxReader.read(is);
        }
    }
    return retDocument;
}
 
Example 5
Source File: Dom4JDriver.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create and initialize the SAX reader.
 * 
 * @return the SAX reader instance.
 * @throws DocumentException if DOCTYPE processing cannot be disabled
 * @since 1.4.9
 */
protected SAXReader createReader() throws DocumentException {
    final SAXReader reader = new SAXReader();
    try {
        reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
    } catch (SAXException e) {
        throw new DocumentException("Cannot disable DOCTYPE processing", e);
    }
    return reader;
}
 
Example 6
Source File: ConfigParseUtils.java    From jeesuite-config with Apache License 2.0 5 votes vote down vote up
private static void parseDataFromXML(Map<String, Object> result, String xmlContents) {
	 Document doc = null;
	try {
           //doc = DocumentHelper.parseText(xmlContents);
		SAXReader reader = new SAXReader();
		 //忽略dtd验证
		reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); 
           InputSource source = new InputSource(new StringReader(xmlContents));
	    source.setEncoding("UTF-8");
	    doc = reader.read(source);
           Element rootElt = doc.getRootElement(); 
           Iterator<?> iter = rootElt.elementIterator("entry"); 
           // 遍历head节点
           while (iter.hasNext()) {
               Element elm = (Element) iter.next();
               String stringValue = elm.getStringValue();
               if(StringUtils.isNotBlank(stringValue)){                	
               	result.put(elm.attribute("key").getStringValue(), stringValue.trim());
               }
           }
       } catch (Exception e) {
       	if(e instanceof  org.dom4j.DocumentException){
       		throw new JeesuiteBaseException(500, "xml文件内容格式错误");
       	}
       	throw new RuntimeException(e);
       }
}
 
Example 7
Source File: Dom4jExtensionTest.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testExtension() throws Exception {
    SAXReader reader = new SAXReader();
    reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
    reader.setFeature("http://xml.org/sax/features/external-general-entities", false);
    reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
    Map<String, Object> vars = new HashMap<>(1);
    vars.put("document", reader.read(new StringReader(XML)));

    Object result = scriptFactory.getScript("/scripts/testDom4jExtension.get.groovy").execute(vars);

    assertEquals("Item #2", result);
}
 
Example 8
Source File: Dom4jTransformer.java    From tutorials with MIT License 5 votes vote down vote up
public Dom4jTransformer(String resourcePath) throws DocumentException, SAXException {
    // 1- Build the doc from the XML file
    SAXReader xmlReader = new SAXReader();
    xmlReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
    xmlReader.setFeature("http://xml.org/sax/features/external-general-entities", false);
    xmlReader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
    this.input = xmlReader.read(resourcePath);
}
 
Example 9
Source File: ContentServiceImpl.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
@ValidateParams
public Document getContentAsDocument(@ValidateStringParam(name = "site") String site,
                                     @ValidateSecurePathParam(name = "path") String path)
        throws DocumentException {
    // TODO: SJ: Refactor in 4.x as this already exists in Crafter Core (which is part of the new Studio)
    Document retDocument = null;
    InputStream is = null;
    try {
        is = this.getContent(site, path);
    } catch (ContentNotFoundException e) {
        logger.debug("Content not found for path {0}", e, path);
    }

    if(is != null) {
        try {
            SAXReader saxReader = new SAXReader();
            try {
                saxReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
                saxReader.setFeature("http://xml.org/sax/features/external-general-entities", false);
                saxReader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
            }catch (SAXException ex){
                logger.error("Unable to turn off external entity loading, This could be a security risk.", ex);
            }
            retDocument = saxReader.read(is);
        }
        finally {
            try {
                if (is != null) {
                    is.close();
                }
            }
            catch (IOException err) {
                logger.debug("Error closing stream for path {0}", err, path);
            }
        }
    }

    return retDocument;
}
 
Example 10
Source File: ComponentServlet.java    From Whack with Apache License 2.0 5 votes vote down vote up
/**
 * Unregisters all JSP page servlets for a component.
 *
 * @param webXML the web.xml file containing JSP page names to servlet class file
 *               mappings.
 */
public static void unregisterServlets(File webXML) {
    if (!webXML.exists()) {
        manager.getLog().error("Could not unregister component servlets, file " + webXML.getAbsolutePath() +
                " does not exist.");
        return;
    }
    // Find the name of the component directory given that the webXML file
    // lives in plugins/[pluginName]/web/web.xml
    String pluginName = webXML.getParentFile().getParentFile().getName();
    try {
        SAXReader saxReader = new SAXReader(false);
        saxReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",
                false);
        Document doc = saxReader.read(webXML);
        // Find all <servelt-mapping> entries to discover name to URL mapping.
        List names = doc.selectNodes("//servlet-mapping");
        for (int i = 0; i < names.size(); i++) {
            Element nameElement = (Element)names.get(i);
            String url = nameElement.element("url-pattern").getTextTrim();
            // Destroy the servlet than remove from servlets map.
            HttpServlet servlet = servlets.get(pluginName + url);
            servlet.destroy();
            servlets.remove(pluginName + url);
            servlet = null;
        }
    }
    catch (Throwable e) {
        manager.getLog().error(e);
    }
}
 
Example 11
Source File: WebXmlUtils.java    From Openfire with Apache License 2.0 5 votes vote down vote up
public static Document asDocument( File webXML ) throws DocumentException
{
    // Make the reader non-validating so that it doesn't try to resolve external DTD's. Trying to resolve
    // external DTD's can break on some firewall configurations.
    SAXReader saxReader = new SAXReader( false);
    try {
        saxReader.setFeature( "http://apache.org/xml/features/nonvalidating/load-external-dtd", false );
    }
    catch (SAXException e)
    {
        Log.warn("Error setting SAXReader feature", e);
    }
    return saxReader.read( webXML );
}
 
Example 12
Source File: PipelineContentImpl.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Document getDocument() throws ContentProcessException {
    if (_xml && _document == null) {
        if (_contentStream != null) {
            try {
                SAXReader saxReader = new SAXReader();
                try {
                    saxReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
                    saxReader.setFeature("http://xml.org/sax/features/external-general-entities", false);
                    saxReader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
                }catch (SAXException ex){
                    LOGGER.error("Unable to turn off external entity loading, This could be a security risk.", ex);
                }
                saxReader.setEncoding(_encoding);
                _document = saxReader.read(_contentStream);
                _contentStream = null;
            } catch (DocumentException e) {
                throw new ContentProcessException("Error while converting " + _id + " into document.", e);
            } finally {
                ContentUtils.release(_contentStream);
                _contentStream = null;
            }
        } else {
            throw new ContentProcessException("Error while converting " + _id
                    + " into document. Both document and content stream cannot be null.");
        }
    }
    return _document;
}
 
Example 13
Source File: SiteServiceImpl.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
protected boolean extractDependenciesForItem(String site, String path) {
boolean toReturn = true;

   try {
    if (path.endsWith(DmConstants.XML_PATTERN)) {
	    SAXReader saxReader = new SAXReader();
		try {
			saxReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
			saxReader.setFeature("http://xml.org/sax/features/external-general-entities", false);
			saxReader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
		}catch (SAXException ex){
			logger.error("Unable to turn off external entity loading, This could be a security risk.", ex);
		}

	    dependencyService.upsertDependencies(site, path);
    } else {
	    boolean isCss = path.endsWith(DmConstants.CSS_PATTERN);
	    boolean isJs = path.endsWith(DmConstants.JS_PATTERN);
	    boolean isTemplate = ContentUtils.matchesPatterns(path, servicesConfig.getRenderingTemplatePatterns
		    (site));
	    if (isCss || isJs || isTemplate) {
		    dependencyService.upsertDependencies(site, path);
	    }
    }
   } catch (ServiceLayerException e) {
    logger.error("Error extracting dependencies for site " + site + " file: " + path, e);
    toReturn = false;
   }

   return toReturn;
  }
 
Example 14
Source File: LoopNodesImportProgressDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings( "unchecked" )
private String[] doScan( IProgressMonitor monitor ) throws Exception {
  monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ScanningFile",
      filename ), 1 );

  SAXReader reader = XMLParserFactoryProducer.getSAXReader( null );
  monitor.worked( 1 );
  if ( monitor.isCanceled() ) {
    return null;
  }
  // Validate XML against specified schema?
  if ( meta.isValidating() ) {
    reader.setValidation( true );
    reader.setFeature( "http://apache.org/xml/features/validation/schema", true );
  } else {
    // Ignore DTD
    reader.setEntityResolver( new IgnoreDTDEntityResolver() );
  }
  monitor.worked( 1 );
  monitor
      .beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ReadingDocument" ), 1 );
  if ( monitor.isCanceled() ) {
    return null;
  }
  InputStream is = null;
  try {
    Document document = null;
    if ( !Utils.isEmpty( filename ) ) {
      is = KettleVFS.getInputStream( filename );
      document = reader.read( is, encoding );
    } else {
      if ( !Utils.isEmpty( xml ) ) {
        document = reader.read( new StringReader( xml ) );
      } else {
        document = reader.read( new URL( url ) );
      }
    }
    monitor.worked( 1 );
    monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.DocumentOpened" ),
        1 );
    monitor.worked( 1 );
    monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ReadingNode" ), 1 );

    if ( monitor.isCanceled() ) {
      return null;
    }
    List<Node> nodes = document.selectNodes( document.getRootElement().getName() );
    monitor.worked( 1 );
    monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes" ) );

    if ( monitor.isCanceled() ) {
      return null;
    }
    for ( Node node : nodes ) {
      if ( monitor.isCanceled() ) {
        return null;
      }
      if ( !listpath.contains( node.getPath() ) ) {
        nr++;
        monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes",
            String.valueOf( nr ) ) );
        monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.AddingNode", node
            .getPath() ) );
        listpath.add( node.getPath() );
        addLoopXPath( node, monitor );
      }
    }
    monitor.worked( 1 );
  } finally {
    try {
      if ( is != null ) {
        is.close();
      }
    } catch ( Exception e ) { /* Ignore */
    }
  }
  String[] list_xpath = listpath.toArray( new String[listpath.size()] );

  monitor.setTaskName( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.NodesReturned" ) );

  monitor.done();

  return list_xpath;

}
 
Example 15
Source File: XMLInputFieldsImportProgressDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings( "unchecked" )
private RowMetaAndData[] doScan( IProgressMonitor monitor ) throws Exception {
  monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ScanningFile",
      filename ), 1 );

  SAXReader reader = XMLParserFactoryProducer.getSAXReader( null );
  monitor.worked( 1 );
  if ( monitor.isCanceled() ) {
    return null;
  }
  // Validate XML against specified schema?
  if ( meta.isValidating() ) {
    reader.setValidation( true );
    reader.setFeature( "http://apache.org/xml/features/validation/schema", true );
  } else {
    // Ignore DTD
    reader.setEntityResolver( new IgnoreDTDEntityResolver() );
  }
  monitor.worked( 1 );
  monitor
      .beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ReadingDocument" ), 1 );
  if ( monitor.isCanceled() ) {
    return null;
  }
  InputStream is = null;
  try {

    Document document = null;
    if ( !Utils.isEmpty( filename ) ) {
      is = KettleVFS.getInputStream( filename );
      document = reader.read( is, encoding );
    } else {
      if ( !Utils.isEmpty( xml ) ) {
        document = reader.read( new StringReader( xml ) );
      } else {
        document = reader.read( new URL( url ) );
      }
    }

    monitor.worked( 1 );
    monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.DocumentOpened" ),
        1 );
    monitor.worked( 1 );
    monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ReadingNode" ), 1 );

    if ( monitor.isCanceled() ) {
      return null;
    }
    List<Node> nodes = document.selectNodes( this.loopXPath );
    monitor.worked( 1 );
    monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes" ) );

    if ( monitor.isCanceled() ) {
      return null;
    }
    for ( Node node : nodes ) {
      if ( monitor.isCanceled() ) {
        return null;
      }

      nr++;
      monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes", String
          .valueOf( nr ) ) );
      monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes", node
          .getPath() ) );
      setNodeField( node, monitor );
      childNode( node, monitor );

    }
    monitor.worked( 1 );
  } finally {
    try {
      if ( is != null ) {
        is.close();
      }
    } catch ( Exception e ) { /* Ignore */
    }
  }

  RowMetaAndData[] listFields = fieldsList.toArray( new RowMetaAndData[fieldsList.size()] );

  monitor.setTaskName( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.NodesReturned" ) );

  monitor.done();

  return listFields;

}
 
Example 16
Source File: LowercaseTableNames.java    From unitime with Apache License 2.0 4 votes vote down vote up
public LowercaseTableNames() throws DocumentException, SAXException {
	iSAXReader = new SAXReader();
	iSAXReader.setEntityResolver(iEntityResolver);
	iSAXReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
}
 
Example 17
Source File: DoubleVarcharSizes.java    From unitime with Apache License 2.0 4 votes vote down vote up
public DoubleVarcharSizes() throws DocumentException, SAXException {
	iSAXReader = new SAXReader();
	iSAXReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
}
 
Example 18
Source File: XmlHelper.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
public static SAXReader createSaxReader() throws SAXException {
	SAXReader reader = new SAXReader();
	reader.setFeature(NO_DOCTYPE, true);
	return reader;
}
 
Example 19
Source File: LoopNodesImportProgressDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings( "unchecked" )
private String[] doScan( IProgressMonitor monitor ) throws Exception {
  monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ScanningFile",
      filename ), 1 );

  SAXReader reader = XmlParserFactoryProducer.getSAXReader( null );
  monitor.worked( 1 );
  if ( monitor.isCanceled() ) {
    return null;
  }
  // Validate XML against specified schema?
  if ( meta.isValidating() ) {
    reader.setValidation( true );
    reader.setFeature( "http://apache.org/xml/features/validation/schema", true );
  } else {
    // Ignore DTD
    reader.setEntityResolver( new IgnoreDtdEntityResolver() );
  }
  monitor.worked( 1 );
  monitor
      .beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ReadingDocument" ), 1 );
  if ( monitor.isCanceled() ) {
    return null;
  }
  InputStream is = null;
  try {
    Document document = null;
    if ( !Utils.isEmpty( filename ) ) {
      is = HopVfs.getInputStream( filename );
      document = reader.read( is, encoding );
    } else {
      if ( !Utils.isEmpty( xml ) ) {
        document = reader.read( new StringReader( xml ) );
      } else {
        document = reader.read( new URL( url ) );
      }
    }
    monitor.worked( 1 );
    monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.DocumentOpened" ),
        1 );
    monitor.worked( 1 );
    monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ReadingNode" ), 1 );

    if ( monitor.isCanceled() ) {
      return null;
    }
    List<Node> nodes = document.selectNodes( document.getRootElement().getName() );
    monitor.worked( 1 );
    monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes" ) );

    if ( monitor.isCanceled() ) {
      return null;
    }
    for ( Node node : nodes ) {
      if ( monitor.isCanceled() ) {
        return null;
      }
      if ( !listpath.contains( node.getPath() ) ) {
        nr++;
        monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes",
            String.valueOf( nr ) ) );
        monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.AddingNode", node
            .getPath() ) );
        listpath.add( node.getPath() );
        addLoopXPath( node, monitor );
      }
    }
    monitor.worked( 1 );
  } finally {
    try {
      if ( is != null ) {
        is.close();
      }
    } catch ( Exception e ) { /* Ignore */
    }
  }
  String[] list_xpath = listpath.toArray( new String[listpath.size()] );

  monitor.setTaskName( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.NodesReturned" ) );

  monitor.done();

  return list_xpath;

}
 
Example 20
Source File: XmlInputFieldsImportProgressDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings( "unchecked" )
private RowMetaAndData[] doScan( IProgressMonitor monitor ) throws Exception {
  monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ScanningFile",
      filename ), 1 );

  SAXReader reader = XmlParserFactoryProducer.getSAXReader( null );
  monitor.worked( 1 );
  if ( monitor.isCanceled() ) {
    return null;
  }
  // Validate XML against specified schema?
  if ( meta.isValidating() ) {
    reader.setValidation( true );
    reader.setFeature( "http://apache.org/xml/features/validation/schema", true );
  } else {
    // Ignore DTD
    reader.setEntityResolver( new IgnoreDtdEntityResolver() );
  }
  monitor.worked( 1 );
  monitor
      .beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ReadingDocument" ), 1 );
  if ( monitor.isCanceled() ) {
    return null;
  }
  InputStream is = null;
  try {

    Document document = null;
    if ( !Utils.isEmpty( filename ) ) {
      is = HopVfs.getInputStream( filename );
      document = reader.read( is, encoding );
    } else {
      if ( !Utils.isEmpty( xml ) ) {
        document = reader.read( new StringReader( xml ) );
      } else {
        document = reader.read( new URL( url ) );
      }
    }

    monitor.worked( 1 );
    monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.DocumentOpened" ),
        1 );
    monitor.worked( 1 );
    monitor.beginTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.ReadingNode" ), 1 );

    if ( monitor.isCanceled() ) {
      return null;
    }
    List<Node> nodes = document.selectNodes( this.loopXPath );
    monitor.worked( 1 );
    monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes" ) );

    if ( monitor.isCanceled() ) {
      return null;
    }
    for ( Node node : nodes ) {
      if ( monitor.isCanceled() ) {
        return null;
      }

      nr++;
      monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes", String
          .valueOf( nr ) ) );
      monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes", node
          .getPath() ) );
      setNodeField( node, monitor );
      childNode( node, monitor );

    }
    monitor.worked( 1 );
  } finally {
    try {
      if ( is != null ) {
        is.close();
      }
    } catch ( Exception e ) { /* Ignore */
    }
  }

  RowMetaAndData[] listFields = fieldsList.toArray( new RowMetaAndData[fieldsList.size()] );

  monitor.setTaskName( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.NodesReturned" ) );

  monitor.done();

  return listFields;

}