|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jaffa.util.XmlHelper
Utility Class for Common XML Manipulation routines.
| Constructor Summary | |
XmlHelper()
|
|
| Method Summary | |
static String |
getTextTrim(Node node)
This returns the textual content directly held under this element. |
static boolean |
hasChildElements(Node node)
Test whether the input element has a child element. |
static InputStream |
stripDoctypeDeclaration(InputStream in)
This routine will return an InputStream which will strip off the DOCTYPE declaration from the source InputStream. |
static InputStream |
stripDoctypeDeclaration(URL in)
This routine will return an InputStream which will strip off the DOCTYPE declaration from the source URL. |
| 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 boolean hasChildElements(Node node)
node - The Element to be tested.
public static String getTextTrim(Node node)
node - The Element for which the Text is to be returned
public static InputStream stripDoctypeDeclaration(URL in)
throws IOException
in - The source URL from which the DOCTYPE will be stripped off.
IOException - if an I/O error occurs.stripDoctypeDeclaration(InputStream)
public static InputStream stripDoctypeDeclaration(InputStream in)
throws IOException
URL xmlFile = "testfile.xml";
try {
xmlFile = URLHelper.newExtendedURL(name);
} catch (MalformedURLException e) {
log.fatal("Can't Find Components Definition File. Bad URL - " + name, e);
return null;
}
try {
// create a JAXBContext capable of handling classes generated into the package
JAXBContext jc = JAXBContext.newInstance("org.jaffa.presentation.portlet.component.componentdomain");
// create an Unmarshaller
Unmarshaller u = jc.createUnmarshaller();
// enable validation
u.setValidating(true);
// unmarshal a document into a tree of Java content objects composed of classes from the package.
compList = (Components) u.unmarshal(XmlHelper.stripDoctypeDeclaration(xmlFile));
} catch (JAXBException e) {
log.fatal("XML Formatting Error Reading Components Definition File", e);
return null;
} catch (IOException e) {
log.fatal("Error in Reading Components Definition File", e);
return null;
}
in - The source InputStream from which the DOCTYPE will be stripped off.
IOException - if an I/O error occurs.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||