001: package net.sf.saxon.pull;
002:
003: import net.sf.saxon.expr.XPathContext;
004: import net.sf.saxon.instruct.DocumentInstr;
005: import net.sf.saxon.om.DocumentInfo;
006: import net.sf.saxon.om.NodeInfo;
007: import net.sf.saxon.type.Type;
008:
009: /**
010: * A document node whose construction is deferred.
011: * </p>
012: * (TODO) NOTE: this class is an exception to the general rule that for document nodes, node identity implies object identity
013: */
014:
015: public class UnconstructedDocument extends UnconstructedParent
016: implements DocumentInfo {
017:
018: public UnconstructedDocument(DocumentInstr instruction,
019: XPathContext context) {
020: super (instruction, context);
021: }
022:
023: /**
024: * Get name code. The name code is a coded form of the node name: two nodes
025: * with the same name code have the same namespace URI, the same local name,
026: * and the same prefix. By masking the name code with &0xfffff, you get a
027: * fingerprint: two nodes with the same fingerprint have the same local name
028: * and namespace URI.
029: *
030: * @return an integer name code, which may be used to obtain the actual node
031: * name from the name pool
032: * @see net.sf.saxon.om.NamePool#allocate allocate
033: * @see net.sf.saxon.om.NamePool#getFingerprint getFingerprint
034: */
035:
036: public int getNameCode() {
037: return -1;
038: }
039:
040: public int getNodeKind() {
041: return Type.DOCUMENT;
042: }
043:
044: /**
045: * Get fingerprint. The fingerprint is a coded form of the expanded name
046: * of the node: two nodes
047: * with the same name code have the same namespace URI and the same local name.
048: * A fingerprint of -1 should be returned for a node with no name.
049: *
050: * @return an integer fingerprint; two nodes with the same fingerprint have
051: * the same expanded QName
052: */
053:
054: public int getFingerprint() {
055: return -1;
056: }
057:
058: /**
059: * Get the local part of the name of this node. This is the name after the ":" if any.
060: *
061: * @return the local part of the name. For an unnamed node, returns "". Unlike the DOM
062: * interface, this returns the full name in the case of a non-namespaced name.
063: */
064:
065: public String getLocalPart() {
066: return "";
067: }
068:
069: /**
070: * Get the URI part of the name of this node. This is the URI corresponding to the
071: * prefix, or the URI of the default namespace if appropriate.
072: *
073: * @return The URI of the namespace of this node. For an unnamed node,
074: * or for a node with an empty prefix, return an empty
075: * string.
076: */
077:
078: public String getURI() {
079: return "";
080: }
081:
082: /**
083: * Get the display name of this node. For elements and attributes this is [prefix:]localname.
084: * For unnamed nodes, it is an empty string.
085: *
086: * @return The display name of this node. For a node with no name, return
087: * an empty string.
088: */
089:
090: public String getDisplayName() {
091: return "";
092: }
093:
094: /**
095: * Get the prefix of the name of the node. This is defined only for elements and attributes.
096: * If the node has no prefix, or for other kinds of node, return a zero-length string.
097: *
098: * @return The prefix of the name of the node.
099: */
100:
101: public String getPrefix() {
102: return "";
103: }
104:
105: /**
106: * Get the root node, if it is a document node.
107: *
108: * @return the DocumentInfo representing the containing document. If this
109: * node is part of a tree that does not have a document node as its
110: * root, return null.
111: */
112:
113: public DocumentInfo getDocumentRoot() {
114: return this ;
115: }
116:
117: /**
118: * Get the element with a given ID, if any
119: *
120: * @param id the required ID value
121: * @return the element with the given ID, or null if there is no such ID
122: * present (or if the parser has not notified attributes as being of
123: * type ID)
124: * @since 8.4
125: */
126:
127: public NodeInfo selectID(String id) {
128: if (node == null) {
129: tryToConstruct();
130: }
131: return ((DocumentInfo) node).selectID(id);
132: }
133:
134: /**
135: * Get the unparsed entity with a given name
136: *
137: * @param name the name of the entity
138: * @return if the entity exists, return an array of two Strings, the first
139: * holding the system ID of the entity, the second holding the public
140: * ID if there is one, or null if not. If the entity does not exist,
141: * the method returns null. Applications should be written on the
142: * assumption that this array may be extended in the future to provide
143: * additional information.
144: * @since 8.4
145: */
146:
147: public String[] getUnparsedEntity(String name) {
148: return null;
149: }
150:
151: }
|