ant从xml文件中删除行
我想用ant脚本删除所有的doctypeant从xml文件中删除行,ant,Ant,我想用ant脚本删除所有的doctype <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > 我仅成功删除我尝试了此解决方案: replac
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
我仅成功删除
我尝试了此解决方案:
replaceregexp >
<regexp pattern="<DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >"/>
<substitution expression=""/>
<fileset file="${subproject.build.pre-dist.dir}/WEB-INF/struts-config.xml">
</fileset>
</replaceregexp>
使用正则表达式操作xml文档非常容易出错。使用XML文档并进行更改。试试groovy:
replaceregexp >
<regexp pattern="<DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >"/>
<substitution expression=""/>
<fileset file="${subproject.build.pre-dist.dir}/WEB-INF/struts-config.xml">
</fileset>
</replaceregexp>
<target name="test" depends ="init">
<loadfile
srcfile="${subproject.build.pre-dist.dir}/WEB-INF/struts-config.xml"
property="src.file.head1">
<filterchain>
<headfilter lines="-1" skip="3"/>
</filterchain>
</loadfile>
<echo file ="${subproject.build.pre-dist.dir}/WEB-INF/struts-config.xml"
message="<?xml version="1.0" encoding="UTF-8"?>
${src.file.head1}"/>
</target>