XSD reference (or DTD reference) learning for the Web. xml file

Source: Internet
Author: User
Tags xsd example

1. Why Web. XML has different versions of the XSD reference:

  JDK dependent change;

or the servlet (JAVA EE) itself API changes;

2. Why there is a difference between DTD and XSD two versions

As I saw in this article, the author seems to have copied an API note:

 

There is, ways to specify, the schema for a, the Web. xml file (Deployment descriptor). Dtd-document Type definitionxsd-xml Schema definitionthe XSD version is preferred since JSP 2.0/servlets 2.4 (eg:to MCAT 5.5). Note that the XML encoding can is specified as Iso-8859-1, UTF-8, or any other valid encoding in either version, and Shoul D match the actual encoding of your text file. XSD Example for JSP 2.1/servlets 2.5 (Tomcat 6.0): <?xml version= "1.0" encoding= "iso-8859-1"? ><web-app xmlns= "HT Tp://java.sun.com/xml/ns/j2ee "xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation="/HTTP/ JAVA.SUN.COM/XML/NS/J2EE http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd "version=" 2.5 "></web-app>xsd Example for JSP 2.0/servlets 2.4 (Tomcat 5.5): <?xml version= "1.0" encoding= "iso-8859-1"? ><web-app xmlns= "http: Java.sun.com/xml/ns/j2ee "xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "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>dtd example for JSP 1.2/ Servlets 2.3 (Tomcat 5): <?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.d TD "><web-app></web-app>

 

Here, too, the DTD is the way of early support, using XSD as much as possible later. Why XSD becomes a trend, here's a good note on "How to use XSD", "dtd,xsd differences and Applications in XML".

DTD versus xsd: DTDs are written using non-XML syntax.

DTDs are not extensible, namespaces are not supported, and only a very limited number of data types are available.

3. Web. xml Several versions of the list

Web. XML v2.3

<? 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></web-app>

Web. XML v2.4

<Web-app id="Webapp_9" version="2.4" xmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE"

xmlns:xsi="Http://www.w3.org/2001/XMLSchema-instance"

xsi:schemalocation="Http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >

</Web-app>

Web. XML v2.5

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

xmlns:xsi="Http://www.w3.org/2001/XMLSchema-instance"

xsi:schemalocation="Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

version="2.5">

</Web-app>

Web. Xml v3.0

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

<Web-app version="3.0" xmlns="Http://java.sun.com/xml/ns/javaee"

xmlns:xsi="Http://www.w3.org/2001/XMLSchema-instance"

xsi:schemalocation="Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" >

</Web-app>

XSD reference (or DTD reference) learning for the Web. xml file

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.