com.stimulsoft.base.utils
Class StiXmlHelper

java.lang.Object
  extended by com.stimulsoft.base.utils.StiXmlHelper

public class StiXmlHelper
extends Object

XML helper Copyright Stimulsoft


Constructor Summary
StiXmlHelper()
           
 
Method Summary
static Document loadXML(File file)
          Parse xml file to Document If file not foutn it tries to load from resuorces
static Document loadXML(InputStream is)
           
static Document loadXML(String filePath)
           
static String serialize(Document doc)
          Serialize Document to string
static String serialize(Document doc, boolean omitXMLDeclaration)
           
static String serialize(Document doc, boolean omitXMLDeclaration, boolean indent, Element element)
          Serialize Document to string
static String serialize(Document doc, boolean omitXMLDeclaration, Element element)
           
static String serialize(Document doc, Element el)
          Serialize element
static String validName(String value)
          Check & convert non-valid XML param
static Element writeElementString(Document doc, Element element, String elName, String value)
          Write string emenet-value to Element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StiXmlHelper

public StiXmlHelper()
Method Detail

loadXML

public static Document loadXML(String filePath)
                        throws ParserConfigurationException,
                               SAXException,
                               IOException
Throws:
ParserConfigurationException
SAXException
IOException

loadXML

public static Document loadXML(File file)
                        throws ParserConfigurationException,
                               SAXException,
                               IOException
Parse xml file to Document If file not foutn it tries to load from resuorces

Parameters:
filePath -
Returns:
Throws:
ParserConfigurationException
SAXException
IOException

loadXML

public static Document loadXML(InputStream is)
                        throws ParserConfigurationException,
                               SAXException,
                               IOException
Throws:
ParserConfigurationException
SAXException
IOException

serialize

public static String serialize(Document doc)
                        throws IOException,
                               TransformerException
Serialize Document to string

Parameters:
doc - Document
Returns:
Serialized Document
Throws:
IOException
TransformerException

serialize

public static String serialize(Document doc,
                               boolean omitXMLDeclaration)
                        throws IOException,
                               TransformerException
Throws:
IOException
TransformerException

serialize

public static String serialize(Document doc,
                               boolean omitXMLDeclaration,
                               Element element)
                        throws IOException,
                               TransformerException
Throws:
IOException
TransformerException

serialize

public static String serialize(Document doc,
                               boolean omitXMLDeclaration,
                               boolean indent,
                               Element element)
                        throws IOException,
                               TransformerException
Serialize Document to string

Parameters:
doc - Document
omitXMLDeclaration - Omit XML declaration
Returns:
Throws:
IOException
TransformerException

serialize

public static String serialize(Document doc,
                               Element el)
                        throws IOException,
                               TransformerException
Serialize element

Parameters:
doc - Document
el - Element
Returns:
Serialized element
Throws:
IOException
TransformerException

validName

public static String validName(String value)
Check & convert non-valid XML param

Parameters:
value -
Returns:

writeElementString

public static Element writeElementString(Document doc,
                                         Element element,
                                         String elName,
                                         String value)
Write string emenet-value to Element

Parameters:
doc - Current Document
element - Current Element
elName -
value -
Returns:
Created Element


Copyright © 2017 Stimulsoft. All Rights Reserved.