Debian Codegraph @

net/sf/saxon/tree/wrapper/TypeStrippedDocument.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.tree.wrapper;
9
10 import net.sf.saxon.om.GenericTreeInfo;
11 import net.sf.saxon.om.NodeInfo;
12 import net.sf.saxon.om.TreeInfo;
13
14
15 /**
16 * A TypeStrippedDocument represents a view of a real Document in which all nodes are
17 * untyped
18 */
19
20 public class TypeStrippedDocument extends GenericTreeInfo {
21
22 TreeInfo underlyingTree;
23
24 /**
25 * Create a type-stripped view of a document
26 *
27 * @param doc the underlying document
28 */
29
30 public TypeStrippedDocument(TreeInfo doc) {
31 super(doc.getConfiguration());
32 setRootNode(wrap(doc.getRootNode()));
33 this.underlyingTree = doc;
34 }
35
36 /**
37 * Create a wrapped node within this document
38 */
39
40 public TypeStrippedNode wrap(NodeInfo node) {
41 return TypeStrippedNode.makeWrapper(node, this, null);
42 }
43
44
45 /**
46 * Ask whether the document contains any nodes whose type annotation is anything other than
47 * UNTYPED
48 *
49 * @return true if the document contains elements whose type is other than UNTYPED
50 */
51 public boolean isTyped() {
52 return false;
53 }
54
55 /**
56 * Get the element with a given ID, if any
57 *
58 * @param id the required ID value
59 * @param getParent
60 * @return the element with the given ID value, or null if there is none.
61 */
62
63 /*@Nullable*/
64 public NodeInfo selectID(String id, boolean getParent) {
65 NodeInfo n = underlyingTree.selectID(id, false);
66 if (n == null) {
67 return null;
68 } else {
69 return wrap(n);
70 }
71 }
72
73 }
74