Java_xml_dtd约束规范实例

本博文为子墨原创,转载请注明出处!
http://blog.csdn.net/zimo2013/article/details/8963579

Download dtd帮助文档

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE CATALOG [
<!--元素就是标签-->
<!ENTITY AUTHOR "John Doe">   <!--表示AUTHOR代表后面的内容信息 可以使用&AUTHOR;调用-->
<!ENTITY COMPANY "JD Power Tools, Inc.">
<!ENTITY EMAIL "[email protected]">

<!ELEMENT CATALOG (PRODUCT+)>  <!--表示CATALOG标签里面可以放入一个或者多个PRODUCT标签-->

<!ELEMENT PRODUCT   <!--表示PRODUCT标签里面可以包含下面的四个同一等级的标签-->
(SPECIFICATIONS+,OPTIONS?,PRICE+,NOTES?)> 	<!--+?*与正则表达式一样,+表示一个或者多个 ?表示一个或者0个 *表示0个或者多个-->
<!ATTLIST PRODUCT  <!--表示PRODUCT下的属性信息 比如<PRODUCT NAME="nameInfo">-->
NAME CDATA #IMPLIED<!--#IMPLIED表示可写可不写-->
CATEGORY (HandTool|Table|Shop-Professional) "HandTool"<!--在枚举中选择一个,不写则为默认值-->
PARTNUM CDATA #IMPLIED
AGE CDATA #REQUIRED<!--必须要写的-->
PLANT (Pittsburgh|Milwaukee|Chicago) "Chicago"
INVENTORY (InStock|Backordered|Discontinued) "InStock">

<!ELEMENT SPECIFICATIONS (#PCDATA)>
<!ATTLIST SPECIFICATIONS
WEIGHT CDATA #IMPLIED
POWER CDATA #IMPLIED>

<!ELEMENT OPTIONS (#PCDATA)>
<!ATTLIST OPTIONS
FINISH (Metal|Polished|Matte) "Matte" 
ADAPTER (Included|Optional|NotApplicable) "Included"
CASE (HardShell|Soft|NotApplicable) "HardShell">

<!ELEMENT PRICE (#PCDATA)>
<!ATTLIST PRICE
MSRP CDATA #IMPLIED
WHOLESALE CDATA #IMPLIED
STREET CDATA #IMPLIED
SHIPPING CDATA #IMPLIED>

<!ELEMENT NOTES (#PCDATA)>

]>

<CATELOG>
	<PRODUCT NAME="HAHA" CATEGORY="Table" AGE="ss">
		<SPECIFICATIONS WEIGHT="S">&AUTHOR;</SPECIFICATIONS>
		<OPTIONS>OPTIONS</OPTIONS>
		<PRICE>ZZZZ</PRICE>
		<NOTES>ZZZZ</NOTES>
	</PRODUCT>
	<PRODUCT NAME="HAHA" CATEGORY="Table">
		<SPECIFICATIONS WEIGHT="S">&AUTHOR;</SPECIFICATIONS>
		<OPTIONS>OPTIONS</OPTIONS>
		<PRICE>ZZZZ</PRICE>
		<NOTES>ZZZZ</NOTES>
	</PRODUCT>
</CATELOG>


 

你可能感兴趣的:(xml,标签,dtd)