286N/A/*
286N/A * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
286N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
286N/A *
286N/A * This code is free software; you can redistribute it and/or modify it
286N/A * under the terms of the GNU General Public License version 2 only, as
286N/A * published by the Free Software Foundation. Oracle designates this
286N/A * particular file as subject to the "Classpath" exception as provided
286N/A * by Oracle in the LICENSE file that accompanied this code.
286N/A *
286N/A * This code is distributed in the hope that it will be useful, but WITHOUT
286N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
286N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
286N/A * version 2 for more details (a copy is included in the LICENSE file that
286N/A * accompanied this code).
286N/A *
286N/A * You should have received a copy of the GNU General Public License version
286N/A * 2 along with this work; if not, write to the Free Software Foundation,
286N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
286N/A *
286N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
286N/A * or visit www.oracle.com if you need additional information or have any
286N/A * questions.
286N/A */
286N/A
286N/Apackage javax.xml.transform.dom;
286N/A
286N/Aimport javax.xml.transform.Source;
286N/A
286N/Aimport org.w3c.dom.Node;
286N/A
286N/A/**
286N/A * <p>Acts as a holder for a transformation Source tree in the
286N/A * form of a Document Object Model (DOM) tree.</p>
286N/A *
286N/A * <p>Note that XSLT requires namespace support. Attempting to transform a DOM
286N/A * that was not contructed with a namespace-aware parser may result in errors.
286N/A * Parsers can be made namespace aware by calling
286N/A * {@link javax.xml.parsers.DocumentBuilderFactory#setNamespaceAware(boolean awareness)}.</p>
286N/A *
286N/A * @author <a href="Jeff.Suttor@Sun.com">Jeff Suttor</a>
286N/A * @see <a href="http://www.w3.org/TR/DOM-Level-2">Document Object Model (DOM) Level 2 Specification</a>
286N/A */
286N/Apublic class DOMSource implements Source {
286N/A
286N/A /**
286N/A * <p><code>Node</code> to serve as DOM source.</p>
286N/A */
286N/A private Node node;
286N/A
286N/A /**
286N/A * <p>The base ID (URL or system ID) from where URLs
286N/A * will be resolved.</p>
286N/A */
286N/A private String systemID;
286N/A
286N/A /** If {@link javax.xml.transform.TransformerFactory#getFeature}
286N/A * returns true when passed this value as an argument,
286N/A * the Transformer supports Source input of this type.
286N/A */
286N/A public static final String FEATURE =
286N/A "http://javax.xml.transform.dom.DOMSource/feature";
286N/A
286N/A /**
286N/A * <p>Zero-argument default constructor. If this constructor is used, and
286N/A * no DOM source is set using {@link #setNode(Node node)} , then the
286N/A * <code>Transformer</code> will
286N/A * create an empty source {@link org.w3c.dom.Document} using
286N/A * {@link javax.xml.parsers.DocumentBuilder#newDocument()}.</p>
286N/A *
286N/A * @see javax.xml.transform.Transformer#transform(Source xmlSource, Result outputTarget)
286N/A */
286N/A public DOMSource() { }
286N/A
286N/A /**
286N/A * Create a new input source with a DOM node. The operation
286N/A * will be applied to the subtree rooted at this node. In XSLT,
286N/A * a "/" pattern still means the root of the tree (not the subtree),
286N/A * and the evaluation of global variables and parameters is done
286N/A * from the root node also.
286N/A *
286N/A * @param n The DOM node that will contain the Source tree.
286N/A */
286N/A public DOMSource(Node n) {
286N/A setNode(n);
286N/A }
286N/A
286N/A /**
286N/A * Create a new input source with a DOM node, and with the
286N/A * system ID also passed in as the base URI.
286N/A *
286N/A * @param node The DOM node that will contain the Source tree.
286N/A * @param systemID Specifies the base URI associated with node.
286N/A */
286N/A public DOMSource(Node node, String systemID) {
286N/A setNode(node);
286N/A setSystemId(systemID);
286N/A }
286N/A
286N/A /**
286N/A * Set the node that will represents a Source DOM tree.
286N/A *
286N/A * @param node The node that is to be transformed.
286N/A */
286N/A public void setNode(Node node) {
286N/A this.node = node;
286N/A }
286N/A
286N/A /**
286N/A * Get the node that represents a Source DOM tree.
286N/A *
286N/A * @return The node that is to be transformed.
286N/A */
286N/A public Node getNode() {
286N/A return node;
286N/A }
286N/A
286N/A /**
286N/A * Set the base ID (URL or system ID) from where URLs
286N/A * will be resolved.
286N/A *
286N/A * @param systemID Base URL for this DOM tree.
286N/A */
286N/A public void setSystemId(String systemID) {
286N/A this.systemID = systemID;
286N/A }
286N/A
286N/A /**
286N/A * Get the base ID (URL or system ID) from where URLs
286N/A * will be resolved.
286N/A *
286N/A * @return Base URL for this DOM tree.
286N/A */
286N/A public String getSystemId() {
286N/A return this.systemID;
286N/A }
286N/A}