public class JulieXMLTools extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
CONTENT_FRAGMENT |
static int |
ELEMENT_FRAGMENT |
| Constructor and Description |
|---|
JulieXMLTools() |
| Modifier and Type | Method and Description |
|---|---|
static Iterator<Map<String,Object>> |
constructRowIterator(byte[] data,
int bufferSize,
String forEachXpath,
List<Map<String,String>> fields,
String identifier)
Convenience method for quick construction of a row iterator over an XML document.
|
static Iterator<Map<String,Object>> |
constructRowIterator(String fileName,
int bufferSize,
String forEachXpath,
List<Map<String,String>> fields,
boolean largeFileSize)
Convenience method for quick construction of a row iterator over an XML document.
|
static Iterator<Map<String,Object>> |
constructRowIterator(com.ximpleware.VTDNav vn,
String forEachXpath,
List<Map<String,String>> fields,
String identifier)
The
VTDNav vn is a VTD navigator over the XML file to return data records from. |
static <T> String[] |
expandArrayEntries(List<T> list,
String fmtStr) |
static <T> String[] |
expandArrayEntries(T[] array,
String fmtStr) |
static <T> String[] |
expandArrayEntries(T[] array,
String[] fmtStrs) |
static String |
getElementText(com.ximpleware.VTDNav vn) |
static String |
getFragment(com.ximpleware.VTDNav vn,
int fragmentType,
boolean returnRawString) |
static URL |
getSolrServerURL(String urlStr,
boolean calledByCLI,
org.slf4j.Logger LOG) |
static com.ximpleware.VTDNav |
getVTDNav(InputStream is,
int bufferSize) |
static byte[] |
gzipData(byte[] data) |
static byte[] |
readStream(InputStream is,
int bufferSize)
Reads an
InputStream buffer wise, concatenates all buffers and returns one byte[] of
exact length of the read data. |
static int |
setElementText(com.ximpleware.VTDNav vn,
com.ximpleware.AutoPilot ap,
com.ximpleware.XMLModifier xm,
String xpath,
String text)
Sets the text content of an XML element pointed to by
xpath to text. |
static byte[] |
unGzipData(byte[] gzipData) |
public static final int ELEMENT_FRAGMENT
public static final int CONTENT_FRAGMENT
public static Iterator<Map<String,Object>> constructRowIterator(String fileName, int bufferSize, String forEachXpath, List<Map<String,String>> fields, boolean largeFileSize)
The fileName determines the location of the XML file to return data records from. For more detailed
information see constructRowIterator(VTDNav, String, List, String).
fileName - XML file to return data rows from.bufferSize - Size of buffers while reading the file at fileName.forEachXpath - An XPath expression determining the XML elements to retrieve data records from.fields - List of attribute-value pairs determining the record fields returned by the iterator.fileName.public static Iterator<Map<String,Object>> constructRowIterator(byte[] data, int bufferSize, String forEachXpath, List<Map<String,String>> fields, String identifier)
data contains the XML data to return data records from. For more detailed information see
constructRowIterator(VTDNav, String, List, String).
data - Byte array containing an XML document.bufferSize - Size of buffers while reading the file at fileName.forEachXpath - An XPath expression determining the XML elements to retrieve data records from.fields - List of attribute-value pairs determining the record fields returned by the iterator.identifier - A string identifying the XML document in data, needed for error messages.fileName.public static Iterator<Map<String,Object>> constructRowIterator(com.ximpleware.VTDNav vn, String forEachXpath, List<Map<String,String>> fields, String identifier)
The VTDNav vn is a VTD navigator over the XML file to return data records from. For each evaluation
of the forEach XPath expression, one data row is created
Such a row consist of the fields given by the list fields The list contains Maps of
attribute-value pairs. All fields are required to have a Constants#XPATH attribute which specifies the
XPath pointing to information in the XML documents to retrieve. Likewise, a Constants#NAME attribute is
required. This attribute determines the name of the field in the resulting row containing the information
retrieved by the field's Constants.XPATH attribute.
Example:
A field with the following attribute-value-pairs
<field name="pmid" xpath="/MedlineCitationSet/MedlineCitation/PMID" >
vn - The VTDNav object which navigates over the XML document to retrieve records from.forEachXpath - An XPath expression determining the XML elements for each of which one row should be created.fields - The fields to be returned with each data row.vn.public static com.ximpleware.VTDNav getVTDNav(InputStream is, int bufferSize) throws com.ximpleware.ParseException, FileTooBigException
com.ximpleware.ParseExceptionFileTooBigExceptionpublic static byte[] readStream(InputStream is, int bufferSize) throws IOException
InputStream buffer wise, concatenates all buffers and returns one byte[] of
exact length of the read data.is - InputStream to read.bufferSize - Size of maximum bytes to read by one is.read() call.byte[] containing all the data of the InputStream.IOExceptionpublic static byte[] gzipData(byte[] data)
public static byte[] unGzipData(byte[] gzipData)
throws IOException
IOExceptionpublic static URL getSolrServerURL(String urlStr, boolean calledByCLI, org.slf4j.Logger LOG)
public static String getElementText(com.ximpleware.VTDNav vn) throws com.ximpleware.NavException
com.ximpleware.NavExceptionpublic static String getFragment(com.ximpleware.VTDNav vn, int fragmentType, boolean returnRawString) throws com.ximpleware.NavException
com.ximpleware.NavExceptionpublic static int setElementText(com.ximpleware.VTDNav vn,
com.ximpleware.AutoPilot ap,
com.ximpleware.XMLModifier xm,
String xpath,
String text)
throws com.ximpleware.VTDException,
UnsupportedEncodingException
xpath to text.
The cursor of vn is moved to the element determined by xpath.
vn - VTDNav object navigating the XML document to modify.ap - AutoPilot object bound to vn.xm - XMLModifier object bound to vn.xpath - An XPath expression pointing to the XML element whose text should be set.text - The text which is to be set to the XML element pointed to by xpath.com.ximpleware.VTDException - If something with navigation or modification of the XML document goes wrong.UnsupportedEncodingExceptionCopyright © 2016 JULIE Lab Jena, Germany. All rights reserved.