1 package net.sf.saxon.om; 2 import net.sf.saxon.Configuration; 3 import net.sf.saxon.style.StandardNames; 4 import net.sf.saxon.pattern.NodeKindTest; 5 import net.sf.saxon.event.Stripper; 6 7 11 12 public class StrippedDocument extends StrippedNode implements DocumentInfo { 13 14 private Stripper stripper; 15 private boolean preservesSpace; 16 17 public StrippedDocument(DocumentInfo doc, Stripper stripper) { 18 this.node = doc; 19 this.parent = null; 20 this.docWrapper = this; 21 this.stripper = stripper; 22 preservesSpace = findPreserveSpace(doc); 23 } 24 25 28 29 public StrippedNode wrap(NodeInfo node) { 30 return makeWrapper(node, this, null); 31 } 32 33 36 37 public Stripper getStripper() { 38 return stripper; 39 } 40 41 44 45 public Configuration getConfiguration() { 46 return node.getConfiguration(); 47 } 48 49 52 53 public NamePool getNamePool() { 54 return node.getNamePool(); 55 } 56 57 60 61 public int getDocumentNumber() { 62 return node.getDocumentNumber(); 63 } 64 65 70 71 public NodeInfo selectID(String id) { 72 NodeInfo n = ((DocumentInfo)node).selectID(id); 73 if (n==null) { 74 return null; 75 } else { 76 return makeWrapper(n, this, null); 77 } 78 } 79 80 84 85 public String [] getUnparsedEntity(String name) { 86 return ((DocumentInfo)node).getUnparsedEntity(name); 87 } 88 89 95 96 private static boolean findPreserveSpace(DocumentInfo doc) { 97 AxisIterator iter = doc.iterateAxis(Axis.DESCENDANT, NodeKindTest.ELEMENT); 98 while (true) { 99 NodeInfo node = (NodeInfo)iter.next(); 100 if (node == null) { 101 return false; 102 } 103 String val = node.getAttributeValue(StandardNames.XML_SPACE); 104 if ("preserve".equals(val)) { 105 return true; 106 } 107 } 108 } 109 110 113 114 public boolean containsPreserveSpace() { 115 return preservesSpace; 116 } 117 118 119 } 120 121 | Popular Tags |