com.ctc.wstx.api.ReaderConfig Java Examples

The following examples show how to use com.ctc.wstx.api.ReaderConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestUTF8Reader.java    From woodstox with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("resource")
   public void testDelAtBufferBoundary() throws IOException
   {
final int BYTE_BUFFER_SIZE = 4;
final int CHAR_BUFFER_SIZE = 1 + BYTE_BUFFER_SIZE; 
final int INPUT_SIZE = 4 * BYTE_BUFFER_SIZE; // could be of arbitrary size
final byte CHAR_FILLER = 32; // doesn't even matter, just need an ascii char
final byte CHAR_DEL = 127;

// Create input that will cause the array index out of bounds exception
byte[] inputBytes = new byte[INPUT_SIZE];
for (int i=0; i < inputBytes.length; i++) {
    inputBytes[i] = CHAR_FILLER;
}
inputBytes[BYTE_BUFFER_SIZE - 1] = CHAR_DEL;
InputStream in = new ByteArrayInputStream(inputBytes);

// Create the UTF8Reader
ReaderConfig cfg = ReaderConfig.createFullDefaults();
byte[] byteBuffer = new byte[BYTE_BUFFER_SIZE];
UTF8Reader reader = new UTF8Reader(cfg,in, byteBuffer, 0, 0, false);

// Run the reader on the input
char[] charBuffer = new char[CHAR_BUFFER_SIZE];
reader.read(charBuffer, 0, charBuffer.length);		
   }
 
Example #2
Source File: Configuration.java    From flink with Apache License 2.0 6 votes vote down vote up
private XMLStreamReader parse(InputStream is, String systemIdStr,
                              boolean restricted) throws IOException, XMLStreamException {
	if (!quietmode) {
		LOG.debug("parsing input stream " + is);
	}
	if (is == null) {
		return null;
	}
	SystemId systemId = SystemId.construct(systemIdStr);
	ReaderConfig readerConfig = XML_INPUT_FACTORY.createPrivateConfig();
	if (restricted) {
		readerConfig.setProperty(XMLInputFactory.SUPPORT_DTD, false);
	}
	return XML_INPUT_FACTORY.createSR(readerConfig, systemId,
			StreamBootstrapper.getInstance(null, systemId, is), false, true);
}
 
Example #3
Source File: WstxInputFactory.java    From woodstox with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("resource")
protected XMLStreamReader2 createSR(SystemId systemId, InputStream in, String enc,
		boolean forER, boolean autoCloseInput)
    throws XMLStreamException
{
    // 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);
    }

    /* !!! 17-Feb-2006, TSa: We don't yet know if it's xml 1.0 or 1.1;
     *   so have to specify 1.0 (which is less restrictive WRT input
     *   streams). Would be better to let bootstrapper deal with it
     *   though:
     */
    Reader r = DefaultInputResolver.constructOptimizedReader(cfg, in, false, enc);
    return createSR(cfg, systemId, ReaderBootstrapper.getInstance
                    (null, systemId, r, enc), forER, autoCloseInput);
}
 
Example #4
Source File: Configuration.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private XMLStreamReader parse(InputStream is, String systemIdStr,
                              boolean restricted) throws IOException, XMLStreamException {
	if (!quietmode) {
		LOG.debug("parsing input stream " + is);
	}
	if (is == null) {
		return null;
	}
	SystemId systemId = SystemId.construct(systemIdStr);
	ReaderConfig readerConfig = XML_INPUT_FACTORY.createPrivateConfig();
	if (restricted) {
		readerConfig.setProperty(XMLInputFactory.SUPPORT_DTD, false);
	}
	return XML_INPUT_FACTORY.createSR(readerConfig, systemId,
			StreamBootstrapper.getInstance(null, systemId, is), false, true);
}
 
Example #5
Source File: Configuration.java    From flink with Apache License 2.0 6 votes vote down vote up
private XMLStreamReader parse(InputStream is, String systemIdStr,
                              boolean restricted) throws IOException, XMLStreamException {
	if (!quietmode) {
		LOG.debug("parsing input stream " + is);
	}
	if (is == null) {
		return null;
	}
	SystemId systemId = SystemId.construct(systemIdStr);
	ReaderConfig readerConfig = XML_INPUT_FACTORY.createPrivateConfig();
	if (restricted) {
		readerConfig.setProperty(XMLInputFactory.SUPPORT_DTD, false);
	}
	return XML_INPUT_FACTORY.createSR(readerConfig, systemId,
			StreamBootstrapper.getInstance(null, systemId, is), false, true);
}
 
