本文整理汇总了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 );
}
}
}
示例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);
}
示例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);
}