-/*
-* Copyright 2001-2009 Internet2
- *
-* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
+ *
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
*/
/**
// We have a DOM but it doesn't match the document we were given, so we import
// it into the new document.
- cachedDOM=static_cast<DOMElement*>(document->importNode(cachedDOM, true));
+ try {
+ cachedDOM=static_cast<DOMElement*>(document->importNode(cachedDOM, true));
+ }
+ catch (XMLException& ex) {
+ auto_ptr_char temp(ex.getMessage());
+ throw XMLParserException(
+ string("Error importing DOM into caller-supplied document: ") + (temp.get() ? temp.get() : "no message")
+ );
+ }
// Recache the DOM.
setDocumentElement(document, cachedDOM);
// The caller insists on using his own document, so we now have to import the thing
// into it. Then we're just dumping the one we built.
log.debug("reimporting new DOM into caller-supplied document");
- cachedDOM=static_cast<DOMElement*>(document->importNode(internalDoc->getDocumentElement(), true));
+ try {
+ cachedDOM=static_cast<DOMElement*>(document->importNode(internalDoc->getDocumentElement(), true));
+ }
+ catch (XMLException& ex) {
+ internalDoc->release();
+ auto_ptr_char temp(ex.getMessage());
+ throw XMLParserException(
+ string("Error importing DOM into caller-supplied document: ") + (temp.get() ? temp.get() : "no message")
+ );
+ }
internalDoc->release();
}
else {
// We have a DOM but it doesn't match the document we were given, so we import
// it into the new document.
- cachedDOM=static_cast<DOMElement*>(parentElement->getOwnerDocument()->importNode(cachedDOM, true));
+ try {
+ cachedDOM=static_cast<DOMElement*>(parentElement->getOwnerDocument()->importNode(cachedDOM, true));
+ }
+ catch (XMLException& ex) {
+ auto_ptr_char temp(ex.getMessage());
+ throw XMLParserException(
+ string("Error importing DOM into caller-supplied document: ") + (temp.get() ? temp.get() : "no message")
+ );
+ }
// Recache the DOM.
parentElement->appendChild(cachedDOM);
DOMDocument* internalDoc=XMLToolingConfig::getConfig().getParser().parse(dsrc);
log.debug("reimporting new DOM into caller-supplied document");
- cachedDOM=static_cast<DOMElement*>(parentElement->getOwnerDocument()->importNode(internalDoc->getDocumentElement(), true));
+ try {
+ cachedDOM=static_cast<DOMElement*>(parentElement->getOwnerDocument()->importNode(internalDoc->getDocumentElement(), true));
+ }
+ catch (XMLException& ex) {
+ internalDoc->release();
+ auto_ptr_char temp(ex.getMessage());
+ throw XMLParserException(
+ string("Error importing DOM into caller-supplied document: ") + (temp.get() ? temp.get() : "no message")
+ );
+ }
internalDoc->release();
// Recache the DOM and clear the serialized copy.