/**
* Utils.java
*
* Copyright (c) 2010, JULIE Lab.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
*
* Author: chew
*
* Current version: 1.0
* Since version: 1.0
*
* Creation date: 16.11.2010
**/
package de.julielab.xml;
import com.ximpleware.*;
import com.ximpleware.EOFException;
import com.ximpleware.extended.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.sql.Timestamp;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
interface FieldValueSource {
Object getFieldValue() throws FieldValueRetrievalException;
}
/**
* Utility class offering convenience methods.
*
* @author faessler
*/
public class JulieXMLTools {
public static final int ELEMENT_FRAGMENT = 0;
public static final int CONTENT_FRAGMENT = 1;
static final Logger LOG = LoggerFactory.getLogger(JulieXMLTools.class);
/**
* Convenience method for quick construction of a row iterator over an XML
* document.
*
*
* The fileName
determines the location of the XML file to
* return data records from. For more detailed information see
* {@link #constructRowIterator(VTDNav, String, List, String)}.
*
* @param fileName XML file to return data rows from.
* @param bufferSize Size of buffers while reading the file at
* fileName
.
* @param forEachXpath An XPath expression determining the XML elements to retrieve
* data records from.
* @param fields List of attribute-value pairs determining the record fields
* returned by the iterator.
* @return An iterator over all rows extracted from the XMl document pointed
* to by fileName
.
*/
public static Iterator