当前位置:网站首页>DTD constraints

DTD constraints

2022-06-22 08:03:00 Chasing dream Zichen

1. What is? DTD?
Document type definition (document type definition) ( constraint )

2. What is? XML?
HTML: Hypertext markup language
XML: Extensible markup language

3.XML Two document constraints for
DTD and Schema

4.XML Format requirements ( legal XML)
1) With and only one root node ;
2) It consists of a start tag and an end tag ;
3)XML Label case sensitive ;
4) Nesting labels correctly ;
5) Use legal tag name , Do not use special symbols ;
6) Define valid properties ;

5. Use DTD
5.1 stay XML Add DTD Affirming
1) Internal statement :
2) An external statement :
5.2 Element definition syntax (DTD Restrictions on elements )
Basic grammar :<!ELEMENT The element name Element type >
Element classification :EMPTY Empty elements

(#PCDATA) Text elements
(e1,e2) Mixed elements
Element limits :,( The order )、|( or , A commonplace )、?(0 or 1 Time ),(10=0,0 Times or times ), +(1+0=1,1 Times or times )
5.3 Attribute definition syntax (DTD Restrictions on attributes )
Basic grammar :<!ATTLIST The element name The attribute name Attribute types Setting instructions >
Attribute types :ID/CDATA/ENUM ( male | Woman ) “ male ” IDREF

Setting instructions :#REQUIRED( must )/#IMPLIED( Optional )

5.4 Special symbol escape
&( Logic and ) --> &
>( Greater than ) --> >
<( Less than ) --> <
‘( Single quotation marks ) --> '
“( Double quotes ) --> "

Code case

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app[
        <!ELEMENT web-app (display-name,context-param,listener+,filter,filter-mapping,servlet,servlet-mapping,welcome-file-list) >
        <!ELEMENT display-name (#PCDATA) >
        <!ELEMENT context-param (param-name,param-value) >
        <!ELEMENT param-name (#PCDATA) >
        <!ELEMENT param-value (#PCDATA) >
        <!ELEMENT listener (listener-class) >
        <!ELEMENT listener-class (#PCDATA) >
        <!ELEMENT filter (filter-name,filter-class,async-supported,init-param) >
        <!ELEMENT filter-name (#PCDATA) >
        <!ELEMENT filter-class (#PCDATA) >
        <!ELEMENT async-supported (#PCDATA) >
        <!ELEMENT init-param (param-name,param-value) >
        <!ELEMENT filter-mapping (filter-name,url-pattern) >
        <!ELEMENT url-pattern (#PCDATA) >
        <!ELEMENT servlet (servlet-name,servlet-class,init-param,load-on-startup,async-supported) >
        <!ELEMENT servlet-name (#PCDATA) >
        <!ELEMENT servlet-class (#PCDATA) >
        <!ELEMENT load-on-startup (#PCDATA) >

        <!ELEMENT servlet-mapping (servlet-name,url-pattern) >

        <!ELEMENT welcome-file-list (welcome-file) >
        <!ELEMENT welcome-file (#PCDATA) >

        ]>

<web-app>
<display-name>Archetype Created Web Application</display-name>
        <!-- Spring and web Project integration start -->
        <!-- spring Context profile  -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
        <!--  Read Spring Context listener  -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
        <!-- Spring and web Project integration end -->

        <!--  prevent Spring Memory overflow listener  -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>

        <!--  Chinese scrambling  -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<async-supported>true</async-supported>
<init-param>
  <param-name>encoding</param-name>
  <param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern> </filter-mapping> <!-- Spring MVC servlet --> <servlet> <servlet-name>SpringMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- This parameter can not be configured , The default value is :/WEB-INF/springmvc-servlet.xml--> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <!--web.xml 3.0 New features , Is asynchrony supported --> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>SpringMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/home/index.shtml</welcome-file> </welcome-file-list> </web-app> 
原网站

版权声明
本文为[Chasing dream Zichen]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220800135093.html