Package com.ctc.wstx.api

Examples of com.ctc.wstx.api.ReaderConfig


    }

    public XMLValidationSchema createSchema(URL url)
        throws XMLStreamException
    {
        ReaderConfig rcfg = createPrivateReaderConfig();
        try {
            InputStream in = URLUtil.inputStreamFromURL(url);
            return doCreateSchema(rcfg, StreamBootstrapper.getInstance
                                  (null, null, in),
                                  null, url.toExternalForm(), url);
View Full Code Here


    }

    public XMLValidationSchema createSchema(File f)
        throws XMLStreamException
    {
        ReaderConfig rcfg = createPrivateReaderConfig();
        try {
            URL url = f.toURL();
            return doCreateSchema(rcfg, StreamBootstrapper.getInstance
                                  (null, null, new FileInputStream(f)),
                                  null, url.toExternalForm(), url);
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.inputStreamFromURL(srcUrl);
                } catch (IOException ioe) {
                    SAXException saxe = new SAXException(ioe);
                    ExceptionUtil.setInitCause(saxe, ioe);
                    throw saxe;
                }
            }
        }

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

        /* Note: since we are reusing the same config instance, need to
         * make sure state is not carried forward. Thus:
         */
        cfg.resetState();

        try {
            String inputEnc = input.getEncoding();
            String publicId = input.getPublicId();

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
                            (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

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.