The relationship between schema, DTD, and XML

Source: Internet
Author: User
Tags xmlns

XML files support Any user-defined element, schema (i.e.. xsd file, XML Schema document) and DTD (i.e.. dtd file, document Type definition) are further constraints on the XML file. This means that an XML file, such as Web. xsd, can not use any custom element after it has been introduced into a, or, the. xsd or. dtd file, and the type, number, and order of the elements must also be restricted.


==========================================schema====================================

============

Schema is the professional term for patterns , and every web. XML is

What elements can be used in 1xml files, such as the web-app_2.4.xsd can use <display-name>, welcome-file-list and other elements, in web-app_2.4. XSD does not have a specified element that is not available for use: This is why, such as the following Web. XML configuration, will error "element" mvc:interceptors "prefix" MVC "unbound", that is because the introduction of web-app_2_4.xsd, such as the XSD file does not have the definition of MVC, so it is not used.

<?xml version= "1.0" encoding= "UTF-8"?>
<web-app
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE"
Xmlns:javaee= "Http://java.sun.com/xml/ns/javaee" xmlns:web= "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemalocation= "Http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version= "2.4" >
<display-name>aaa</display-name>
<welcome-file-list>
<welcome-file>index.do</welcome-file>
</welcome-file-list>


<!--login control blocker--
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path= "/**"/>
<mvc:exclude-mapping path= "/login.do"/>
<bean class= "Org.bjlx.base.login.AuthInterceptor" ></bean>
</mvc:interceptor>
</mvc:interceptors>
</web-app>

2 type, number, order, etc.).


============

such as Web. XML:

<?xml version= "1.0" encoding= "UTF-8"?> <web-app
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE"
Xmlns:javaee= "Http://java.sun.com/xml/ns/javaee" xmlns:web= "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemalocation= "Http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

version= "2.4">

</web-app> Web. XML is first to include its schema,schema in <web-app> (the red part), meaning that this XML is the constraint in the XSD file that is referenced by the web, such as Web-app_ 2_4.xsd and so on. Once you have defined one or more schema references in <web-app>, Web. XML must adhere to the schema, the constraints in the. xsd file, the elements that are not in the XSD file when Web. XML is not available. In addition, the XSD also limits the type, number, order, and so on.


==========================================DTD====================================

DTD files, as well as further restrictions on XML files. If a Web. XML introduces Web-app_2_3.dtd, the Web. XML is bound to the WEB-APP_2_3.DTD element, the element that is not in Web-app_2_3.dtd, and Web. XML is not available.

<?xml version= "1.0" encoding= "Iso-8859-1"?>
<! DOCTYPE Web-app
Public "-//sun Microsystems, INC.//DTD Web application 2.3//en"
"Http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>online Store application</display-name>
</web-app>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.