Package com.ctc.wstx.api

Examples of com.ctc.wstx.api.ReaderConfig


        // sanity check:
        if (in == null) {
            throw new IllegalArgumentException("Null InputStream is not a valid argument");
        }

        ReaderConfig cfg = createPrivateConfig();
        if (enc == null || enc.length() == 0) {
            return createSR(cfg, systemId, StreamBootstrapper.getInstance
                            (null, systemId, in), forER, autoCloseInput);
        }
View Full Code Here


    }

    protected XMLStreamReader2 createSR(File f, boolean forER, boolean autoCloseInput)
        throws XMLStreamException
    {
        ReaderConfig cfg = createPrivateConfig();
        try {
            /* 18-Nov-2008, TSa: If P_BASE_URL is set, and File reference is
             *   relative, let's resolve against base...
             */
            if (!f.isAbsolute()) {
                URL base = cfg.getBaseURL();
                if (base != null) {
                    URL src = new URL(base, f.getPath());
                    return createSR(cfg, src, URLUtil.inputStreamFromURL(src), forER, autoCloseInput);
                }
            }
View Full Code Here

     */
    protected XMLStreamReader2 createSR(javax.xml.transform.Source src,
                                        boolean forER)
        throws XMLStreamException
    {
        ReaderConfig cfg = createPrivateConfig();
        Reader r = null;
        InputStream in = null;
        String pubId = null;
        String sysId = null;
        String encoding = null;
        boolean autoCloseInput;

        InputBootstrapper bs = null;

        if (src instanceof Stax2Source) {
            Stax2Source ss = (Stax2Source) src;
            sysId = ss.getSystemId();
            pubId = ss.getPublicId();
            encoding = ss.getEncoding();

            try {
    /* 11-Nov-2008, TSa: Let's add optimized handling for byte-block
     *   source
     */
    if (src instanceof Stax2ByteArraySource) {
        Stax2ByteArraySource bas = (Stax2ByteArraySource) src;
        bs = StreamBootstrapper.getInstance(pubId, sysId, bas.getBuffer(), bas.getBufferStart(), bas.getBufferEnd());
    } else {
        in = ss.constructInputStream();
        if (in == null) {
      r = ss.constructReader();
        }
    }
            } catch (IOException ioe) {
                throw new WstxIOException(ioe);
            }
            /* Caller has no direct access to stream/reader, Woodstox
             * owns it and thus has to close too
             */
            autoCloseInput = true;
        } else  if (src instanceof StreamSource) {
            StreamSource ss = (StreamSource) src;
            sysId = ss.getSystemId();
            pubId = ss.getPublicId();
            in = ss.getInputStream();
            if (in == null) {
                r = ss.getReader();
            }
            /* Caller still has access to stream/reader; no need to
             * force auto-close-input
             */
            autoCloseInput = cfg.willAutoCloseInput();
        } else if (src instanceof SAXSource) {
            SAXSource ss = (SAXSource) src;
            /* 28-Jan-2006, TSa: Not a complete implementation, but maybe
             *   even this might help...
             */
            sysId = ss.getSystemId();
            InputSource isrc = ss.getInputSource();
            if (isrc != null) {
                encoding = isrc.getEncoding();
                in = isrc.getByteStream();
                if (in == null) {
                    r = isrc.getCharacterStream();
                }
            }
            /* Caller still has access to stream/reader; no need to
             * force auto-close-input
             */
            autoCloseInput = cfg.willAutoCloseInput();
        } else if (src instanceof DOMSource) {
            DOMSource domSrc = (DOMSource) src;
            // SymbolTable not used by the DOM-based 'reader':
            return WstxDOMWrappingReader.createFrom(domSrc, cfg);
        } else {
View Full Code Here

    public void parse(InputSource input)
        throws SAXException
    {
        mScanner = null;
        String systemId = input.getSystemId();
        ReaderConfig cfg = mConfig;
        URL srcUrl = null;

        // Let's figure out input, first, before sending start-doc event
        InputStream is = null;
        Reader r = input.getCharacterStream();
        if (r == null) {
            is = input.getByteStream();
            if (is == null) {
                if (systemId == null) {
                    throw new SAXException("Invalid InputSource passed: neither character or byte stream passed, nor system id specified");
                }
                try {
                    srcUrl = URLUtil.urlFromSystemId(systemId);
                    is = URLUtil.optimizedStreamFromURL(srcUrl);
                } catch (IOException ioe) {
                    SAXException saxe = new SAXException(ioe);
                    saxe.initCause(ioe);
                    throw saxe;
                }
            }
        }

        if (mContentHandler != null) {
            mContentHandler.setDocumentLocator(this);
            mContentHandler.startDocument();
        }

        try {
            InputBootstrapper bs;
            String inputEnc = input.getEncoding();
            String publicId = input.getPublicId();
            if (r != null) {
                bs = ReaderBootstrapper.getInstance(r, publicId, systemId, inputEnc);
            } else {
                bs = StreamBootstrapper.getInstance(is, publicId, systemId);
            }
            /* Note: since we are reusing the same config instance, need to
             * make sure state is not carried forward. Thus:
             */
            cfg.resetState();
            // false -> not for event reader; false -> no auto-closing
            mScanner = (BasicStreamReader) mStaxFactory.createSR(cfg, systemId, bs, false, false);

            // Need to get xml declaration stuff out now:
            {
View Full Code Here

            } catch (IOException ie) {
                throw new WstxIOException(ie);
            }
        }

        ReaderConfig cfg = mConfig.createNonShared(mSymbols.makeChild());
        Reader r;
        try {
            r = bs.bootstrapInput(cfg, true, XmlConsts.XML_V_UNKNOWN);
            if (bs.declaredXml11()) {
                cfg.enableXml11(true);
            }
        } catch (IOException ie) {
            throw new WstxIOException(ie);
        }
View Full Code Here

        // sanity check:
        if (in == null) {
            throw new IllegalArgumentException("Null InputStream is not a valid argument");
        }

        ReaderConfig cfg = createPrivateConfig();
        if (enc == null || enc.length() == 0) {
            return createSR(cfg, systemId, StreamBootstrapper.getInstance
                            (in, null, systemId), forER, autoCloseInput);
        }
View Full Code Here

     */
    protected XMLStreamReader2 createSR(javax.xml.transform.Source src,
                                        boolean forER)
        throws XMLStreamException
    {
        ReaderConfig cfg = createPrivateConfig();
        Reader r = null;
        InputStream in = null;
        String pubId = null;
        String sysId = null;
        String encoding = null;
        boolean autoCloseInput;

        if (src instanceof Stax2Source) {
            /* 16-Aug-2006, TSa: Should have more optimized handling
             *   for specific types
             */
            Stax2Source ss = (Stax2Source) src;
            sysId = ss.getSystemId();
            pubId = ss.getPublicId();
            encoding = ss.getEncoding();
            try {
                in = ss.constructInputStream();
                if (in == null) {
                    r = ss.constructReader();
                }
            } catch (IOException ioe) {
                throw new WstxIOException(ioe);
            }
            /* Caller has no direct access to stream/reader, Woodstox
             * owns it and thus has to close too
             */
            autoCloseInput = true;
        } else  if (src instanceof StreamSource) {
            StreamSource ss = (StreamSource) src;
            sysId = ss.getSystemId();
            pubId = ss.getPublicId();
            in = ss.getInputStream();
            if (in == null) {
                r = ss.getReader();
            }
            /* Caller still has access to stream/reader; no need to
             * force auto-close-input
             */
            autoCloseInput = cfg.willAutoCloseInput();
        } else if (src instanceof SAXSource) {
            SAXSource ss = (SAXSource) src;
            /* 28-Jan-2006, TSa: Not a complete implementation, but maybe
             *   even this might help...
             */
            InputSource isrc = ss.getInputSource();
            if (isrc != null) {
                sysId = isrc.getSystemId();
                pubId = isrc.getPublicId();
                encoding = isrc.getEncoding();
                in = isrc.getByteStream();
                if (in == null) {
                    r = isrc.getCharacterStream();
                }
            }
            /* Caller still has access to stream/reader; no need to
             * force auto-close-input
             */
            autoCloseInput = cfg.willAutoCloseInput();
        } else if (src instanceof DOMSource) {
            DOMSource domSrc = (DOMSource) src;
            // SymbolTable not used by the DOM-based 'reader':
            return DOMWrappingReader.createFrom(cfg, domSrc);
        } else {
View Full Code Here

    public static DTDSubset flattenExternalSubset(WstxInputSource src, Writer flattenWriter,
                                                  boolean inclComments, boolean inclConditionals,
                                                  boolean inclPEs)
        throws IOException, XMLStreamException
    {
        ReaderConfig cfg = ReaderConfig.createFullDefaults();
        // Need to create a non-shared copy to populate symbol table field
        cfg = cfg.createNonShared(new SymbolTable());

        /* Let's assume xml 1.0... can be taken as an arg later on, if we
         * truly care.
         */
        FullDTDReader r = new FullDTDReader(src, cfg, null, true, XmlConsts.XML_V_UNKNOWN);
View Full Code Here

    public XMLValidationSchema createSchema(InputStream in, String encoding,
                                           String publicId, String systemId)
        throws XMLStreamException
    {
        ReaderConfig rcfg = createPrivateReaderConfig();
        return doCreateSchema(rcfg, StreamBootstrapper.getInstance
                              (publicId, systemId, in), publicId, systemId, null);
    }
View Full Code Here

    public XMLValidationSchema createSchema(Reader r, String publicId,
                                           String systemId)
        throws XMLStreamException
    {
        ReaderConfig rcfg = createPrivateReaderConfig();
        return doCreateSchema(rcfg, ReaderBootstrapper.getInstance
                              (publicId, systemId, r, null), publicId, systemId, null);
    }
View Full Code Here

TOP

Related Classes of com.ctc.wstx.api.ReaderConfig

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.