Package org.apache.xalan.xsltc.dom

Examples of org.apache.xalan.xsltc.dom.DOMImpl


    AbstractTranslet translet =
        (AbstractTranslet)transletClass.newInstance();
    translet.setDOMCache(cache);

    // Get the DOM from the DOM cache
    DOMImpl dom = cache.retrieveDocument(document, 0, translet);

    if (dom == null) {
        errorMessage("Could not locate: \"<b>"+document+"\"</b>");
    }
    else {
View Full Code Here


    // Set the document cache for the translet. This is needed in
    // case the translet uses the document() function.
    translet.setDOMCache(cache);

    // Read input document from the DOM cache
    DOMImpl dom = cache.retrieveDocument(documentURI, 0, translet);

    // Create output handler
    TransletOutputHandlerFactory tohFactory =
        TransletOutputHandlerFactory.newInstance();
    tohFactory.setOutputType(TransletOutputHandlerFactory.STREAM);
View Full Code Here

     */
    private DOMImpl getDOM(Source source, int mask)
  throws TransformerException
    {
  try {
      DOMImpl dom = null;
      DTDMonitor dtd = null;

      // Get systemId from source
      if (source != null) {
    _sourceSystemId = source.getSystemId();
      }

      if (source instanceof SAXSource) {
    // Get all info from the input SAXSource object
    final SAXSource sax = (SAXSource)source;
    XMLReader reader = sax.getXMLReader();
    final InputSource input = sax.getInputSource();

    // Create a reader if not set by user
    if (reader == null) {
        reader = _tfactory.getXMLReader();
    }

    // Create a DTD monitor to trap all DTD/declarative events
    dtd = new DTDMonitor();
    dtd.handleDTD(reader);

    // Create a new internal DOM and set up its builder
    dom = new DOMImpl();
    final DOMBuilder builder = dom.getBuilder();
    try {
        reader.setProperty(LEXICAL_HANDLER_PROPERTY, builder);
    }
    catch (SAXException e) {
        // quitely ignored
    }
    reader.setContentHandler(builder);

    // Parse the input and build the internal DOM
    reader.parse(input);
    dom.setDocumentURI(_sourceSystemId);
      }
      else if (source instanceof DOMSource) {
    final DOMSource domsrc = (DOMSource) source;
    final org.w3c.dom.Node node = domsrc.getNode();
    final DOM2SAX dom2sax = new DOM2SAX(node);

    // Create a DTD monitor to trap all DTD/declarative events
    dtd = new DTDMonitor();
    dtd.handleDTD(dom2sax);

    // Create a new internal DOM and set up its builder to trap
    // all content/lexical events
    dom = new DOMImpl();
    final DOMBuilder builder = dom.getBuilder();
    dom2sax.setContentHandler(builder);

    // Parse the input and build the internal DOM
    dom2sax.parse();
    dom.setDocumentURI(_sourceSystemId);
      }
      else if (source instanceof StreamSource) {
    // Get all info from the input StreamSource object
    final StreamSource stream = (StreamSource)source;
    final InputStream streamInput = stream.getInputStream();
    final Reader streamReader = stream.getReader();
    final XMLReader reader = _tfactory.getXMLReader();

    // Create a DTD monitor to trap all DTD/declarative events
    dtd = new DTDMonitor();
    dtd.handleDTD(reader);

    // Create a new internal DOM and set up its builder to trap
    // all content/lexical events
    dom = new DOMImpl();
    final DOMBuilder builder = dom.getBuilder();
    try {
        reader.setProperty(LEXICAL_HANDLER_PROPERTY, builder);
    }
    catch (SAXException e) {
        // quitely ignored
    }
    reader.setContentHandler(builder);

    InputSource input;
    if (streamInput != null) {
        input = new InputSource(streamInput);
        input.setSystemId(_sourceSystemId);
    }
    else if (streamReader != null) {
        input = new InputSource(streamReader);
        input.setSystemId(_sourceSystemId);
    }
    else if (_sourceSystemId != null) {
        input = new InputSource(_sourceSystemId);
    }
    else {
        ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_SOURCE_ERR);
        throw new TransformerException(err.toString());
    }

    // Parse the input and build the internal DOM
    reader.parse(input);
    dom.setDocumentURI(_sourceSystemId);
      }
      else if (source instanceof XSLTCSource) {
    final XSLTCSource xsltcsrc = (XSLTCSource)source;
    dtd = xsltcsrc.getDTD();
    dom = xsltcsrc.getDOM();
      }
      // DOM already set via a call to setDOM()
      else if (_dom != null) {
    dtd = _dtdMonitor;     // must be set via setDTDMonitor()
    dom = _dom; _dom = null;   // use only once, so reset to 'null'
      }
      else {
    return null;
      }

      // Set size of key/id indices
      if (!_isIdentity) {
    _translet.setIndexSize(dom.getSize());

    // If there are any elements with ID attributes, build an index
    dtd.buildIdIndex(dom, mask, _translet);

    // Pass unparsed entity URIs to the translet
View Full Code Here

  else if (source instanceof DOMSource) {
      final DOMSource domsrc = (DOMSource) source;
      new DOM2TO(domsrc.getNode(), handler).parse();
  }
  else if (source instanceof XSLTCSource) {
      final DOMImpl dom = ((XSLTCSource) source).getDOM();
      dom.copy(handler);
  }
  else {
      ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_SOURCE_ERR);
      throw new TransformerException(err.toString());
  }
View Full Code Here

        // Copy all the nodes in the nodelist to be under the top element
        copyNodes(nodeList, doc, topElementNode);
       
  // w3c DOM -> DOM2SAX -> DOMBuilder -> DOMImpl
  DOMImpl idom = new DOMImpl();
  final DOM2SAX dom2sax = new DOM2SAX(doc);
  final DOMBuilder domBuilder = idom.getBuilder();
  dom2sax.setContentHandler(domBuilder);
  try {
      dom2sax.parse();
  }
        catch (java.io.IOException e){
View Full Code Here

      }
      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());
View Full Code Here

  else {
      // Get a reference to the translet wrapped inside the transformer
      _translet = _transformer.getTranslet();

      // Create a DOMBuilder object and get the handler
      _dom = new DOMImpl();
      _handler = _dom.getBuilder();
      _lexHandler = (LexicalHandler) _handler;

      // Create a new DTD monitor
      _dtd = new DTDMonitor();
View Full Code Here

     * Create a new XSLTC-specific DOM source
     * @param size The estimated node-count for this DOM. A good guess here
     * speeds up the DOM build process.
     */
    public XSLTCSource(int size) {
  _dom = new DOMImpl(size);
  _dtd = new DTDMonitor();
    }
View Full Code Here

    /**
     * Create a new XSLTC-specific DOM source
     */
    public XSLTCSource() {
  _dom = new DOMImpl();
  _dtd = new DTDMonitor();
    }
View Full Code Here

      }
      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());
View Full Code Here

TOP

Related Classes of org.apache.xalan.xsltc.dom.DOMImpl

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.