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


Java SAXBuilder.setExpandEntities方法代码示例

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


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

示例1: processResource

import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
public void processResource( String resource, InputStream is, List<Relocator> relocators )
    throws IOException
{
    Document r;
    try
    {
        SAXBuilder builder = new SAXBuilder( false );
        builder.setExpandEntities( false );
        if ( ignoreDtd )
        {
            builder.setEntityResolver( new EntityResolver()
            {
                public InputSource resolveEntity( String publicId, String systemId )
                    throws SAXException, IOException
                {
                    return new InputSource( new StringReader( "" ) );
                }
            } );
        }
        r = builder.build( is );
    }
    catch ( JDOMException e )
    {
        throw new RuntimeException( "Error processing resource " + resource + ": " + e.getMessage(), e );
    }

    if ( doc == null )
    {
        doc = r;
    }
    else
    {
        Element root = r.getRootElement();

        for ( @SuppressWarnings( "unchecked" )
        Iterator<Attribute> itr = root.getAttributes().iterator(); itr.hasNext(); )
        {
            Attribute a = itr.next();
            itr.remove();

            Element mergedEl = doc.getRootElement();
            Attribute mergedAtt = mergedEl.getAttribute( a.getName(), a.getNamespace() );
            if ( mergedAtt == null )
            {
                mergedEl.setAttribute( a );
            }
        }

        for ( @SuppressWarnings( "unchecked" )
        Iterator<Content> itr = root.getChildren().iterator(); itr.hasNext(); )
        {
            Content n = itr.next();
            itr.remove();

            doc.getRootElement().addContent( n );
        }
    }
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:59,代码来源:XmlAppendingTransformer.java

示例2: XML2JDOM

import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
/**
 * Generates a Document from a XML input stream
 * 
 * @param is the input xml stream
 * @throws JDOMException if something goes wrong during the parsing process
 * @throws IOException if something goes wrong reading stream
 */
public static void XML2JDOM(Reader is, Document doc) throws IOException, JDOMException {
    Document tdoc = new Document();
    SAXBuilder builder = new SAXBuilder();
    builder.setExpandEntities(false);
    builder.setEntityResolver(new MyResolver());
    tdoc = builder.build(is);
    Element root = tdoc.getRootElement();
    Element new_root = (Element) root.clone();
    doc.setRootElement(new_root);
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:18,代码来源:JDOMUtils.java

示例3: XML2JDOM

import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
/**
 * Generates a Document from a XML input stream
 * 
 * @param is the input xml stream
 * @throws Exception if something goes wrong during the parsing process
 */
public static void XML2JDOM(Reader is, Document doc) throws Exception {
    Document tdoc = new Document();
    SAXBuilder builder = new SAXBuilder();
    builder.setExpandEntities(false);
    builder.setEntityResolver(new MyResolver());
    tdoc = builder.build(is);
    Element root = tdoc.getRootElement();
    Element new_root = (Element) root.clone();
    doc.setRootElement(new_root);
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:17,代码来源:JDOMUtils.java


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