286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2005 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xerces.internal.util;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
286N/Aimport org.w3c.dom.Node;
286N/A
286N/A/**
286N/A * <p>An <code>XMLInputSource</code> analogue to <code>javax.xml.transform.dom.DOMSource</code>.</p>
286N/A *
286N/A */
286N/Apublic final class DOMInputSource extends XMLInputSource {
286N/A
286N/A private Node fNode;
286N/A
286N/A public DOMInputSource() {
286N/A this(null);
286N/A }
286N/A
286N/A public DOMInputSource(Node node) {
286N/A super(null, getSystemIdFromNode(node), null);
286N/A fNode = node;
286N/A }
286N/A
286N/A public DOMInputSource(Node node, String systemId) {
286N/A super(null, systemId, null);
286N/A fNode = node;
286N/A }
286N/A
286N/A public Node getNode() {
286N/A return fNode;
286N/A }
286N/A
286N/A public void setNode(Node node) {
286N/A fNode = node;
286N/A }
286N/A
286N/A private static String getSystemIdFromNode(Node node) {
286N/A if (node != null) {
286N/A try {
286N/A return node.getBaseURI();
286N/A }
286N/A // If the DOM implementation is DOM Level 2
286N/A // then a NoSuchMethodError will be thrown.
286N/A // Just ignore it.
286N/A catch (NoSuchMethodError e) {
286N/A return null;
286N/A }
286N/A // There was a failure for some other reason
286N/A // Ignore it as well.
286N/A catch (Exception e) {
286N/A return null;
286N/A }
286N/A }
286N/A return null;
286N/A }
286N/A
286N/A} // DOMInputSource