这种要求的dtd该怎么写啊?

03-12-01 agilejava

<?xml version="1.0" encoding="GBK"?>
"file://D:/eclipse/workspace/common/bin/com/gongtry/common/util/validator/test/validator.dtd">
<validators>
	<validator name="addUserTask" beanUrl="D:/eclipse/workspace/common/bin/com/gongtry/common/util/validator/test/bean.xml">
		<property name="name">
			<validatorBean id="notNull" message="不能为空"/>		
		</property>
		<property name="password">
			<validatorBean id="len" message="长度必须符合要求大于等于6并且小于等于14"/>				
			<validatorBean id="notNull" message="不能为空"/>					
		</property>	
		<property name="group">
				<validatorBean id="notNull" message="不能为空"/>					
		</property>				
	</validator>
	
	<validator name="addGroupTask"  beanUrl="D:/eclipse/workspace/common/bin/com/gongtry/common/util/validator/test/bean.xml">
		<property name="name">
			<validatorBean id="notNull" message="不能为空"/>		
		</property>
		<property name="password">
			<validatorBean id="len" message="长度必须符合要求大于等于6并且小于等于14"/>				
			<validatorBean id="notNull" message="不能为空"/>					
		</property>	
		<property name="group">
				<validatorBean id="notNull" message="不能为空"/>					
		</property>				
	</validator>
</validators>
<p>

针对这个xml文件,我定义了一个dtd

<?xml version="1.0" encoding="GBK" ?>
<!ELEMENT validators ( validator+ ) >

<!ELEMENT validatorBean EMPTY >
<!ATTLIST validatorBean message NMTOKEN #IMPLIED>
<!ATTLIST validatorBean id NMTOKEN #REQUIRED>

<!ELEMENT validator ( property+ ) >
<!ATTLIST validator name ID #REQUIRED ><!DOCTYPE validators SYSTEM 
<!ATTLIST validator beanUrl CDATA #REQUIRED >

<!ELEMENT property ( validatorBean+ ) >
<!ATTLIST property name ID #REQUIRED >
<p>

现在我想property的name属性在每一个validator中是惟一的, 但在xml文件中可以不同,也就是说在另一个validator中的property的name属性可以具有相同的值,这怎么做到?

还有就是怎么让xml解析器找到这个dtd文件,每次我都要写全路径,有没有别的办法啊?

请高人指点,谢谢!:)

猜你喜欢