给eclipse xml编辑器增加xml提示

一般的,有些xml模板并不会在根节点给出dtd的信息,只在文件头部给出.让eclipse无法自动提示.
比如:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperTemplate PUBLIC "-//JasperReports//DTD Template//EN" "http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd">

<jasperTemplate>
	<style name="borderColor">
		<
		<box>
			<topPen lineWidth="1.0"/>
			<leftPen lineWidth="1.0"/>
			<bottomPen lineWidth="1.0"/>
			<rightPen lineWidth="1.0"/>
			
		</box>
	</style>
</jasperTemplate>


1.通过文件头部信息,去http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd下载jaspertemplate.dtd文件,并放入eclipse的某一个文件夹下面,
比如:
D:\dev-soft\eclipse-jee-indigo-SR2-win32-x86_64\eclipse\dropins\jaspertemplate.dtd

2.然后设定这个dtd的xml信息:注意最后一个选项是key type=URI
windows --> preferences --> Myeclipse --> Files and Editors --> XML --> XML Catalog
--> add... --> Location --> File System...--> 添加附件中的文件(找到这个dtd的位置,并添加到输入框来.) -->
Key Type --> URI
key --> http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd

然后确定

3.修改xml文件,在根节点增加xsi:schemaLocation信息.< 这里可以不用>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperTemplate PUBLIC "-//JasperReports//DTD Template//EN" "http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd">

<jasperTemplate xsi:schemaLocation="http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd">
	<style name="borderColor">
		<box>
			<topPen lineWidth="1.0"/>
			<leftPen lineWidth="1.0"/>
			<bottomPen lineWidth="1.0"/>
			<rightPen lineWidth="1.0"/>
			
		</box>
	</style>
</jasperTemplate>


4.可以自动提示了.

你可能感兴趣的:(给eclipse xml编辑器增加xml提示)