Package org.apache.xalan.xsltc.dom

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


      _dom = new DOMImpl();
      _handler = _dom.getBuilder();
      _lexHandler = (LexicalHandler) _handler;

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


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

     
  }

  // Get the references to the actual DOM and DTD handler
  final DOMImpl    dom = doc.getDocument();
  final DTDMonitor dtd = doc.getDTDMonitor();

  // The dom reference may be null if the URL pointed to a
  // non-existing document
  if (dom == null) return null;

  doc.incAccessCount(); // For statistics

  final AbstractTranslet translet = (AbstractTranslet)trs;

  // Set minimum needed size for key/id indices in the translet
  translet.setIndexSize(dom.getSize());
  // Create index for any ID attributes defined in the document DTD
  dtd.buildIdIndex(dom, mask, translet);
  // Pass all unparsed entities to the translet
  translet.setUnparsedEntityURIs(dtd.getUnparsedEntityURIs());

  return(doc.getDocument());
    }
View Full Code Here

   * Loads the document and updates build-time (latency) statistics
   */
  public void loadDocument(String uri) {

      _dom = new DOMImpl();
      _dtdMonitor = new DTDMonitor();

      try {
    final long stamp = System.currentTimeMillis();

    _reader.setContentHandler(_dom.getBuilder());
View Full Code Here

     * @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

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

      // Create a DTD monitor and pass it to the XMLReader object
      _dtdMonitor = new DTDMonitor();
      _dtdMonitor.handleDTD(reader);

      // Parse the input document
      reader.parse(url);
View Full Code Here

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

  // Create a DTD monitor and pass it to the XMLReader object
  final DTDMonitor dtdMonitor = new DTDMonitor();
  dtdMonitor.handleDTD(reader);
  translet.setDTDMonitor(dtdMonitor);

  // Parse the input document
  reader.parse(url);
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
    _translet.setDTDMonitor(dtd);
      }
      return dom;
View Full Code Here

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

TOP

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

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.