Example #6
Source File: WstxInputFactory.java    From woodstox with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("resource")
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, SystemId.construct(src), URLUtil.inputStreamFromURL(src),
                		forER, autoCloseInput);
            }
        }
        final SystemId systemId = SystemId.construct(URLUtil.toURL(f));
        return createSR(cfg, systemId, new FileInputStream(f), forER, autoCloseInput);

    } catch (IOException ie) {
        throw new WstxIOException(ie);
    }
}
 
Example #7
Source File: FullDTDReader.java    From woodstox with Apache License 2.0 6 votes vote down vote up
/**
 * Method called to read in the internal subset definition.
 */
public static DTDSubset readInternalSubset(WstxInputData srcData,
                                           WstxInputSource input,
                                           ReaderConfig cfg,
                                           boolean constructFully,
                                           int xmlVersion)
    throws XMLStreamException
{
    FullDTDReader r = new FullDTDReader(input, cfg, constructFully, xmlVersion);
    // Need to read using the same low-level reader interface:
    r.copyBufferStateFrom(srcData);
    DTDSubset ss;

    try {
        ss = r.parseDTD();
    } finally {
        /* And then need to restore changes back to owner (line nrs etc);
         * effectively means that we'll stop reading external DTD subset,
         * if so.
         */
        srcData.copyBufferStateFrom(r);
    }
    return ss;
}
 
Example #8
Source File: FullDTDReader.java    From woodstox with Apache License 2.0 6 votes vote down vote up
/**
 * Method that will parse, process and output contents of an external
 * DTD subset. It will do processing similar to
 * {@link #readExternalSubset}, but additionally will copy its processed
 * ("flattened") input to specified writer.
 *
 * @param src Input source used to read the main external subset
 * @param flattenWriter Writer to output processed DTD content to
 * @param inclComments If true, will pass comments to the writer; if false,
 *   will strip comments out
 * @param inclConditionals If true, will include conditional block markers,
 *   as well as intervening content; if false, will strip out both markers
 *   and ignorable sections.
 * @param inclPEs If true, will output parameter entity declarations; if
 *   false will parse and use them, but not output.
 */
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);
    r.setFlattenWriter(flattenWriter, inclComments, inclConditionals,
                       inclPEs);
    DTDSubset ss = r.parseDTD();
    r.flushFlattenWriter();
    flattenWriter.flush();
    return ss;
}
 
Example #9
Source File: MinimalDTDReader.java    From woodstox with Apache License 2.0 6 votes vote down vote up
/**
 * Method that just skims
 * through structure of internal subset, but without doing any sort
 * of validation, or parsing of contents. Method may still throw an
 * exception, if skipping causes EOF or there's an I/O problem.
 *
 * @param srcData Link back to the input buffer shared with the owning
 *    stream reader.
 */
public static void skipInternalSubset(WstxInputData srcData, WstxInputSource input,
                                      ReaderConfig cfg)
    throws XMLStreamException
{
    MinimalDTDReader r = new MinimalDTDReader(input, cfg);
    // Need to read from same source as the master (owning stream reader)
    r.copyBufferStateFrom(srcData);
    try {
        r.skipInternalSubset();
    } finally {
        /* And then need to restore changes back to srcData (line nrs etc);
         * effectively means that we'll stop reading internal DTD subset,
         * if so.
         */
        srcData.copyBufferStateFrom(r);
    }
}
 
Example #10
Source File: DefaultInputResolver.java    From woodstox with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("resource")
private static WstxInputSource sourceFromURL(WstxInputSource parent, ReaderConfig cfg,
        String refName, int xmlVersion,
        URL url,
        String pubId)
    throws IOException, XMLStreamException
{
    /* And then create the input source. Note that by default URL's
     * own input stream creation creates buffered reader -- for us
     * that's useless and wasteful (adds one unnecessary level of
     * caching, halving the speed due to copy operations needed), so
     * let's avoid it.
     */
    InputStream in = URLUtil.inputStreamFromURL(url);
    SystemId sysId = SystemId.construct(url);
    StreamBootstrapper bs = StreamBootstrapper.getInstance(pubId, sysId, in);
    Reader r = bs.bootstrapInput(cfg, false, xmlVersion);
    return InputSourceFactory.constructEntitySource
        (cfg, parent, refName, bs, pubId, sysId, xmlVersion, r);
}
 
