コード例 #1
0
 /*     */ private final void buildIDIndex(DOM document) /*     */ {
   /* 322 */ setRootForKeys(document.getDocument());
   /*     */
   /* 324 */ if ((document instanceof DOMEnhancedForDTM)) {
     /* 325 */ DOMEnhancedForDTM enhancedDOM = (DOMEnhancedForDTM) document;
     /*     */
     /* 330 */ if (enhancedDOM.hasDOMSource()) {
       /* 331 */ buildKeyIndex("##id", document);
       /* 332 */ return;
       /*     */ }
     /*     */
     /* 335 */ Hashtable elementsByID = enhancedDOM.getElementsWithIDs();
     /*     */
     /* 337 */ if (elementsByID == null) {
       /* 338 */ return;
       /*     */ }
     /*     */
     /* 344 */ Enumeration idValues = elementsByID.keys();
     /* 345 */ boolean hasIDValues = false;
     /*     */
     /* 347 */ while (idValues.hasMoreElements()) {
       /* 348 */ Object idValue = idValues.nextElement();
       /* 349 */ int element =
           document.getNodeHandle(((Integer) elementsByID.get(idValue)).intValue());
       /*     */
       /* 354 */ buildKeyIndex("##id", element, idValue);
       /* 355 */ hasIDValues = true;
       /*     */ }
     /*     */
     /* 358 */ if (hasIDValues) /* 359 */ setKeyIndexDom("##id", document);
     /*     */ }
   /*     */ }
コード例 #2
0
 public String shallowCopy(final int node, SerializationHandler handler) throws TransletException {
   if (_enhancedDOM != null) {
     return _enhancedDOM.shallowCopy(node, handler);
   } else {
     return _dom.shallowCopy(node, handler);
   }
 }
コード例 #3
0
 /** Return a instance of a DOM class to be used as an RTF */
 public DOM getResultTreeFrag(int initSize, int rtfType) {
   if (_enhancedDOM != null) {
     return _enhancedDOM.getResultTreeFrag(initSize, rtfType);
   } else {
     return _dom.getResultTreeFrag(initSize, rtfType);
   }
 }
コード例 #4
0
 public DTMAxisIterator getAxisIterator(final int axis) {
   if (_enhancedDOM != null) {
     return _enhancedDOM.getAxisIterator(axis);
   } else {
     return _dom.getAxisIterator(axis);
   }
 }
コード例 #5
0
 /** Return a instance of a DOM class to be used as an RTF */
 public DOM getResultTreeFrag(int initSize, int rtfType, boolean addToManager) {
   if (_enhancedDOM != null) {
     return _enhancedDOM.getResultTreeFrag(initSize, rtfType, addToManager);
   } else {
     return _dom.getResultTreeFrag(initSize, rtfType, addToManager);
   }
 }
コード例 #6
0
 public String getDocumentURI() {
   if (_enhancedDOM != null) {
     return _enhancedDOM.getDocumentURI();
   } else {
     return "";
   }
 }
コード例 #7
0
 public void characters(final int textNode, SerializationHandler handler)
     throws TransletException {
   if (_enhancedDOM != null) {
     _enhancedDOM.characters(textNode, handler);
   } else {
     _dom.characters(textNode, handler);
   }
 }
コード例 #8
0
 private int[] getReverse() {
   if (_reverse == null) {
     if (_enhancedDOM != null) {
       _reverse = _enhancedDOM.getReverseMapping(_namesArray, _urisArray, _typesArray);
     }
   }
   return _reverse;
 }
コード例 #9
0
 public DTMAxisIterator getTypedAxisIterator(final int axis, final int type) {
   final int[] reverse = getReverse();
   if (_enhancedDOM != null) {
     return _enhancedDOM.getTypedAxisIterator(axis, reverse[type]);
   } else {
     return _dom.getTypedAxisIterator(axis, type);
   }
 }
コード例 #10
0
 public DTMAxisIterator getChildren(final int node) {
   if (_enhancedDOM != null) {
     return _enhancedDOM.getChildren(node);
   } else {
     DTMAxisIterator iterator = _dom.getChildren(node);
     return iterator.setStartNode(node);
   }
 }
