1 16 19 package org.apache.xalan.xsltc.dom; 20 21 import org.apache.xalan.xsltc.DOM; 22 import org.apache.xalan.xsltc.DOMEnhancedForDTM; 23 import org.apache.xalan.xsltc.StripFilter; 24 import org.apache.xalan.xsltc.runtime.AbstractTranslet; 25 import org.apache.xalan.xsltc.runtime.Hashtable; 26 import org.apache.xml.dtm.DTM; 27 import org.apache.xml.dtm.DTMWSFilter; 28 29 34 public class DOMWSFilter implements DTMWSFilter { 35 36 private AbstractTranslet m_translet; 37 private StripFilter m_filter; 38 39 private Hashtable m_mappings; 41 42 private DTM m_currentDTM; 44 private short[] m_currentMapping; 45 46 56 public DOMWSFilter(AbstractTranslet translet) { 57 m_translet = translet; 58 m_mappings = new Hashtable(); 59 60 if (translet instanceof StripFilter) { 61 m_filter = (StripFilter) translet; 62 } 63 } 64 65 77 public short getShouldStripSpace(int node, DTM dtm) { 78 if (m_filter != null && dtm instanceof DOM) { 79 DOM dom = (DOM)dtm; 80 int type = 0; 81 82 if (dtm instanceof DOMEnhancedForDTM) { 83 DOMEnhancedForDTM mappableDOM = (DOMEnhancedForDTM)dtm; 84 85 short[] mapping; 86 if (dtm == m_currentDTM) { 87 mapping = m_currentMapping; 88 } 89 else { 90 mapping = (short[])m_mappings.get(dtm); 91 if (mapping == null) { 92 mapping = mappableDOM.getMapping( 93 m_translet.getNamesArray(), 94 m_translet.getUrisArray(), 95 m_translet.getTypesArray()); 96 m_mappings.put(dtm, mapping); 97 m_currentDTM = dtm; 98 m_currentMapping = mapping; 99 } 100 } 101 102 int expType = mappableDOM.getExpandedTypeID(node); 103 104 if (expType >= 0 && expType < mapping.length) 110 type = mapping[expType]; 111 else 112 type = -1; 113 114 } 115 else { 116 return INHERIT; 117 } 118 119 if (m_filter.stripSpace(dom, node, type)) { 120 return STRIP; 121 } else { 122 return NOTSTRIP; 123 } 124 } else { 125 return NOTSTRIP; 126 } 127 } 128 } 129 | Popular Tags |