Source Home >> Java Source 1.6.0 >> javax.xml.transform.dom.DOMSource V 0.09
  • 001/*
  • 002 * The contents of this file are subject to the terms
  • 003 * of the Common Development and Distribution License
  • 004 * (the "License"). You may not use this file except
  • 005 * in compliance with the License.
  • 006 *
  • 007 * You can obtain a copy of the license at
  • 008 * https://jaxp.dev.java.net/CDDLv1.0.html.
  • 009 * See the License for the specific language governing
  • 010 * permissions and limitations under the License.
  • 011 *
  • 012 * When distributing Covered Code, include this CDDL
  • 013 * HEADER in each file and include the License file at
  • 014 * https://jaxp.dev.java.net/CDDLv1.0.html
  • 015 * If applicable add the following below this CDDL HEADER
  • 016 * with the fields enclosed by brackets "[]" replaced with
  • 017 * your own identifying information: Portions Copyright
  • 018 * [year] [name of copyright owner]
  • 019 */
  • 020
  • 021/*
  • 022 * $Id: XMLEntityReader.java,v 1.3 2005/11/03 17:02:21 jeffsuttor Exp $
  • 023 * @(#)DOMSource.java 1.24 05/11/17
  • 024 *
  • 025 * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
  • 026 */
  • 027
  • 028package javax.xml.transform.dom;
  • 029
  • 030import javax.xml.transform.Source;
  • 031
  • 032import org.w3c.dom.Node;
  • 033
  • 034/**
  • 035 * <p>Acts as a holder for a transformation Source tree in the
  • 036 * form of a Document Object Model (DOM) tree.</p>
  • 037 *
  • 038 * <p>Note that XSLT requires namespace support. Attempting to transform a DOM
  • 039 * that was not contructed with a namespace-aware parser may result in errors.
  • 040 * Parsers can be made namespace aware by calling
  • 041 * {@link javax.xml.parsers.DocumentBuilderFactory#setNamespaceAware(boolean awareness)}.</p>
  • 042 *
  • 043 * @author <a href="Jeff.Suttor@Sun.com">Jeff Suttor</a>
  • 044 * @version $Revision: 1.2 $, $Date: 2005/06/10 03:50:40 $
  • 045 * @see <a href="http://www.w3.org/TR/DOM-Level-2">Document Object Model (DOM) Level 2 Specification</a>
  • 046 */
  • 047public class DOMSource implements Source {
  • 048
  • 049 /**
  • 050 * <p><code>Node</code> to serve as DOM source.</p>
  • 051 */
  • 052 private Node node;
  • 053
  • 054 /**
  • 055 * <p>The base ID (URL or system ID) from where URLs
  • 056 * will be resolved.</p>
  • 057 */
  • 058 private String systemID;
  • 059
  • 060 /** If {@link javax.xml.transform.TransformerFactory#getFeature}
  • 061 * returns true when passed this value as an argument,
  • 062 * the Transformer supports Source input of this type.
  • 063 */
  • 064 public static final String FEATURE =
  • 065 "http://javax.xml.transform.dom.DOMSource/feature";
  • 066
  • 067 /**
  • 068 * <p>Zero-argument default constructor. If this constructor is used, and
  • 069 * no DOM source is set using {@link #setNode(Node node)} , then the
  • 070 * <code>Transformer</code> will
  • 071 * create an empty source {@link org.w3c.dom.Document} using
  • 072 * {@link javax.xml.parsers.DocumentBuilder#newDocument()}.</p>
  • 073 *
  • 074 * @see javax.xml.transform.Transformer#transform(Source xmlSource, Result outputTarget)
  • 075 */
  • 076 public DOMSource() { }
  • 077
  • 078 /**
  • 079 * Create a new input source with a DOM node. The operation
  • 080 * will be applied to the subtree rooted at this node. In XSLT,
  • 081 * a "/" pattern still means the root of the tree (not the subtree),
  • 082 * and the evaluation of global variables and parameters is done
  • 083 * from the root node also.
  • 084 *
  • 085 * @param n The DOM node that will contain the Source tree.
  • 086 */
  • 087 public DOMSource(Node n) {
  • 088 setNode(n);
  • 089 }
  • 090
  • 091 /**
  • 092 * Create a new input source with a DOM node, and with the
  • 093 * system ID also passed in as the base URI.
  • 094 *
  • 095 * @param node The DOM node that will contain the Source tree.
  • 096 * @param systemID Specifies the base URI associated with node.
  • 097 */
  • 098 public DOMSource(Node node, String systemID) {
  • 099 setNode(node);
  • 100 setSystemId(systemID);
  • 101 }
  • 102
  • 103 /**
  • 104 * Set the node that will represents a Source DOM tree.
  • 105 *
  • 106 * @param node The node that is to be transformed.
  • 107 */
  • 108 public void setNode(Node node) {
  • 109 this.node = node;
  • 110 }
  • 111
  • 112 /**
  • 113 * Get the node that represents a Source DOM tree.
  • 114 *
  • 115 * @return The node that is to be transformed.
  • 116 */
  • 117 public Node getNode() {
  • 118 return node;
  • 119 }
  • 120
  • 121 /**
  • 122 * Set the base ID (URL or system ID) from where URLs
  • 123 * will be resolved.
  • 124 *
  • 125 * @param systemID Base URL for this DOM tree.
  • 126 */
  • 127 public void setSystemId(String systemID) {
  • 128 this.systemID = systemID;
  • 129 }
  • 130
  • 131 /**
  • 132 * Get the base ID (URL or system ID) from where URLs
  • 133 * will be resolved.
  • 134 *
  • 135 * @return Base URL for this DOM tree.
  • 136 */
  • 137 public String getSystemId() {
  • 138 return this.systemID;
  • 139 }
  • 140}

文件:DOMSource.java
包名:javax.xml.transform.dom
类名:DOMSource
继承:
接口:[Source]