unico 2004/03/27 07:35:49
Modified: src/java/org/apache/cocoon/components/source SourceUtil.java
Log:
add toDOM method that takes mimeTypeHint
Revision Changes Path
1.16 +28 -3
cocoon-2.1/src/java/org/apache/cocoon/components/source/SourceUtil.java
Index: SourceUtil.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/source/SourceUtil.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- SourceUtil.java 24 Mar 2004 12:24:14 -0000 1.15
+++ SourceUtil.java 27 Mar 2004 15:35:49 -0000 1.16
@@ -302,7 +302,7 @@
* @throws SAXException If a SAX exception occurs.
*/
static public Document toDOM(Source source)
- throws SAXException, IOException, ProcessingException {
+ throws SAXException, IOException, ProcessingException {
DOMBuilder builder = new DOMBuilder();
toSAX(source, builder);
@@ -327,7 +327,7 @@
* @throws SAXException If a SAX exception occurs.
*/
static public Document toDOM(ServiceManager manager, Source source)
- throws SAXException, IOException, ProcessingException {
+ throws SAXException, IOException, ProcessingException {
DOMBuilder builder = new DOMBuilder();
toSAX(manager, source, null, builder);
@@ -341,6 +341,31 @@
return document;
}
+ /**
+ * Generates a DOM from the given source
+ * @param source The data
+ *
+ * @return Created DOM document.
+ *
+ * @throws IOException If a io exception occurs.
+ * @throws ProcessingException if no suitable converter is found
+ * @throws SAXException If a SAX exception occurs.
+ */
+ static public Document toDOM(ServiceManager manager, String
mimeTypeHint, Source source)
+ throws SAXException, IOException, ProcessingException {
+ DOMBuilder builder = new DOMBuilder();
+
+ toSAX(manager, source, mimeTypeHint, builder);
+
+ Document document = builder.getDocument();
+ if (document == null) {
+ throw new ProcessingException("Could not build DOM for '"+
+ source.getURI()+"'");
+ }
+
+ return document;
+ }
+
/**
* Make a ProcessingException from a SourceException
* If the exception is a SourceNotFoundException than a