初学XML

 

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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"
  version="3.0"
  metadata-complete="true">  

    <description>
      Servlet and JSP Examples.
    </description>
    <display-name>Servlet and JSP Examples</display-name>

    <!-- Define example filters -->
    <filter>
        <filter-name>Timing filter</filter-name>
        <filter-class>filters.ExampleFilter</filter-class>
        <init-param>
            <param-name>attribute</param-name>
            <param-value>filters.ExampleFilter</param-value>
        </init-param>
    </filter>

</web-app>

    如上的XML文档: 一个格式良好有效的XML文档指的是遵守了XML文档基本规则,而且定义了语义约束。

 <xsd:complexType name="servlet-mappingType">
    <xsd:annotation>
      <xsd:documentation>

        The servlet-mappingType defines a mapping between a
        servlet and a url pattern. 
        Used in: web-app
        
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="servlet-name"
                   type="javaee:servlet-nameType"/>
      <xsd:element name="url-pattern"
                   type="javaee:url-patternType"
                   minOccurs="1"
                   maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute name="id"
                   type="xsd:ID"/>
  </xsd:complexType>
    上面的文档是Schema文档中的一部分,它对ServletMapping类型进行约束。

 

你可能感兴趣的:(xml)