Article From:


eXtendsible markup language Extensible Markup Language

XML Function

  1. Used to save data.
  2. Used for configuration files.
  3. Data transmission carrier.

XML Document Statement

    Simple statement: version: What version of parser is used when parsing this XML?& lt;? XML version= "1.0"? & gt;Encoding: What to use when parsing text in XMLCoding& lt;? XML version = 1.0 encoding = utf-8? & gt;Standalone: no - This document has been associated with other documents yes since the meeting- This is a stand-alone document& lt;? XML version = 1.0"encoding = utf-8" standalone = "no"? & gt;

Element Definition (Label)

  1. Use & lt; & gt; enclosed is that most elements appear in pairs, such as:
  2. The first element after a document declaration is called the root element (root tag).
  3. Labels can be nested within them.
  4. Closed labels (not in pairs) such as
    <zbuter />
  5. Tags can be customized.

    xmlElements must follow the naming rules:Names can contain alphanumeric and other charactersNames cannot begin with numbers or punctuation marks.Names cannot begin with the character "xml" (case-insensitive)Name cannot contain spacesNaming is as simple as possible.

Simple Elements and Complex Elements

  • Simple elements

Elements contain plain text

  • Complex elements

Other elements can also be nested inside the element.

Definition of Attribute

Defined in an element, & lt; element name attribute name = “attribute value” & gt;


Zhang San

<!ELEMENT stus (stu)>  : stus There's an element stu below, but there's only one& lt;! ELEMENT stu (name, age) & gt; there are two elements under stu: name, age order must be name-age<!ELEMENT name (# PCDATA) & gt;& lt;! ELEMENT age (#PCDATA) & gt;& lt;! ATTLIST stu ID CDATA #IMPLIED>Stu has an attribute text type, which is optionalNumber of elements:+One or more* Zero or moreZero or oneType Definition of AttributesCDATA: Attributes are plain textID: The value of an attribute must be unique& lt;! ELEMENT stu (name, age) & gt; in order<!! ELEMENTStu (name | age) & gt; two can contain only one child element


In fact, it's an xml. Using xml's grammar rules, XML parser is more convenient to parse, in order to replace DTD.But Schema constrains more text content than DTD. So there is no real alternative to DTD at present.Constraint documents:& lt;! - xmlns: XML namespace: namespace / namespaceTargetNamespace: Target namespace. Defined belowThose elements are bound to the namespace.ElementFormDefault: Element formatting. -->& lt; schema xmlns = "http://www.w3.o"Rg/2001/XML Schema“TargetNamespace= ""ElementFormDEfault= "qualified" & gt;& lt; element name = "teachers" & gt;& lt; complexType & gt;& lt; sequence maxOccurs= "unbounded" & gt;& lt;! - This is a complex element - & gt;& lt; element name = "teacher" & gt;& lt; complexType & gt;& lt; sequence & gt;& lt;! - The following two are simple elements - & gt;& lt; element name = "name" type = "string" & gt; & lt; / element & gt;& lt; element name = "age" type = "int" & gt; & lt; / element & gt;& lt; / Sequence & gt;& lt; / complexType & gt;< /elEment>& lt; / Sequence & gt;& lt; / complexType & gt;< /element>& lt; / schema & gt;Example documents:& lt;? XML version = "1.0" encoding = "UTF-8"? & gt;<! - XMLns: xsi: This must be written in such a way that the value is fixed.Xmlns: This is a namespace, fixed, written as the top target namespace in the schemaXsi: schemaLocaThere are two segments: the first half is the namespace, which is also the value of the target space, and the second is the path of the constrained document.-->< teachersXmlns: xsi= "http:// Schema-instance“Xmlns= ""Xsi:sChemaLocation= "">& lt; teacher & gt;& lt; name & gt; Zhangsan & lt; / Name & gt;& lt; age & gt; 19 & lt; / age & gt;< /teacheR>& lt; teacher & gt;& lt; name & gt; Lisi & lt; / Name & gt;& lt; age & gt; 29< /age>& lt; / Teacher & gt;& lt; teacher & gt;& lt; name & gt; Lisi & lt; / NaMe>& lt; age & gt; 29 & lt; / age & gt;& lt; / Teacher & gt;& lt; / teachers & gt;

The Role of Namespaces

If an XML wants to specify its constraint rules, assuming that DTD is used, then the XML can only specify one DTD, not multiple DTDs. But if an XML constraint is defined in a schema and there are multiple schemas, thenYes. Simply put: An XML can refer to multiple schema constraints. But only one DTD constraint can be referenced.

The function of namespaces is to specify which set of constraints the element uses when it is written. By default, if there is only one set of rules, it can be written as follows

<name>Zhang San & lt; / Name & gt;& lt; aa: name & gt; & lt; / aa: name & gt;& lt; bb: name & gt; & lt; / bb: name & gt;


Actually, the server is a computer. Configuration is better than usual.

Tomcat Installation

  1. Unzip and find bin/startup.bat

  2. install

After startup, if you can see the black window normally, it indicates that the installation has been successful. In order to make sure everything is right, it’s best to enter http://localhost:8080 in the browser’s address bar. If you see the content, it indicates success.

  1. If you double-click startup. bat and see a flash, it’s usually JDK environment variables that are not configured.

Introduction to Tomcat Catalogue


 It contains some jar, bat files. Startup.bat


tomcatConfiguration server. XML web. XML


tomcatRunning the required jar files


Running log files


Temporary file


Items published to Tomcat servers are stored in this directory.


jspTranslate to class file repository

Publish a project to Tomcat

Let other computers access the resources on my computer. Stu.xml

localhost : Native address

1. Copy this file to webapps/ROOT in Tomcat and access it in browser:


* Create a new folder XML under webaps, and then copy the files into the folder


    http://localhost:8080 : In fact, it corresponds to webapps / rootHttp://localhost:8080/xml/: corresponding to webapps/xmlAccess using IP address:Http://

  • Find the host element node in conf/server.xml.

  • Add the following.

       <!-- docBase :  The path address of the projectPath: The corresponding virtual path must start with/ -->& lt; Context docBase = "D: javawebtest" path ="/ a" & gt; & lt/ Context & gt;
  • Enter: http://localhost:8080/a/stu.xml in the browser address bar

  • Create a new XML file under the Tomcat / conf / Catalina / localhost / folder, and the name can be defined by itself. Person.xml

  • Write the following in this file

    <?xml version='1.0' encoding='utf-8'?>
    <Context docBase="D:\javawebtest"></Context>
  • Access on the browser

    http://localhost:8080/zbuter/stu.xmlName is enough.
  • Configure Tomcat for Eclipse

    1. Create a new Dynamic Web Project and select the corresponding Tomcat version to complete
    2. In the server below, right-click to create a new server, select Apache classification, find the corresponding Tomcat version, and then configure step by step.
    3. After configuring, right-click the server in the server, then open, find the Server Location above, and select Use Tomcat installation in the middle.
    4. Create a web project, define HTML files under WebContent, right-click project, run as server
    5. Browser window input http://localhost:8080/[project name]/[file name.extension]

    Link of this Article: Java Web Foundation

    Leave a Reply

    Your email address will not be published. Required fields are marked *