コード例 #11
0
 private short[] getNSReverse() {
   if (_NSreverse == null) {
     if (_enhancedDOM != null) {
       _NSreverse = _enhancedDOM.getReverseNamespaceMapping(_namespaceArray);
     }
   }
   return _NSreverse;
 }
コード例 #12
0
 private short[] getNSMapping() {
   if (_NSmapping == null) {
     if (_enhancedDOM != null) {
       _NSmapping = _enhancedDOM.getNamespaceMapping(_namespaceArray);
     }
   }
   return _NSmapping;
 }
コード例 #13
0
 private short[] getMapping() {
   if (_mapping == null) {
     if (_enhancedDOM != null) {
       _mapping = _enhancedDOM.getMapping(_namesArray, _urisArray, _typesArray);
     }
   }
   return _mapping;
 }
コード例 #14
0
  public DTMAxisIterator getTypedChildren(final int type) {
    final int[] reverse = getReverse();

    if (_enhancedDOM != null) {
      return _enhancedDOM.getTypedChildren(reverse[type]);
    } else {
      return _dom.getTypedChildren(type);
    }
  }
コード例 #15
0
 public String getStringValueX(final int node) {
   if (_enhancedDOM != null) {
     return _enhancedDOM.getStringValueX(node);
   } else {
     if (node == DTM.NULL) {
       return "";
     }
     return _dom.getStringValueX(node);
   }
 }
コード例 #16
0
 public int getExpandedTypeID(final int node) {
   final short[] mapping = getMapping();
   final int type;
   if (_enhancedDOM != null) {
     type = mapping[_enhancedDOM.getExpandedTypeID2(node)];
   } else {
     if (null != mapping) {
       type = mapping[_dom.getExpandedTypeID(node)];
     } else {
       type = _dom.getExpandedTypeID(node);
     }
   }
   return type;
 }
