当前位置: 首页>>代码示例>>Java>>正文


Java SAXSource.getXMLReader方法代码示例

本文整理汇总了Java中javax.xml.transform.sax.SAXSource.getXMLReader方法的典型用法代码示例。如果您正苦于以下问题:Java SAXSource.getXMLReader方法的具体用法?Java SAXSource.getXMLReader怎么用?Java SAXSource.getXMLReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.transform.sax.SAXSource的用法示例。


在下文中一共展示了SAXSource.getXMLReader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unmarshal

import javax.xml.transform.sax.SAXSource; //导入方法依赖的package包/类
@Override
public <T> JAXBElement<T> unmarshal( Source source, Class<T> expectedType ) throws JAXBException {
    if (source instanceof SAXSource) {
        SAXSource ss = (SAXSource) source;

        XMLReader locReader = ss.getXMLReader();
        if (locReader == null) {
            locReader = getXMLReader();
        }

        return unmarshal(locReader, ss.getInputSource(), expectedType);
    }
    if (source instanceof StreamSource) {
        return unmarshal(getXMLReader(), streamSourceToInputSource((StreamSource) source), expectedType);
    }
    if (source instanceof DOMSource) {
        return unmarshal(((DOMSource) source).getNode(), expectedType);
    }

    // we don't handle other types of Source
    throw new IllegalArgumentException();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:UnmarshallerImpl.java

示例2: unmarshal0

import javax.xml.transform.sax.SAXSource; //导入方法依赖的package包/类
public Object unmarshal0( Source source, JaxBeanInfo expectedType ) throws JAXBException {
    if (source instanceof SAXSource) {
        SAXSource ss = (SAXSource) source;

        XMLReader locReader = ss.getXMLReader();
        if (locReader == null) {
            locReader = getXMLReader();
        }

        return unmarshal0(locReader, ss.getInputSource(), expectedType);
    }
    if (source instanceof StreamSource) {
        return unmarshal0(getXMLReader(), streamSourceToInputSource((StreamSource) source), expectedType);
    }
    if (source instanceof DOMSource) {
        return unmarshal0(((DOMSource) source).getNode(), expectedType);
    }

    // we don't handle other types of Source
    throw new IllegalArgumentException();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:UnmarshallerImpl.java

示例3: unmarshal

import javax.xml.transform.sax.SAXSource; //导入方法依赖的package包/类
private Object unmarshal( SAXSource source ) throws JAXBException {

        XMLReader r = source.getXMLReader();
        if( r == null )
            r = getXMLReader();

        return unmarshal( r, source.getInputSource() );
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:AbstractUnmarshallerImpl.java

示例4: setEntityResolver

import javax.xml.transform.sax.SAXSource; //导入方法依赖的package包/类
/**
 * Establish an entityResolver for newly resolved URIs.
 * <p>
 * This is called from the URIResolver to set an EntityResolver on the SAX
 * parser to be used for new XML documents that are encountered as a result
 * of the document() function, xsl:import, or xsl:include. This is done
 * because the XSLT processor calls out to the SAXParserFactory itself to
 * create a new SAXParser to parse the new document. The new parser does not
 * automatically inherit the EntityResolver of the original (although
 * arguably it should). Quote from JAXP specification on Class
 * SAXTransformerFactory:
 * <p>
 * {@code If an application wants to set the ErrorHandler or EntityResolver
 * for an XMLReader used during a transformation, it should use a URIResolver
 * to return the SAXSource which provides (with getXMLReader) a reference to
 * the XMLReader}
 *
 */
private void setEntityResolver(SAXSource source) {
    XMLReader reader = source.getXMLReader();
    if (reader == null) {
        SAXParserFactory spFactory = new SAXParserFactoryImpl();
        spFactory.setNamespaceAware(true);
        try {
            reader = spFactory.newSAXParser().getXMLReader();
        } catch (ParserConfigurationException | SAXException ex) {
            CatalogMessages.reportRunTimeError(CatalogMessages.ERR_PARSER_CONF, ex);
        }
    }
    if (entityResolver != null) {
        entityResolver = new CatalogResolverImpl(catalog);
    }
    reader.setEntityResolver(entityResolver);
    source.setXMLReader(reader);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:CatalogResolverImpl.java


注:本文中的javax.xml.transform.sax.SAXSource.getXMLReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。