KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > transform > dom > DOMSource


1 // $Id: DOMSource.java,v 1.5.14.1.2.2 2004/07/13 22:27:49 jsuttor Exp $
2
/*
3  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
4  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
5  */

6
7 /*
8  * @(#)DOMSource.java 1.16 04/07/13
9  */

10 package javax.xml.transform.dom;
11
12 import javax.xml.transform.Source JavaDoc;
13
14 import org.w3c.dom.Node JavaDoc;
15
16 /**
17  * <p>Acts as a holder for a transformation Source tree in the
18  * form of a Document Object Model (DOM) tree.</p>
19  *
20  * <p>Note that XSLT requires namespace support. Attempting to transform a DOM
21  * that was not contructed with a namespace-aware parser may result in errors.
22  * Parsers can be made namespace aware by calling
23  * {@link javax.xml.parsers.DocumentBuilderFactory#setNamespaceAware(boolean awareness)}.</p>
24  *
25  * @author <a HREF="Jeff.Suttor@Sun.com">Jeff Suttor</a>
26  * @version $Revision: 1.5.14.1.2.2 $, $Date: 2004/07/13 22:27:49 $
27  * @see <a HREF="http://www.w3.org/TR/DOM-Level-2">Document Object Model (DOM) Level 2 Specification</a>
28  */

29 public class DOMSource implements Source JavaDoc {
30
31     /**
32      * <p><code>Node</code> to serve as DOM source.</p>
33      */

34     private Node JavaDoc node;
35
36     /**
37      * <p>The base ID (URL or system ID) from where URLs
38      * will be resolved.</p>
39      */

40     private String JavaDoc systemID;
41
42     /** If {@link javax.xml.transform.TransformerFactory#getFeature}
43      * returns true when passed this value as an argument,
44      * the Transformer supports Source input of this type.
45      */

46     public static final String JavaDoc FEATURE =
47         "http://javax.xml.transform.dom.DOMSource/feature";
48
49     /**
50      * <p>Zero-argument default constructor. If this constructor is used, and
51      * no DOM source is set using {@link #setNode(Node node)} , then the
52      * <code>Transformer</code> will
53      * create an empty source {@link org.w3c.dom.Document} using
54      * {@link javax.xml.parsers.DocumentBuilder#newDocument()}.</p>
55      *
56      * @see javax.xml.transform.Transformer#transform(Source xmlSource, Result outputTarget)
57      */

58     public DOMSource() { }
59
60     /**
61      * Create a new input source with a DOM node. The operation
62      * will be applied to the subtree rooted at this node. In XSLT,
63      * a "/" pattern still means the root of the tree (not the subtree),
64      * and the evaluation of global variables and parameters is done
65      * from the root node also.
66      *
67      * @param n The DOM node that will contain the Source tree.
68      */

69     public DOMSource(Node JavaDoc n) {
70         setNode(n);
71     }
72
73     /**
74      * Create a new input source with a DOM node, and with the
75      * system ID also passed in as the base URI.
76      *
77      * @param node The DOM node that will contain the Source tree.
78      * @param systemID Specifies the base URI associated with node.
79      */

80     public DOMSource(Node JavaDoc node, String JavaDoc systemID) {
81         setNode(node);
82         setSystemId(systemID);
83     }
84
85     /**
86      * Set the node that will represents a Source DOM tree.
87      *
88      * @param node The node that is to be transformed.
89      */

90     public void setNode(Node JavaDoc node) {
91         this.node = node;
92     }
93
94     /**
95      * Get the node that represents a Source DOM tree.
96      *
97      * @return The node that is to be transformed.
98      */

99     public Node JavaDoc getNode() {
100         return node;
101     }
102
103     /**
104      * Set the base ID (URL or system ID) from where URLs
105      * will be resolved.
106      *
107      * @param systemID Base URL for this DOM tree.
108      */

109     public void setSystemId(String JavaDoc systemID) {
110         this.systemID = systemID;
111     }
112
113     /**
114      * Get the base ID (URL or system ID) from where URLs
115      * will be resolved.
116      *
117      * @return Base URL for this DOM tree.
118      */

119     public String JavaDoc getSystemId() {
120         return this.systemID;
121     }
122 }
123
Popular Tags