Home » xml-commons-external-1.4.01-src » javax » xml » transform » dom » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   
   18   // $Id: DOMSource.java 446598 2006-09-15 12:55:40Z jeremias $
   19   
   20   package javax.xml.transform.dom;
   21   
   22   import javax.xml.transform.Source;
   23   
   24   import org.w3c.dom.Node;
   25   
   26   /**
   27    * <p>Acts as a holder for a transformation Source tree in the
   28    * form of a Document Object Model (DOM) tree.</p>
   29    * 
   30    * <p>Note that XSLT requires namespace support. Attempting to transform a DOM
   31    * that was not contructed with a namespace-aware parser may result in errors.
   32    * Parsers can be made namespace aware by calling
   33    * {@link javax.xml.parsers.DocumentBuilderFactory#setNamespaceAware(boolean awareness)}.</p>
   34    * 
   35    * @author <a href="Jeff.Suttor@Sun.com">Jeff Suttor</a>
   36    * @version $Revision: 446598 $, $Date: 2006-09-15 08:55:40 -0400 (Fri, 15 Sep 2006) $
   37    * @see <a href="http://www.w3.org/TR/DOM-Level-2">Document Object Model (DOM) Level 2 Specification</a>
   38    */
   39   public class DOMSource implements Source {
   40   
   41       /**
   42        * <p><code>Node</code> to serve as DOM source.</p>
   43        */
   44       private Node node;
   45   
   46       /**
   47        * <p>The base ID (URL or system ID) from where URLs
   48        * will be resolved.</p>
   49        */
   50       private String systemID;
   51   
   52       /** If {@link javax.xml.transform.TransformerFactory#getFeature}
   53        * returns true when passed this value as an argument,
   54        * the Transformer supports Source input of this type.
   55        */
   56       public static final String FEATURE =
   57           "http://javax.xml.transform.dom.DOMSource/feature";
   58   
   59       /**
   60        * <p>Zero-argument default constructor.  If this constructor is used, and
   61        * no DOM source is set using {@link #setNode(Node node)} , then the
   62        * <code>Transformer</code> will
   63        * create an empty source {@link org.w3c.dom.Document} using
   64        * {@link javax.xml.parsers.DocumentBuilder#newDocument()}.</p>
   65        *
   66        * @see javax.xml.transform.Transformer#transform(Source xmlSource, Result outputTarget)
   67        */
   68       public DOMSource() { }
   69   
   70       /**
   71        * Create a new input source with a DOM node.  The operation
   72        * will be applied to the subtree rooted at this node.  In XSLT,
   73        * a "/" pattern still means the root of the tree (not the subtree),
   74        * and the evaluation of global variables and parameters is done
   75        * from the root node also.
   76        *
   77        * @param n The DOM node that will contain the Source tree.
   78        */
   79       public DOMSource(Node n) {
   80           setNode(n);
   81       }
   82   
   83       /**
   84        * Create a new input source with a DOM node, and with the
   85        * system ID also passed in as the base URI.
   86        *
   87        * @param node The DOM node that will contain the Source tree.
   88        * @param systemID Specifies the base URI associated with node.
   89        */
   90       public DOMSource(Node node, String systemID) {
   91           setNode(node);
   92           setSystemId(systemID);
   93       }
   94   
   95       /**
   96        * Set the node that will represents a Source DOM tree.
   97        *
   98        * @param node The node that is to be transformed.
   99        */
  100       public void setNode(Node node) {
  101           this.node = node;
  102       }
  103   
  104       /**
  105        * Get the node that represents a Source DOM tree.
  106        *
  107        * @return The node that is to be transformed.
  108        */
  109       public Node getNode() {
  110           return node;
  111       }
  112   
  113       /**
  114        * Set the base ID (URL or system ID) from where URLs
  115        * will be resolved.
  116        *
  117        * @param systemID Base URL for this DOM tree.
  118        */
  119       public void setSystemId(String systemID) {
  120           this.systemID = systemID;
  121       }
  122   
  123       /**
  124        * Get the base ID (URL or system ID) from where URLs
  125        * will be resolved.
  126        *
  127        * @return Base URL for this DOM tree.
  128        */
  129       public String getSystemId() {
  130           return this.systemID;
  131       }
  132   }

Home » xml-commons-external-1.4.01-src » javax » xml » transform » dom » [javadoc | source]