Example #11
Source File: DefaultInputResolver.java    From woodstox with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("resource")
private static WstxInputSource sourceFromIS(WstxInputSource parent,
		ReaderConfig cfg, String refName, int xmlVersion,
		InputStream is, String pubId, String sysId)
    throws IOException, XMLStreamException
{
    StreamBootstrapper bs = StreamBootstrapper.getInstance(pubId, SystemId.construct(sysId), is);
    Reader r = bs.bootstrapInput(cfg, false, xmlVersion);
    URL ctxt = parent.getSource();

    // If we got a real sys id, we do know the source...
    if (sysId != null && sysId.length() > 0) {
        ctxt = URLUtil.urlFromSystemId(sysId, ctxt);
    }
    return InputSourceFactory.constructEntitySource
        (cfg, parent, refName, bs, pubId, SystemId.construct(sysId, ctxt),
        		xmlVersion, r);
}
 
Example #12
Source File: DefaultInputResolver.java    From woodstox with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("resource")
private static WstxInputSource sourceFromR(WstxInputSource parent, ReaderConfig cfg,
		String refName, int xmlVersion,
		Reader r, String pubId, String sysId)
    throws IOException, XMLStreamException
{
    /* Last null -> no app-provided encoding (doesn't matter for non-
     * main-level handling)
     */
    ReaderBootstrapper rbs = ReaderBootstrapper.getInstance(pubId, SystemId.construct(sysId), r, null);
    // null -> no xml reporter... should have one?
    Reader r2 = rbs.bootstrapInput(cfg, false, xmlVersion);
    URL ctxt = (parent == null) ? null : parent.getSource();
    if (sysId != null && sysId.length() > 0) {
        ctxt = URLUtil.urlFromSystemId(sysId, ctxt);
    }
    return InputSourceFactory.constructEntitySource
        (cfg, parent, refName, rbs, pubId, SystemId.construct(sysId, ctxt), xmlVersion, r2);
}
 
Example #13
Source File: InputSourceFactory.java    From woodstox with Apache License 2.0 6 votes vote down vote up
/**
 * Factory method used for creating the main-level document reader
 * source.
 */
public static BranchingReaderSource constructDocumentSource
    (ReaderConfig cfg, InputBootstrapper bs, String pubId, SystemId sysId,
     Reader r, boolean realClose) 
{
    /* To resolve [WSTX-50] need to ensure that P_BASE_URL overrides
     * the defaults if/as necessary
     */
    URL url = cfg.getBaseURL();
    if (url != null) {
    	sysId = SystemId.construct(url);
    }
    BranchingReaderSource rs = new BranchingReaderSource(cfg, pubId, sysId, r, realClose);
    if (bs != null) {
        rs.setInputOffsets(bs.getInputTotal(), bs.getInputRow(),
                           -bs.getInputColumn());
    }
    return rs;
}
 
Example #14
Source File: TestInputFactory.java    From woodstox with Apache License 2.0 6 votes vote down vote up
public void testConfig()
    throws XMLStreamException
{
    XMLInputFactory2 f = getNewInputFactory();

    ReaderConfig cfg = ((WstxInputFactory) f).getConfig();
    assertNotNull(cfg);

    assertNull(f.getEventAllocator());
    assertNull(f.getXMLResolver());

    assertNull(f.getXMLReporter());
    MyReporter rep = new MyReporter();
    f.setXMLReporter(rep);
    assertEquals(rep, f.getXMLReporter());

    assertFalse(f.isPropertySupported("foobar"));
}
 
Example #15
Source File: ReaderBootstrapper.java    From woodstox with Apache License 2.0 5 votes vote down vote up
protected void verifyXmlEncoding(ReaderConfig cfg)
    throws XMLStreamException
{
    String inputEnc = mInputEncoding;

    // Close enough?
    if (StringUtil.equalEncodings(inputEnc, mFoundEncoding)) {
        return;
    }

    /* Ok, maybe the difference is just with endianness indicator?
     * (UTF-16BE vs. UTF-16)?
     */
    // !!! TBI

    XMLReporter rep = cfg.getXMLReporter();
    if (rep != null) {
        Location loc = getLocation();
        String msg = MessageFormat.format(ErrorConsts.W_MIXED_ENCODINGS,
                                          new Object[] { mFoundEncoding,
                                                         inputEnc });
        String type = ErrorConsts.WT_XML_DECL;
        /* 30-May-2008, tatus: Should wrap all the info as XMValidationProblem
         *    since that's Woodstox' contract wrt. relatedInformation field.
         */
        XMLValidationProblem prob = new XMLValidationProblem(loc, msg, XMLValidationProblem.SEVERITY_WARNING, type);
        rep.report(msg, type, prob, loc);
    }
}
 
