Java Code Examples for com.ctc.wstx.api.ReaderConfig#enableXml11()

The following examples show how to use com.ctc.wstx.api.ReaderConfig#enableXml11() . 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: WstxInputFactory.java    From woodstox with Apache License 2.0 5 votes vote down vote up
/**
 * Bottleneck method used for creating ALL full stream reader instances
 * (via other createSR() methods and directly)
 *
 * @param forER True, if the reader is being constructed to be used
 *   by an event reader; false if it is not (or the purpose is not known)
 * @param autoCloseInput Whether the underlying input source should be
 *   actually closed when encountering EOF, or when <code>close()</code>
 *   is called. Will be true for input sources that are automatically
 *   managed by stream reader (input streams created for
 *   {@link java.net.URL} and {@link java.io.File} arguments, or when
 *   configuration settings indicate auto-closing is to be enabled
 *   (the default value is false as per Stax 1.0 specs).
 */
@SuppressWarnings("resource")
private XMLStreamReader2 doCreateSR(ReaderConfig cfg, SystemId systemId,
		InputBootstrapper bs,  boolean forER, boolean autoCloseInput)
    throws XMLStreamException
{
    /* Automatic closing of input: will happen always for some input
     * types (ones application has no direct access to; but can also
     * be explicitly enabled.
     */
    if (!autoCloseInput) {
        autoCloseInput = cfg.willAutoCloseInput();
    }

    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);
    }

    /* null -> no public id available
     * false -> don't close the reader when scope is closed.
     */
    BranchingReaderSource input = InputSourceFactory.constructDocumentSource
        (cfg, bs, null, systemId, r, autoCloseInput);

    return ValidatingStreamReader.createValidatingStreamReader(input, this, cfg, bs, forER);
}
 
Example 2
Source File: DTDSchemaFactory.java    From woodstox with Apache License 2.0 5 votes vote down vote up
/**
 * The main validator construction method, called by all externally
 * visible methods.
 */
@SuppressWarnings("resource")
protected XMLValidationSchema doCreateSchema
    (ReaderConfig rcfg, InputBootstrapper bs, String publicId, String systemIdStr, URL ctxt)
    throws XMLStreamException
{
    try {
        Reader r = bs.bootstrapInput(rcfg, false, XmlConsts.XML_V_UNKNOWN);
        if (bs.declaredXml11()) {
            rcfg.enableXml11(true);
        }
        if (ctxt == null) { // this is just needed as context for param entity expansion
            ctxt = URLUtil.urlFromCurrentDir();
        }
        /* Note: need to pass unknown for 'xmlVersion' here (as well as
         * above for bootstrapping), since this is assumed to be the main
         * level parsed document and no xml version compatibility checks
         * should be done.
         */
        SystemId systemId = SystemId.construct(systemIdStr, ctxt);
        WstxInputSource src = InputSourceFactory.constructEntitySource
            (rcfg, null, null, bs, publicId, systemId, XmlConsts.XML_V_UNKNOWN, r);

        /* true -> yes, fully construct for validation
         * (does not mean it has to be used for validation, but required
         * if it is to be used for that purpose)
         */
        return FullDTDReader.readExternalSubset(src, rcfg, /*int.subset*/null, true, bs.getDeclaredVersion());
    } catch (IOException ioe) {
        throw new WstxIOException(ioe);
    }
}
 
Example 3
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;
}