|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.massimo.utils.XMLHelper
public class XMLHelper
Helper to do things with XML and nu.xom.Elements
| Constructor Summary | |
|---|---|
XMLHelper()
|
|
| Method Summary | |
|---|---|
static void |
copyAttributes(Element source,
Element target)
Copy all source Attributes to target |
static void |
extractAttributes(Map<String,String> map,
Element element)
Add all element's attributes to map |
static void |
extractAttributes(Properties properties,
Element element)
Add all element's attributes to properties |
static void |
extractProperties(Map<String,String> map,
Element element,
String propertyElementName)
Add all child properties to map |
static void |
extractProperties(Properties properties,
Element element,
String propertyElementName)
Add all child properties to properties |
static Builder |
getNonValidatingBuilder()
|
static Element |
getRootElement(Element element)
Utility method to find the root element for a given element |
static String |
getText(Node node)
The XOM Node.getValue() method returns the XPath 1.0 string-value of Node. |
static Builder |
getValidatingBuilder()
Delegates to getValidatingBuilder(String, String) without setting noNamespaceSchemaLocation or externalLocation. |
static Builder |
getValidatingBuilder(String externalLocation)
Delegates to getValidatingBuilder(String, String) |
protected static Builder |
getValidatingBuilder(String noNamespaceSchemaLocation,
String externalLocation)
Unfortunately, the Xerces parser does not honour both noNamespaceSchemaLocation and externalLocation. |
static Builder |
getValidatingBuilderNoNamespace(String noNamespaceSchemaLocation)
Delegates to getValidatingBuilder(String, String) |
static void |
populateAttributes(Map<String,String> attributes,
Element element)
Set attributes for an element |
static boolean |
readBooleanAttribute(Element elm,
String attrName)
Helper method to read named attribute from specified element and convert it to boolean. |
static boolean |
readBooleanAttribute(Element elm,
String attrName,
boolean defaultValue)
Helper method to read named attribute from specified element and convert it to boolean. |
static int |
readIntAttribute(Element elm,
String attrName,
int defaultValue)
|
static Element |
readXML(String xmlFile)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XMLHelper()
| Method Detail |
|---|
public static void copyAttributes(Element source,
Element target)
source - target -
public static void extractAttributes(Map<String,String> map,
Element element)
map - Map to add attribute (name, value) ;element - Element
public static void extractAttributes(Properties properties,
Element element)
properties - to add attribute (name, value) ;element - Element
public static void extractProperties(Map<String,String> map,
Element element,
String propertyElementName)
map - Map to add attribute (name, value) ;element - A properties elementpropertyElementName -
public static void extractProperties(Properties properties,
Element element,
String propertyElementName)
properties - to add attribute (name, value) ;element - A properties elementpropertyElementName - public static Builder getNonValidatingBuilder()
public static Element getRootElement(Element element)
element - the element to find the root of
public static String getText(Node node)
node -
public static Builder getValidatingBuilder()
throws SAXException
SAXException
public static Builder getValidatingBuilder(String externalLocation)
throws SAXException
externalLocation - A schema location list. Defaults to XInclude schema location.
SAXException
protected static Builder getValidatingBuilder(String noNamespaceSchemaLocation,
String externalLocation)
throws SAXException
noNamespaceSchemaLocation - If specified, externalLocation will be ignored.externalLocation - If empty, defaults to XInclude schema location
SAXException
public static Builder getValidatingBuilderNoNamespace(String noNamespaceSchemaLocation)
throws SAXException
noNamespaceSchemaLocation - The location of a schema for the nameless namespace
SAXException
public static void populateAttributes(Map<String,String> attributes,
Element element)
attributes - the attrbutes to setelement - the element the attributes belong to
public static boolean readBooleanAttribute(Element elm,
String attrName)
elm - Source elementattrName - Name of the attribute
public static boolean readBooleanAttribute(Element elm,
String attrName,
boolean defaultValue)
elm - Source elementattrName - Name of the attributedefaultValue -
public static int readIntAttribute(Element elm,
String attrName,
int defaultValue)
elm - attrName - defaultValue -
public static Element readXML(String xmlFile)
throws ValidityException,
ParsingException,
IOException,
BadParseAttributeException,
InclusionLoopException,
NoIncludeLocationException,
XIncludeException
xmlFile -
ValidityException
ParsingException
IOException
BadParseAttributeException
InclusionLoopException
NoIncludeLocationException
XIncludeException
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||