Example #16
Source File: MergedReader.java    From woodstox with Apache License 2.0 5 votes vote down vote up
public MergedReader(ReaderConfig cfg, Reader in, char[] buf, int start, int end)
{
    mConfig = cfg;
    mIn = in;
    mData = buf;
    mPtr = start;
    mEnd = end;
    // sanity check: should not pass empty buffer
    if (buf != null && start >= end) {
        throw new IllegalArgumentException("Trying to construct MergedReader with empty contents (start "+start+", end "+end+")");
    }
}
 
Example #17
Source File: MergedStream.java    From woodstox with Apache License 2.0 5 votes vote down vote up
public MergedStream(ReaderConfig cfg,
                    InputStream in, byte[] buf, int start, int end)
{
    mConfig = cfg;
    mIn = in;
    mData = buf;
    mPtr = start;
    mEnd = end;
}
 
Example #18
Source File: DefaultInputResolver.java    From woodstox with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("resource")
private static WstxInputSource sourceFromSS(WstxInputSource parent, ReaderConfig cfg,
		String refName, int xmlVersion, StreamSource ssrc)
    throws IOException, XMLStreamException
{
    InputBootstrapper bs;
    Reader r = ssrc.getReader();
    String pubId = ssrc.getPublicId();
    String sysId0 = ssrc.getSystemId();
    URL ctxt = (parent == null) ? null : parent.getSource();
    URL url = (sysId0 == null || sysId0.length() == 0) ? null
        : URLUtil.urlFromSystemId(sysId0, ctxt);

    final SystemId systemId = SystemId.construct(sysId0, (url == null) ? ctxt : url);
    
    if (r == null) {
        InputStream in = ssrc.getInputStream();
        if (in == null) { // Need to try just resolving the system id then
            if (url == null) {
                throw new IllegalArgumentException("Can not create Stax reader for a StreamSource -- neither reader, input stream nor system id was set.");
            }
            in = URLUtil.inputStreamFromURL(url);
        }
        bs = StreamBootstrapper.getInstance(pubId, systemId, in);
    } else {
        bs = ReaderBootstrapper.getInstance(pubId, systemId, r, null);
    }
    
    Reader r2 = bs.bootstrapInput(cfg, false, xmlVersion);
    return InputSourceFactory.constructEntitySource
        (cfg, parent, refName, bs, pubId, systemId, xmlVersion, r2);
}
 
Example #19
Source File: InputSourceFactory.java    From woodstox with Apache License 2.0 5 votes vote down vote up
/**
 * @param parent
 * @param entityName Name of the entity expanded to create this input
 *    source: null when source created for the (main level) external
 *    DTD subset entity.
 * @param xmlVersion Optional xml version identifier of the main parsed
 *   document. Currently only relevant for checking that XML 1.0 document
 *   does not include XML 1.1 external parsed entities.
 *   If unknown, no checks will be done.
 */
public static ReaderSource constructEntitySource
    (ReaderConfig cfg, WstxInputSource parent, String entityName, InputBootstrapper bs,
     String pubId, SystemId sysId, int xmlVersion, Reader r)
{
    // true -> do close the underlying Reader at EOF
    ReaderSource rs = new ReaderSource
        (cfg, parent, entityName, pubId, sysId, r, true);
    if (bs != null) {
        rs.setInputOffsets(bs.getInputTotal(), bs.getInputRow(),
                           -bs.getInputColumn());
    }
    return rs;
}
 
Example #20
Source File: DefaultInputResolver.java    From woodstox with Apache License 2.0 5 votes vote down vote up
/**
 * Factory method that accepts various types of Objects, and tries to
 * create a {@link WstxInputSource} from it. Currently it's only called
 * to locate external DTD subsets, when overriding default DOCTYPE
 * declarations; not for entity expansion or for locating the main
 * document entity.
 *
 * @param parent Input source context active when resolving a new
 *    "sub-source"; usually the main document source.
 * @param refName Name of the entity to be expanded, if any; may be
 *    null (and currently always is)
 * @param o Object that should provide the new input source; non-type safe
 */
