Package org.apache.xalan.xsltc

Examples of org.apache.xalan.xsltc.Translet


      if (_class == null) defineTransletClasses();

      // The translet needs to keep a reference to all its auxiliary
      // class to prevent the GC from collecting them
      Translet translet = (Translet) _class[_transletIndex].newInstance();
      final int classCount = _bytecodes.length;
      for (int i = 0; i < classCount; i++) {
    if (i != _transletIndex) {
        translet.addAuxiliaryClass(_class[i]);
    }
      }
      return translet;
  }
  catch (InstantiationException e) {
View Full Code Here


    private void doTransform() {
  try {
     
      final Class clazz = loadTranslet(_className);
      final Translet translet = (Translet)clazz.newInstance();

      // Create a SAX parser and get the XMLReader object it uses
      final SAXParserFactory factory = SAXParserFactory.newInstance();
      try {
    factory.setFeature(Constants.NAMESPACE_FEATURE,true);
      }
      catch (Exception e) {
    factory.setNamespaceAware(true);
      }
      final SAXParser parser = factory.newSAXParser();
      final XMLReader reader = parser.getXMLReader();

      // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
      final DOMImpl dom = new DOMImpl();
      DOMBuilder builder = dom.getBuilder();
      reader.setContentHandler(builder);

      try {
    String prop = "http://xml.org/sax/properties/lexical-handler";
    reader.setProperty(prop, builder);
      }
      catch (SAXException e) {
    // quitely ignored
      }
     
      // Create a DTD monitor and pass it to the XMLReader object
      final DTDMonitor dtdMonitor = new DTDMonitor(reader);
      AbstractTranslet _translet = (AbstractTranslet)translet;
      dom.setDocumentURI(_fileName);
      if (_uri)
    reader.parse(_fileName);
      else
    reader.parse(new File(_fileName).toURL().toExternalForm());

      builder = null;

      // If there are any elements with ID attributes, build an index
      dtdMonitor.buildIdIndex(dom, 0, _translet);
      // Pass unparsed entity descriptions to the translet
      _translet.setDTDMonitor(dtdMonitor);

      // Pass global parameters
      int n = _params.size();
      for (int i = 0; i < n; i++) {
    Parameter param = (Parameter) _params.elementAt(i);
    translet.addParameter(param._name, param._value);
      }

      // Transform the document
      TransletOutputHandlerFactory tohFactory =
    TransletOutputHandlerFactory.newInstance();
      tohFactory.setOutputType(TransletOutputHandlerFactory.STREAM);
      tohFactory.setEncoding(_translet._encoding);
      tohFactory.setOutputMethod(_translet._method);

      if (_iterations == -1) {
    translet.transform(dom, _useOldOutputSystem ?
          tohFactory.getOldTransletOutputHandler() :
          tohFactory.getTransletOutputHandler());
      }
      else if (_iterations > 0) {
    long mm = System.currentTimeMillis();
    for (int i = 0; i < _iterations; i++) {
        translet.transform(dom, _useOldOutputSystem ?
              tohFactory.getOldTransletOutputHandler() :
              tohFactory.getTransletOutputHandler());
    }
    mm = System.currentTimeMillis() - mm;
View Full Code Here

      if (_packageName != null)
          transletName = _packageName + "." + transletName;
         
      try {
          final Class clazz = loadTranslet(transletName);
          final Translet translet = (Translet)clazz.newInstance();             
          resetTransientAttributes();
             
          return new TemplatesImpl(translet, transletName, null, _indentNumber, this);
      }
      catch (ClassNotFoundException cnfe) {
View Full Code Here

      if (_class == null) defineTransletClasses();

      // The translet needs to keep a reference to all its auxiliary
      // class to prevent the GC from collecting them
      Translet translet = (Translet) _class[_transletIndex].newInstance();
      final int classCount = _bytecodes.length;
      for (int i = 0; i < classCount; i++) {
    if (i != _transletIndex) {
        translet.addAuxiliaryClass(_class[i]);
    }
      }
      return translet;
  }
  catch (InstantiationException e) {
View Full Code Here

    private void doTransform() {
  try {
     
      final Class clazz = loadTranslet(_className);
      final Translet translet = (Translet)clazz.newInstance();

      // Create a SAX parser and get the XMLReader object it uses
      final SAXParserFactory factory = SAXParserFactory.newInstance();
      try {
    factory.setFeature(Constants.NAMESPACE_FEATURE,true);
      }
      catch (Exception e) {
    factory.setNamespaceAware(true);
      }
      final SAXParser parser = factory.newSAXParser();
      final XMLReader reader = parser.getXMLReader();

      // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
      final DOMImpl dom = new DOMImpl();
      DOMBuilder builder = dom.getBuilder();
      reader.setContentHandler(builder);

      try {
    String prop = "http://xml.org/sax/properties/lexical-handler";
    reader.setProperty(prop, builder);
      }
      catch (SAXException e) {
    // quitely ignored
      }
     
      // Create a DTD monitor and pass it to the XMLReader object
      final DTDMonitor dtdMonitor = new DTDMonitor(reader);
      AbstractTranslet _translet = (AbstractTranslet)translet;
      dom.setDocumentURI(_fileName);
      if (_uri)
    reader.parse(_fileName);
      else
    reader.parse(new File(_fileName).toURL().toExternalForm());

      builder = null;

      // If there are any elements with ID attributes, build an index
      dtdMonitor.buildIdIndex(dom, 0, _translet);
      // Pass unparsed entity descriptions to the translet
      _translet.setDTDMonitor(dtdMonitor);

      // Pass global parameters
      int n = _params.size();
      for (int i = 0; i < n; i++) {
    Parameter param = (Parameter) _params.elementAt(i);
    translet.addParameter(param._name, param._value);
      }

      // Transform the document
      TransletOutputHandlerFactory tohFactory =
    TransletOutputHandlerFactory.newInstance();
      tohFactory.setOutputType(TransletOutputHandlerFactory.STREAM);
      tohFactory.setEncoding(_translet._encoding);
      tohFactory.setOutputMethod(_translet._method);

      if (_iterations == -1) {
    translet.transform(dom, _useOldOutputSystem ?
          tohFactory.getOldTransletOutputHandler() :
          tohFactory.getTransletOutputHandler());
      }
      else if (_iterations > 0) {
    long mm = System.currentTimeMillis();
    for (int i = 0; i < _iterations; i++) {
        translet.transform(dom, _useOldOutputSystem ?
              tohFactory.getOldTransletOutputHandler() :
              tohFactory.getTransletOutputHandler());
    }
    mm = System.currentTimeMillis() - mm;
View Full Code Here

      if (_class == null) defineTransletClasses();

      // The translet needs to keep a reference to all its auxiliary
      // class to prevent the GC from collecting them
      Translet translet = (Translet) _class[_transletIndex].newInstance();
      final int classCount = _class.length;
      for (int i = 0; i < classCount; i++) {
    if (i != _transletIndex) {
        translet.addAuxiliaryClass(_class[i]);
    }
      }
      return translet;
  }
  catch (InstantiationException e) {
View Full Code Here

      // The translet needs a reference to all its auxiliary class
      // definitions so that it can instanciate them on the fly. You
      // wouldn't think this is necessary, but it seems like the JVM
      // quickly forgets the classes we define here and the translet
      // needs to know them as long as it exists.
      Translet translet = (Translet)_class[_transletIndex].newInstance();
      final int classCount = _bytecodes.length;
      for (int i = 0; i < classCount; i++) {
    if (i != _transletIndex)
        translet.addAuxiliaryClass(_class[i]);
      }
      return translet;
  }
  catch (InstantiationException e) {
      ErrorMsg err = new ErrorMsg(ErrorMsg.TRANSLET_OBJECT_ERR+_name);
View Full Code Here

    private void doTransform() {
  try {
     
      final Class clazz = loadTranslet(_className);
      final Translet translet = (Translet)clazz.newInstance();

      // Create a SAX parser and get the XMLReader object it uses
      final SAXParserFactory factory = SAXParserFactory.newInstance();
      try {
    factory.setFeature(Constants.NAMESPACE_FEATURE,true);
      }
      catch (Exception e) {
    factory.setNamespaceAware(true);
      }
      final SAXParser parser = factory.newSAXParser();
      final XMLReader reader = parser.getXMLReader();

      // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
      final DOMImpl dom = new DOMImpl();
      DOMBuilder builder = dom.getBuilder();
      reader.setContentHandler(builder);

      try {
    String prop = "http://xml.org/sax/properties/lexical-handler";
    reader.setProperty(prop, builder);
      }
      catch (SAXException e) {
    // quitely ignored
      }
     
      // Create a DTD monitor and pass it to the XMLReader object
      final DTDMonitor dtdMonitor = new DTDMonitor(reader);
      AbstractTranslet _translet = (AbstractTranslet)translet;
      dom.setDocumentURI(_fileName);
      if (_uri)
    reader.parse(_fileName);
      else
    reader.parse(new File(_fileName).toURL().toExternalForm());

      builder = null;

      // If there are any elements with ID attributes, build an index
      dtdMonitor.buildIdIndex(dom, 0, _translet);
      // Pass unparsed entity descriptions to the translet
      _translet.setDTDMonitor(dtdMonitor);

      // Pass global parameters
      int n = _params.size();
      for (int i = 0; i < n; i++) {
    Parameter param = (Parameter) _params.elementAt(i);
    translet.addParameter(param._name, param._value);
      }

      // Transform the document
      String encoding = _translet._encoding;

      // Create our default SAX/DTD handler
      DefaultSAXOutputHandler saxHandler =
    new DefaultSAXOutputHandler(System.out, encoding);
      // Create a translet output handler and plug in the SAX/DTD handler
      TextOutput textOutput =
    new TextOutput((ContentHandler)saxHandler,
             (LexicalHandler)saxHandler, encoding);

      // Transform and pass output to the translet output handler
      translet.transform(dom, textOutput);
  }
  catch (TransletException e) {
      if (_debug) e.printStackTrace();
      System.err.println(ErrorMsg.getTransletErrorMessage()+
             e.getMessage());
View Full Code Here

      if (_class == null) defineTransletClasses();

      // The translet needs to keep a reference to all its auxiliary
      // class to prevent the GC from collecting them
      Translet translet = (Translet) _class[_transletIndex].newInstance();
      final int classCount = _bytecodes.length;
      for (int i = 0; i < classCount; i++) {
    if (i != _transletIndex) {
        translet.addAuxiliaryClass(_class[i]);
    }
      }
      return translet;
  }
  catch (InstantiationException e) {
View Full Code Here

    private void doTransform() {
  try {
     
      final Class clazz = loadTranslet(_className);
      final Translet translet = (Translet)clazz.newInstance();

      // Create a SAX parser and get the XMLReader object it uses
      final SAXParserFactory factory = SAXParserFactory.newInstance();
      try {
    factory.setFeature(Constants.NAMESPACE_FEATURE,true);
      }
      catch (Exception e) {
    factory.setNamespaceAware(true);
      }
      final SAXParser parser = factory.newSAXParser();
      final XMLReader reader = parser.getXMLReader();

      // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
      final DOMImpl dom = new DOMImpl();
      DOMBuilder builder = dom.getBuilder();
      reader.setContentHandler(builder);

      try {
    String prop = "http://xml.org/sax/properties/lexical-handler";
    reader.setProperty(prop, builder);
      }
      catch (SAXException e) {
    // quitely ignored
      }
     
      // Create a DTD monitor and pass it to the XMLReader object
      final DTDMonitor dtdMonitor = new DTDMonitor(reader);
      AbstractTranslet _translet = (AbstractTranslet)translet;
      dom.setDocumentURI(_fileName);
      if (_uri)
    reader.parse(_fileName);
      else
    reader.parse(new File(_fileName).toURL().toExternalForm());

      builder = null;

      // If there are any elements with ID attributes, build an index
      dtdMonitor.buildIdIndex(dom, 0, _translet);
      // Pass unparsed entity descriptions to the translet
      _translet.setDTDMonitor(dtdMonitor);

      // Pass global parameters
      int n = _params.size();
      for (int i = 0; i < n; i++) {
    Parameter param = (Parameter) _params.elementAt(i);
    translet.addParameter(param._name, param._value);
      }

      // Transform the document
      TransletOutputHandlerFactory tohFactory =
    TransletOutputHandlerFactory.newInstance();
      tohFactory.setOutputType(TransletOutputHandlerFactory.STREAM);
      tohFactory.setEncoding(_translet._encoding);
      tohFactory.setOutputMethod(_translet._method);

      if (_iterations == -1) {
    translet.transform(dom, _useOldOutputSystem ?
          tohFactory.getOldTransletOutputHandler() :
          tohFactory.getTransletOutputHandler());
      }
      else if (_iterations > 0) {
    long mm = System.currentTimeMillis();
    for (int i = 0; i < _iterations; i++) {
        translet.transform(dom, _useOldOutputSystem ?
              tohFactory.getOldTransletOutputHandler() :
              tohFactory.getTransletOutputHandler());
    }
    mm = System.currentTimeMillis() - mm;
View Full Code Here

TOP

Related Classes of org.apache.xalan.xsltc.Translet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.