コード例 #17
0
 /*     */ private void doTransform() {
   /*     */ try {
     /* 101 */ Class clazz = ObjectFactory.findProviderClass(this._className, true);
     /* 102 */ AbstractTranslet translet = (AbstractTranslet) clazz.newInstance();
     /* 103 */ translet.postInitialization();
     /*     */
     /* 106 */ SAXParserFactory factory = SAXParserFactory.newInstance();
     /*     */ try {
       /* 108 */ factory.setFeature("http://xml.org/sax/features/namespaces", true);
       /*     */ }
     /*     */ catch (Exception e) {
       /* 111 */ factory.setNamespaceAware(true);
       /*     */ }
     /* 113 */ SAXParser parser = factory.newSAXParser();
     /* 114 */ XMLReader reader = parser.getXMLReader();
     /*     */
     /* 117 */ XSLTCDTMManager dtmManager =
         (XSLTCDTMManager) XSLTCDTMManager.getDTMManagerClass().newInstance();
     /*     */ DTMWSFilter wsfilter;
     /*     */ DTMWSFilter wsfilter;
     /* 122 */ if ((translet != null) && ((translet instanceof StripFilter)))
       /* 123 */ wsfilter = new DOMWSFilter(translet);
     /*     */ else {
       /* 125 */ wsfilter = null;
       /*     */ }
     /*     */
     /* 128 */ DOMEnhancedForDTM dom =
         (DOMEnhancedForDTM)
             dtmManager.getDTM(
                 new SAXSource(reader, new InputSource(this._fileName)),
                 false,
                 wsfilter,
                 true,
                 false,
                 translet.hasIdCall());
     /*     */
     /* 133 */ dom.setDocumentURI(this._fileName);
     /* 134 */ translet.prepassDocument(dom);
     /*     */
     /* 137 */ int n = this._params.size();
     /* 138 */ for (int i = 0; i < n; i++) {
       /* 139 */ Parameter param = (Parameter) this._params.elementAt(i);
       /* 140 */ translet.addParameter(param._name, param._value);
       /*     */ }
     /*     */
     /* 144 */ TransletOutputHandlerFactory tohFactory =
         TransletOutputHandlerFactory.newInstance();
     /*     */
     /* 146 */ tohFactory.setOutputType(0);
     /* 147 */ tohFactory.setEncoding(translet._encoding);
     /* 148 */ tohFactory.setOutputMethod(translet._method);
     /*     */
     /* 150 */ if (this._iterations == -1) {
       /* 151 */ translet.transform(dom, tohFactory.getSerializationHandler());
       /*     */ }
     /* 153 */ else if (this._iterations > 0) {
       /* 154 */ long mm = System.currentTimeMillis();
       /* 155 */ for (int i = 0; i < this._iterations; i++) {
         /* 156 */ translet.transform(dom, tohFactory.getSerializationHandler());
         /*     */ }
       /*     */
       /* 159 */ mm = System.currentTimeMillis() - mm;
       /*     */
       /* 161 */ System.err.println("\n<!--");
       /* 162 */ System.err.println("  transform  = " + mm / this._iterations + " ms");
       /*     */
       /* 165 */ System.err.println(
           "  throughput = " + 1000.0D / (mm / this._iterations) + " tps");
       /*     */
       /* 169 */ System.err.println("-->");
       /*     */ }
     /*     */ }
   /*     */ catch (TransletException e) {
     /* 173 */ if (this._debug) e.printStackTrace();
     /* 174 */ System.err.println(new ErrorMsg("RUNTIME_ERROR_KEY") + e.getMessage());
     /*     */ }
   /*     */ catch (RuntimeException e)
   /*     */ {
     /* 178 */ if (this._debug) e.printStackTrace();
     /* 179 */ System.err.println(new ErrorMsg("RUNTIME_ERROR_KEY") + e.getMessage());
     /*     */ }
   /*     */ catch (FileNotFoundException e)
   /*     */ {
     /* 183 */ if (this._debug) e.printStackTrace();
     /* 184 */ ErrorMsg err = new ErrorMsg("FILE_NOT_FOUND_ERR", this._fileName);
     /* 185 */ System.err.println(new ErrorMsg("RUNTIME_ERROR_KEY") + err.toString());
     /*     */ }
   /*     */ catch (MalformedURLException e)
   /*     */ {
     /* 189 */ if (this._debug) e.printStackTrace();
     /* 190 */ ErrorMsg err = new ErrorMsg("INVALID_URI_ERR", this._fileName);
     /* 191 */ System.err.println(new ErrorMsg("RUNTIME_ERROR_KEY") + err.toString());
     /*     */ }
   /*     */ catch (ClassNotFoundException e)
   /*     */ {
     /* 195 */ if (this._debug) e.printStackTrace();
     /* 196 */ ErrorMsg err = new ErrorMsg("CLASS_NOT_FOUND_ERR", this._className);
     /* 197 */ System.err.println(new ErrorMsg("RUNTIME_ERROR_KEY") + err.toString());
     /*     */ }
   /*     */ catch (UnknownHostException e)
   /*     */ {
     /* 201 */ if (this._debug) e.printStackTrace();
     /* 202 */ ErrorMsg err = new ErrorMsg("INVALID_URI_ERR", this._fileName);
     /* 203 */ System.err.println(new ErrorMsg("RUNTIME_ERROR_KEY") + err.toString());
     /*     */ }
   /*     */ catch (SAXException e)
   /*     */ {
     /* 207 */ Exception ex = e.getException();
     /* 208 */ if (this._debug) {
       /* 209 */ if (ex != null) ex.printStackTrace();
       /* 210 */ e.printStackTrace();
       /*     */ }
     /* 212 */ System.err.print(new ErrorMsg("RUNTIME_ERROR_KEY"));
     /* 213 */ if (ex != null) /* 214 */ System.err.println(ex.getMessage());
     /*     */ else /* 216 */ System.err.println(e.getMessage());
     /*     */ }
   /*     */ catch (Exception e) {
     /* 219 */ if (this._debug) e.printStackTrace();
     /* 220 */ System.err.println(new ErrorMsg("RUNTIME_ERROR_KEY") + e.getMessage());
     /*     */ }
   /*     */ }
コード例 #18
0
 public void setDocumentURI(String uri) {
   if (_enhancedDOM != null) {
     _enhancedDOM.setDocumentURI(uri);
   }
 }