protected static WstxInputSource sourceFrom(WstxInputSource parent,
		ReaderConfig cfg, String refName,
		int xmlVersion, Object o)
    throws IllegalArgumentException, IOException, XMLStreamException
{
    if (o instanceof Source) {
        if (o instanceof StreamSource) {
            return sourceFromSS(parent, cfg, refName, xmlVersion, (StreamSource) o);
        }
        /* !!! 05-Feb-2006, TSa: Could check if SAXSource actually has
         *    stream/reader available... ?
         */
        throw new IllegalArgumentException("Can not use other Source objects than StreamSource: got "+o.getClass());
    }
    if (o instanceof URL) {
        return sourceFromURL(parent, cfg, refName, xmlVersion, (URL) o, null);
    }
    if (o instanceof InputStream) {
        return sourceFromIS(parent, cfg, refName, xmlVersion, (InputStream) o, null, null);
    }
    if (o instanceof Reader) {
        return sourceFromR(parent, cfg, refName, xmlVersion, (Reader) o, null, null);
    }
    if (o instanceof String) {
        return sourceFromString(parent, cfg, refName, xmlVersion, (String) o);
    }
    if (o instanceof File) {
        URL u = URLUtil.toURL((File) o);
        return sourceFromURL(parent, cfg, refName, xmlVersion, u, null);
    }

    throw new IllegalArgumentException("Unrecognized input argument type for sourceFrom(): "+o.getClass());
}
 
Example #21
Source File: DefaultInputResolver.java    From woodstox with Apache License 2.0 5 votes vote down vote up
/**
 * A very simple utility expansion method used generally when the
 * only way to resolve an entity is via passed resolver; and where
 * failing to resolve it is not fatal.
 */
public static WstxInputSource resolveEntityUsing
    (WstxInputSource refCtxt, String entityName,
     String publicId, String systemId,
     XMLResolver resolver, ReaderConfig cfg, int xmlVersion)
    throws IOException, XMLStreamException
{
    URL ctxt = (refCtxt == null) ? null : refCtxt.getSource();
    if (ctxt == null) {
        ctxt = URLUtil.urlFromCurrentDir();
    }
    Object source = resolver.resolveEntity(publicId, systemId, ctxt.toExternalForm(), entityName);
    return (source == null) ? null : sourceFrom(refCtxt, cfg, entityName, xmlVersion, source);
}
 
Example #22
Source File: DefaultInputResolver.java    From woodstox with Apache License 2.0 5 votes vote down vote up
/**
 * Basic external resource resolver implementation; usable both with
 * DTD and entity resolution.
 *
 * @param parent Input source that contains reference to be expanded.
 * @param pathCtxt Reference context to use for resolving path, if
 *   known. If null, reference context of the parent will
 *   be used; and if that is null (which is possible), the
 *   current working directory will be assumed.
 * @param entityName Name/id of the entity being expanded, if this is an
 *   entity expansion; null otherwise (for example, when resolving external
 *   subset).
 * @param publicId Public identifier of the resource, if known; null/empty
 *   otherwise. Default implementation just ignores the identifier.
 * @param systemId System identifier of the resource. Although interface
 *   allows null/empty, default implementation considers this an error.
 * @param xmlVersion Xml version as declared by the main parsed
 *   document. Currently only relevant for checking that XML 1.0 document
 *   does not include XML 1.1 external parsed entities.
 *   If XML_V_UNKNOWN, no checks will be done.
 * @param customResolver Custom resolver to use first for resolution,
 *   if any (may be null).
 * @param cfg Reader configuration object used by the parser that is
 *   resolving the entity
 *
 * @return Input source, if entity could be resolved; null if it could
 *   not be resolved. In latter case processor may use its own default
 *   resolution mechanism.
 */
public static WstxInputSource resolveEntity
    (WstxInputSource parent, URL pathCtxt, String entityName,
     String publicId, String systemId,
     XMLResolver customResolver, ReaderConfig cfg, int xmlVersion)
    throws IOException, XMLStreamException
{
    if (pathCtxt == null) {
        pathCtxt = parent.getSource();
        if (pathCtxt == null) {
            pathCtxt = URLUtil.urlFromCurrentDir();
        }
    }

    // Do we have a custom resolver that may be able to resolve it?
    if (customResolver != null) {
        Object source = customResolver.resolveEntity(publicId, systemId, pathCtxt.toExternalForm(), entityName);
        if (source != null) {
            return sourceFrom(parent, cfg, entityName, xmlVersion, source);
        }
    }
        
    // Have to have a system id, then...
    if (systemId == null) {
        throw new XMLStreamException("Can not resolve "
                                     +((entityName == null) ? "[External DTD subset]" : ("entity '"+entityName+"'"))+" without a system id (public id '"
                                     +publicId+"')");
    }
    URL url = URLUtil.urlFromSystemId(systemId, pathCtxt);
    return sourceFromURL(parent, cfg, entityName, xmlVersion, url, publicId);
}
 
Example #23
Source File: UnparsedExtEntity.java    From woodstox with Apache License 2.0 5 votes vote down vote up
@Override
public WstxInputSource expand(WstxInputSource parent,
        XMLResolver res, ReaderConfig cfg, int xmlVersion)
{
    // Should never get called, actually...
    throw new IllegalStateException("Internal error: createInputSource() called for unparsed (external) entity.");
}
 
Example #24
Source File: ParsedExtEntity.java    From woodstox with Apache License 2.0 5 votes vote down vote up
@Override
public WstxInputSource expand(WstxInputSource parent,
                              XMLResolver res, ReaderConfig cfg,
                              int xmlVersion)
    throws IOException, XMLStreamException
{
    /* 05-Feb-2006, TSa: If xmlVersion not explicitly known, it defaults
     *    to 1.0
     */
    if (xmlVersion == XmlConsts.XML_V_UNKNOWN) {
        xmlVersion = XmlConsts.XML_V_10;
    }
    return DefaultInputResolver.resolveEntity
        (parent, mContext, mName, getPublicId(), getSystemId(), res, cfg, xmlVersion);
}
 
Example #25
Source File: WstxInputFactory.java    From woodstox with Apache License 2.0 5 votes vote down vote up
private XMLStreamReader2 createSR(ReaderConfig cfg, SystemId systemId,
		InputStream in, boolean forER, boolean autoCloseInput)
    throws XMLStreamException
{
    return doCreateSR(cfg, systemId,
 StreamBootstrapper.getInstance(null, systemId, in),
 forER, autoCloseInput);
}
 
Example #26
Source File: WstxDOMWrappingReader.java    From woodstox with Apache License 2.0 5 votes vote down vote up
protected WstxDOMWrappingReader(DOMSource src, ReaderConfig cfg)
    throws XMLStreamException
{
    super(src, cfg.willSupportNamespaces(), cfg.willCoalesceText());
    mConfig = cfg;
    // [WSTX-162]: allow enabling/disabling name/ns intern()ing
    if (cfg.hasInternNamesBeenEnabled()) {
        setInternNames(true);
    }
    if (cfg.hasInternNsURIsBeenEnabled()) {
        setInternNsURIs(true);
    }
}
 
Example #27
Source File: InputFactoryProviderImpl.java    From woodstox with Apache License 2.0 5 votes vote down vote up
protected Properties getProperties()
{
    Properties props = new Properties();
    props.setProperty(OSGI_SVC_PROP_IMPL_NAME, ReaderConfig.getImplName());
    props.setProperty(OSGI_SVC_PROP_IMPL_VERSION, ReaderConfig.getImplVersion());
    return props;
}
 
Example #28
Source File: OutputFactoryProviderImpl.java    From woodstox with Apache License 2.0 5 votes vote down vote up
protected Properties getProperties()
{
    Properties props = new Properties();
    props.setProperty(OSGI_SVC_PROP_IMPL_NAME, ReaderConfig.getImplName());
    props.setProperty(OSGI_SVC_PROP_IMPL_VERSION, ReaderConfig.getImplVersion());
    return props;
}
 
Example #29
Source File: IntEntity.java    From woodstox with Apache License 2.0 5 votes vote down vote up
@Override
public WstxInputSource expand(WstxInputSource parent,
                              XMLResolver res, ReaderConfig cfg,
                              int xmlVersion)
{
    /* 26-Dec-2006, TSa: Better leave source as null, since internal
     *   entity declaration context should never be used: when expanding,
     *   reference context is to be used.
     */
    return InputSourceFactory.constructCharArraySource
        //(parent, mName, mRepl, 0, mRepl.length, mContentLocation, getSource());
        (parent, mName, mRepl, 0, mRepl.length, mContentLocation, null);
}
 
Example #30
Source File: StaxParserFactory.java    From iaf with Apache License 2.0 5 votes vote down vote up
/**
 * Enable XML 1.1, to avoid errors like:
 * Illegal character entity: expansion character (code 0x3 at [row,col {unknown-source}]: [1,53] 
 */
@Override
public ReaderConfig createPrivateConfig() {
	ReaderConfig result = super.createPrivateConfig();
	result.enableXml11(true);
	return result;
}