XML基础教程第11章 XML在线成绩管理系统
XML建模实例---学生成绩与信息表

</xs:sequence> <xs:attributeGroup ref="contactypeGroup"/> </xs:complexType>
一、schema ቤተ መጻሕፍቲ ባይዱ档:
以 下 是 stu.xsd 用 来 规 定 XML 中 的 元 素 和 属 性 。 <xs:element name="stu" type="stutype"/>对于 stu 来说他是 stutype 类型,接下来定义 stutype 类型: <xs:complexType name="stutype">
</xs:attributeGroup>
其中包括 tel、和 email 两个都是可选择的。
<xs:element name="sex" type="sextype"/>性别属性: <xs:simpleType name="sextype">
<xs:restriction base="xs:string"> <xs:enumeration value="男"/> <xs:enumeration value="女"/>
易语言-XML教学

写入XML文件
注意事项
使用易语言的文件操作函数,打 开XML文件并读取其中的内容。
使用易语言的文件操作函数,创 建或打开一个XML文件,并将数 据写入其中。
在读取和写入XML文件时,需要 注意文件的编码格式和数据的格 式化。
案例二:易语言中XML的解析和生成
解析XML数据
使用易语言的XML解析库, 将XML字符串或文件解析成 易语言的数据结构。
03
促进跨学科融合
易语言-XML教学可以与其他学科如 数学、物理等进行融合,通过编程实 现各种计算和分析,增强学生对其他 学科的理解和应用能力。
易语言-XML教学的发展断发展, 易语言-XML教学将逐渐普 及,成为更多学校和学生的 选择。
未来易语言-XML教学将更 加专业化,针对不同领域和 行业的需求,开发更加专业 化的教学内容和工具。
生成XML数据
使用易语言的XML库,将易 语言的数据结构转换为XML 格式的字符串或文件。
注意事项
在解析和生成XML数据时, 需要注意数据的完整性和准 确性。
案例三:易语言中XML的数据绑定和显示
数据绑定
将易语言中的数据对象与XML数据进行绑定,实现数 据的同步更新。
数据显示
使用易语言的界面库,将绑定的XML数据显示在界面 上。
详细描述
XML元素是由开始标签、结束标签和标签之间的内容组成。开始标签和结束标签分别表示元素的开始 和结束,标签之间的内容是元素的具体内容。此外,XML还支持属性和文本内容,属性提供关于元素 的附加信息,文本内容则是元素的具体数据。
XML的应用场景和优势
总结词
XML广泛应用于数据交换、存储和呈现等领 域。
易语言的编程基础
XML基础教程(Tutorials Point)说明书

About the T utorialXML stands for Ex tensible M arkup L anguage and is a text-based markup language derived from Standard Generalized Markup Language (SGML).This tutorial will teach you the basics of XML. The tutorial is divided into sections such as XML Basics, Advanced XML, and XML tools. Each of these sections contain related topics with simple and useful examples.AudienceThis reference has been prepared for beginners to help them understand the basic to advanced concepts related to XML. This tutorial will give you enough understanding on XML from where you can take yourself to a higher level of expertise. PrerequisitesBefore proceeding with this tutorial, you should have basic knowledge of HTML and JavaScript.Copyright & DisclaimerCopyright 2018 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher.We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or inthistutorial,******************************************T able of ContentsAbout the Tutorial (i)Audience (i)Prerequisites (i)Copyright & Disclaimer (i)Table of Contents (ii)XML BASICS (1)1.XML – Overview (2)XML Usage (2)What is Markup? (3)Is XML a Programming Language? (3)2.XML – Syntax (4)3.XML – Documents (9)Document Prolog Section (9)Document Elements Section (10)4.XML – Declaration (11)5.XML – Tags (14)Start Tag (14)End Tag (14)Empty Tag (14)XML Tags Rules (15)6.XML – Elements (16)Empty Element (16)XML Elements Rules (17)7.XML – Attributes (18)Attribute Types (19)Element Attribute Rules (20)8.XML – Comments (21)XML Comments Rules (21)9.XML – Character Entities (22)Types of Character Entities (22)10.XML – CDATA Sections (24)CDATA Rules (25)11.XML – Whitespaces (26)Significant Whitespace (26)Insignificant Whitespace (26)12.XML – Processing (27)Processing Instructions Rules (28)13.XML – Encoding (29)Encoding Types (29)14.XML – Validation (31)Well-formed XML Document (31)Valid XML Document (32)ADVANCE XML (33)15.XML – DTDs (34)Internal DTD (34)External DTD (36)Types (37)16.XML – Schemas (39)Definition Types (40)17.XML – Tree Structure (42)18.XML – DOM (45)19.XML – Namespaces (47)Namespace Declaration (47)20.XML – Databases (48)XML Database Types (48)XML- Enabled Database (48)XML TOOLS (50)21.XML – Viewers (51)Text Editors (51)Firefox Browser (52)Chrome Browser (52)Errors in XML Document (52)22.XML – Editors (54)Open Source XML Editors (54)23.XML – Parsers (55)24.XML – Processors (56)Types (56)XML Basics11.XML stands for E xtensible M arkup L anguage. It is a text-based markup language derived from Standard Generalized Markup Language (SGML).XML tags identify the data and are used to store and organize the data, rather than specifying how to display it like HTML tags, which are used to display the data. XML is not going to replace HTML in the near future, but it introduces new possibilities by adopting many successful features of HTML.There are three important characteristics of XML that make it useful in a variety of systems and solutions:∙XML is extensible: XML allows you to create your own self-descriptive tags or language, that suits your application.∙XML carries the data, does not present it: XML allows you to store the data irrespective of how it will be presented.∙XML is a public standard: XML was developed by an organization called the World Wide Web Consortium (W3C) and is available as an open standard.XML UsageA short list of XML usage says it all:∙XML can work behind the scene to simplify the creation of HTML documents for large web sites.∙XML can be used to exchange the information between organizations and systems.∙XML can be used for offloading and reloading of databases.∙XML can be used to store and arrange the data, which can customize your data handling needs.∙XML can easily be merged with style sheets to create almost any desired output.∙Virtually, any type of data can be expressed as an XML document.2What is Markup?XML is a markup language that defines set of rules for encoding documents in a format that is both human-readable and machine-readable. So, what exactly is a markup language? Markup is information added to a document that enhances its meaning in certain ways, in that it identifies the parts and how they relate to each other. More specifically, a markup language is a set of symbols that can be placed in the text of a document to demarcate and label the parts of that document.Following example shows how XML markup looks, when embedded in a piece of text:This snippet includes the markup symbols, or the tags such as <message>...</message> and <text>... </text>. The tags <message> and </message> mark the start and the end of the XML code fragment. The tags <text> and </text> surround the text Hello, world!. Is XML a Programming Language?A programming language consists of grammar rules and its own vocabulary which is used to create computer programs. These programs instruct the computer to perform specific tasks. XML does not qualify to be a programming language as it does not perform any computation or algorithms. It is usually stored in a simple text file and is processed by special software that is capable of interpreting XML.32.In this chapter, we will discuss the simple syntax rules to write an XML document. Following is a complete XML document:You can notice, there are two kinds of information in the above example: ∙Markup, like <contact-info>∙The text, or the character data, Tutorials Point and (040) 123-4567The following diagram depicts the syntax rules to write different types of markup and text in an XML document.Let us see each component of the above diagram in detail.4XML DeclarationThe XML document can optionally have an XML declaration. It is written as follows:Where version is the XML version and encoding specifies the character encoding used in the document.Syntax Rules for XML Declaration∙The XML declaration is case sensitive and must begin with "<?xml>" where "xml"is written in lower-case.∙If the document contains XML declaration, then it strictly needs to be the first statement of the XML document.∙The XML declaration strictly needs be the first statement in the XML document.∙An HTTP protocol can override the value of encoding that you put in the XML declaration.T ags and ElementsAn XML file is structured by several XML-elements, also called XML-nodes or XML-tags. The names of XML-elements are enclosed in triangular brackets < > as shown below:Syntax Rules for Tags and ElementsElement Syntax: Each XML-element needs to be closed either with start or with end elements as shown below:or in simple-cases, just this way:Nesting of Elements: An XML-element can contain multiple XML-elements as its children, but the children elements must not overlap. i.e., an end tag of an element must have the same name as that of the most recent unmatched start tag.56The following example shows incorrect nested tags:The following example shows correct nested tags:Root Element: An XML document can have only one root element. For example, following is not a correct XML document, because both the x andy elements occur at the top level without a root element:The following example shows a correctly formed XML document:Case Sensitivity: The names of XML-elements are case-sensitive. That means the name of the start and the end elements need to be exactly in the same case.For example, <contact-info> is different from <Contact-Info>.XML AttributesAn attribute specifies a single property for the element, using a name/value pair. An XML-element can have one or more attributes. For example:Here href is the attribute name and / is attribute value.Syntax Rules for XML Attributes∙Attribute names in XML (unlike HTML) are case sensitive. That is,HREF and href are considered two different XML attributes.∙Same attribute cannot have two values in a syntax. The following example shows incorrect syntax because the attribute b is specified twice:∙Attribute names are defined without quotation marks, whereas attribute values must always appear in quotation marks. Following example demonstrates incorrect xml syntax:In the above syntax, the attribute value is not defined in quotation marks.XML ReferencesReferences usually allow you to add or include additional text or markup in an XML document. References always begin with the symbol "&" which is a reserved character and end with the symbol ";". XML has two types of references:∙Entity References: An entity reference contains a name between the start and the end delimiters. For example, & where amp is name. The name refers toa predefined string of text and/or markup.∙Character References: These contain references, such as A, contains a hash mark (“#”) followed by a number. The number always refers to the Unicode code of a character. In this case, 65 refers to alphabet "A".XML T extThe names of XML-elements and XML-attributes are case-sensitive, which means the name of start and end elements need to be written in the same case. To avoid character encoding problems, all XML files should be saved as Unicode UTF-8 or UTF-16 files.Whitespace characters like blanks, tabs and line-breaks between XML-elements and between the XML-attributes will be ignored.Some characters are reserved by the XML syntax itself. Hence, they cannot be used directly. To use them, some replacement-entities are used, which are listed below:783.An XML document is a basic unit of XML information composed of elements and other markup in an orderly package. An XML document can contain a wide variety of data. For example, database of numbers, numbers representing molecular structure or a mathematical equation.XML Document ExampleA simple document is shown in the following example:The following image depicts the parts of XML document.Document Prolog SectionDocument Prolog comes at the top of the document, before the root element. This section contains:∙XML declaration∙Document type declarationYou can learn more about XML declaration in this chapter : XML Declaration.Document Elements SectionDocument Elements are the building blocks of XML. These divide the document into a hierarchy of sections, each serving a specific purpose. You can separate a document into multiple sections so that they can be rendered differently, or used by a search engine. The elements can be containers, with a combination of text and other elements.9You can learn more about XML elements in this chapter : XML Elements104.This chapter covers XML declaration in detail. XML declaration contains details that prepare an XML processor to parse the XML document. It is optional, but when used, it must appear in the first line of the XML document.SyntaxFollowing syntax shows XML declaration:Each parameter consists of a parameter name, an equals sign (=), and parameter value inside a quote. Following table shows the above syntax in detail:11RulesAn XML declaration should abide with the following rules:∙If the XML declaration is present in the XML, it must be placed as the first line in the XML document.∙If the XML declaration is included, it must contain version number attribute.∙The parameter names and values are case-sensitive.∙The names are always in lower case.∙The order of placing the parameters is important. The correct order is:version, encoding and standalone.∙Either single or double quotes may be used.∙The XML declaration has no closing tag, i.e. </?xml>XML Declaration ExamplesFollowing are few examples of XML declarations:XML declaration with no parameters:XML declaration with version definition:XML declaration with all parameters defined:XML declaration with all parameters defined in single quotes:125.Let us learn about one of the most important part of XML, the XML tags. XML tags form the foundation of XML. They define the scope of an element in XML. They can also be used to insert comments, declare settings required for parsing the environment, and to insert special instructions.We can broadly categorize XML tags as follows:Start T agThe beginning of every non-empty XML element is marked by a start-tag. Following is an example of start-tag:End T agEvery element that has a start tag should end with an end-tag. Following is an example of end-tag:Note, that the end tags include a solidus ("/") before the name of an element.Empty T agThe text that appears between start-tag and end-tag is called content. An element which has no content is termed as empty. An empty element can be represented in two ways as follows:A start-tag immediately followed by an end-tag as shown below:A complete empty-element tag is as shown below:Empty-element tags may be used for any element which has no content.13End of ebook previewIf you liked what you saw…Buy it from our store @ https://14。
XML入门基础教程

�
</note>
�
� � �
文档的第1行:XML声明-定义此文档所遵循的XML标 准的版本,在这个例子里是1.0版本的标准,使用的 是ISO-8859-1 ,字符集。 文档的第2行是根元素(就象是说“这篇文档是一个便 条”); <note>文档的第3--6行描述了根元素的四个子节 点(to, from, heading,和 body): 文档的最后一行是根元素的结束:</note>
XML必须声明于XML文档的第一行 <?xml 之间不能有空格
version 版本号
encoding 编码标准 standalone 独立文档声明. “yes”或 “no” Version,encoding, standalone有顺序,且version 必须有
元素和属性
元素一般由开始标签,元素内容,结束标签组成. 是XML文档内容的基本单元;
XML
�什么是XML �XML与HTML的区别 �XML的用途 �XML文档的架构与写法
什么是XML
XML是EXtensible Markup Language的缩写 XML是一种类似于HTML的标记语言 XML是用来描述数据的 XML的标记不是在XML中预定义的,你必 须定义自己的标记 XML使用文档类型定义(DTD)或者模式 (Schema)来描述数据 XML只是用来组织、存储和发送信息的
DTD的调用
方式一:调用内部文档类型定义。 <?xml version="1.0" standalone="yes"?> <!DOCTYPE studinfo[<!ELEMENT studinfo (#PCDATA)>]> <studinfo> </studinfo> 注意点: (1) studinfo与(#PCDATA)有空格 (2) 文档类型名与根元素名必须一致 方式二:调用外部文档类型定义,需要写一个DTD 文档 <?xml version="1.0" standalone="no"?> <!DOCTYPE studinfo SYSTEM "studinfo1.dtd"> <studinfo> </studinfo>
ml基础教程课后习题解答

X M L基础教程课后习题解答内部编号:(YUUT-TBBY-MMUT-URRUY-UOOY-DBUYI-0128)XML基础教程课后习题习题一1.答:HTML是用来编写Web页的语言、不允许用户自定义标记,HTML体现数据的显示格式。
XML描述数据的组织结构、可自定义标记,其标记名称是对标记所包含的数据内容含义的抽象,而不是数据的显示格式。
2.答:使用UTF-8保存5.答:(1)不可以,(2)可以,(3)不可以6.答::time{ display:block;font-size:18pt;font-weight:bold}hour{ display:line;font-size:16pt;font-style:italic}mimute{ display:line;font-size:9pt;font-weight:bold}习题二1.答:(1)使用ANSI编码。
(2)可以。
(3)不合理。
2.答:不相同。
3.答:(1)和(2)。
4.答:。
5.答:“root”标记包含的文本内容都是空白字符。
“a1”标记包含的文本内容:<CCTV5>。
“a2”标记包含的文本内容: 子曰"有朋自远方来,不亦乐乎"。
习题三1.答:一个规范的XML文件如果和某个DTD文件相关联,并遵守该DTD文件规定的约束条件,就称之为有效的XML文件。
2.答:DTD文件的编码必须和其约束的XML文件的编码相一致。
3.答:无关。
4.答:(1) 使用SYSTEM文档类型声明的格式:<DOCTYPE 根标记的名称 SYSTEM "DTD文件的URI">(2) 使用PUBLIC文档类型声明的格式:<!DOCTYPE 根标记的名称 PUBLIC "正式公用标识符" "DTD文件的URI"> 5.答:一定。
6.答:(1)约束标记“张三”必须有“学号”属性(2)约束标记“张三”必须有“学号”属性,而且学号的属性值是固定的220123。
XML基础入门和简易教程.word精品文档45页

什么是XML资料引用:http://knowsky/343580.htmlxml即可扩展标记语言(eXtensible Markup Language)。
标记是指计算机所能理解的信息符号,通过此种标记,计算机之间可以处理包含各种信息的文章等。
如何定义这些标记,既可以选择国际通用的标记语言,比如HTML,也可以使用象XML这样由相关人士自由决定的标记语言,这就是语言的可扩展性。
XML是从SGML中简化修改出来的。
它主要用到的有XML、XSL 和XPath等。
上面这段是对XML的一个基本定义,一个被广泛接受的说明。
简单说,XML就是一种数据的描述语言,虽然它是语言,但是通常情况下,它并不具备常见语言的基本功能——被计算机识别并运行。
只有依靠另一种语言,来解释它,使它达到你想要的效果或被计算机所接受。
假如你是刚接触XML的新手,那么可能并无法从定义上是了解XML是什么。
也许,你可以换个角度来认识XML是什么;从应用面来认识XML,从XML可以做些什么来认识它,这应该能比那更空洞的定义对你更有帮助。
XML应用面主要分为两种类型,文档型和数据型。
下面介绍一下几种常见的XML应用:1、自定义XML+XSLT=>HTML,最常见的文档型应用之一。
XML存放整个文档的XML数据,然后XSLT将XML转换、解析,结合XSLT中的HTML标签,最终成为HTML,显示在浏览器上。
典型的例子就是CSDN上的帖子。
2、XML作为微型数据库,这是最常见的数据型应用之一。
我们利用相关的XML API(MSXML DOM、java DOM等)对XML进行存取和查询。
留言板的实现中,就经常可以看到用XML 作为数据库。
3、作为通信数据。
最典型的就是WEB SERVICE,利用XML来传递数据。
4、作为一些应用程序的配置信息数据。
常见的如J2EE配置WEB服务器时用的web.XML。
5、其他一些文档的XML格式。
如Word、Excel等。
XML基础教程课后习题解答

X M L基础教程课后习题习题一1.答:HTML是用来编写Web页的语言、不允许用户自定义标记,HTML体现数据的显示格式。
XML描述数据的组织结构、可自定义标记,其标记名称是对标记所包含的数据内容含义的抽象,而不是数据的显示格式。
2.答:使用UTF-8保存5.答:(1)不可以,(2)可以,(3)不可以6.答:Show.css:time{ display:block;font-size:18pt;font-weight:bold}hour{ display:line;font-size:16pt;font-style:italic}mimute{ display:line;font-size:9pt;font-weight:bold}习题二1.答:(1)使用ANSI编码。
(2)可以。
(3)不合理。
2.答:不相同。
3.答:(1)和(2)。
4.答:A3.xml。
5.答:“root”标记包含的文本内容都是空白字符。
“a1”标记包含的文本内容:<CCTV5>。
“a2”标记包含的文本内容:子曰"有朋自远方来,不亦乐乎"。
习题三1.答:一个规范的XML文件如果和某个DTD文件相关联,并遵守该DTD文件规定的约束条件,就称之为有效的XML文件。
2.答:DTD文件的编码必须和其约束的XML文件的编码相一致。
3.答:无关。
4.答:(1) 使用SYSTEM文档类型声明的格式:<DOCTYPE 根标记的名称 SYSTEM "DTD文件的URI">(2) 使用PUBLIC文档类型声明的格式:<!DOCTYPE 根标记的名称PUBLIC "正式公用标识符" "DTD文件的URI">5.答:一定。
6.答:(1)约束标记“张三”必须有“学号”属性(2)约束标记“张三”必须有“学号”属性,而且学号的属性值是固定的220123。
xml课课程设计学生管理系统

xml课课程设计学生管理系统一、教学目标本节课的教学目标是使学生掌握XML的基本概念、语法和应用,能够利用XML构建学生管理系统。
具体目标如下:1.知识目标:–了解XML的起源、发展和应用领域。
–掌握XML的基本语法,包括元素、属性、注释和实体。
–熟悉XML的解析方法,如DOM和SAX。
2.技能目标:–能够使用XML编辑器或编程语言编写XML文档。
–能够利用DOM或SAX解析XML文档,提取所需信息。
–能够设计并实现一个简单的学生管理系统,包括学生信息的增删改查功能。
3.情感态度价值观目标:–培养学生对新技术的兴趣和好奇心,提高学生的学习积极性。
–培养学生团队合作的精神,鼓励学生相互交流和分享。
二、教学内容教学内容分为四个部分:XML基本概念、XML语法、XML解析方法和学生管理系统设计。
1.XML基本概念:介绍XML的起源、发展和应用领域,使学生了解XML的重要性。
2.XML语法:详细讲解XML的元素、属性、注释和实体等基本语法,并通过示例让学生熟悉XML文档的编写。
3.XML解析方法:介绍DOM和SAX两种常用的XML解析方法,让学生了解如何利用编程语言解析XML文档。
4.学生管理系统设计:引导学生利用XML构建一个简单的学生管理系统,包括学生信息的增删改查功能。
三、教学方法本节课采用讲授法、案例分析法和实验法相结合的教学方法。
1.讲授法:用于讲解XML的基本概念、语法和解析方法,使学生掌握基础知识。
2.案例分析法:通过分析实际案例,让学生了解XML在实际应用中的重要性,并培养学生解决实际问题的能力。
3.实验法:让学生动手编写XML文档,利用编程语言解析XML文档,并设计学生管理系统,提高学生的实际操作能力。
四、教学资源教学资源包括教材、参考书、多媒体资料和实验设备。
1.教材:选用权威、实用的XML教材,为学生提供系统的学习资料。
2.参考书:推荐学生阅读相关的XML参考书籍,丰富学生的知识体系。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
11.2 学生信息管理模块
此模块主要实现学生信息的增加、删除、修改和查询功能。
11.2.1 XML结构
student.xml文件是学生管理模块所操作的XML文件。其中 <students>节点为XML文件的根节点,根节点下面有四个<student> 子节点。每一个<student>子节点下面又有<name>、<age>、<sex> 、<tel>和<home>这五个子节点。<student>节点除了含有子节点之 外,还有一个studentId的属性,用来唯一标识每一位学生信息,相当 于数据表的主键字段。
11.3.1
XML结构
grade.xml文件是学生成绩管理模块所要操作的XML文件。 其中<grades>节点为XML文件的根节点,根节点下面有6个 <grade>子节点。每一个<grade>子节点下面又有 <subjectName>、<score>、<teacher>以及<examTime>这四 个子节点。<grade>节点除了含有子节点之外,还含有gradeId( 用来唯一标示每一条成绩信息)属性以及studentId(相当于数据 表的外键)属性。
访问学生成绩DAO实现类
上述GradeDAO接口当中只定义了操作grade.xml文件 所需要的增删改查四个抽象接口,除了接口的定义以外,还 需要接口方法的具体实现。
11.3.5
GradeDAOImpl单元测试类
为了对GradeDAOImpl的代码健壮性进行一个测试, 在工程当中新建了一个使用JUnit单元测试框架的 GradeDAOImplTest类。
小结
本章介绍的在线管理系统主要分为两个模块,分别是学 生信息管理模块以及学生成绩管理模块。系统的服务器端由 扩展性良好的JAVA EE架构实现,操作的数据由XML文件来 存放。这两个模块主要对XML文件做了相应节点的增删改查 的操作,这也是绝大多数WEB应用程序最基本的操作,最终 实现了对学生信息进行增删改查以及对学生成绩信息进行增 删改查的功能。
11.2.4
访问学生信息DAO实现类
上述StudentDAO只是定义了操作student.xml文件的 增删改查的四个接口,还需要这四个接口的具体实现才能真 正地对student.xml文件进行具体的操作。
11.2.5
StudentDAOImpl单元测试类
为了保证代码的一个健壮性,在开发过程中一般会对 相关的类进行单元测试,使用的工具就是非常著名的单元测 试框架JUnit。为了对StudentDAOImpl类进行单元测试, 在工程当中新建了一个使用JUnit单元测试框架的 StudentDAOImplTest类。
11.1.2 系统架构
系统采用的是B/S架构,即浏览器和服务器架构。浏览器端提供用 户操作界面,接受用户输入的各种操作信息,向服务器发出各种操作命 令或数据请求,并接受执行操作命令后的返回的数据结果,根据业务逻 辑执行相关的运算,向用户显示相应的信息。服务器端接受浏览器端的 数据或命令请求,并操作XML文件得到相应的数据集,对数据集执行相 应的处理,然后将数据集或处理后的数据集返回给浏览器端。
11.1.1 系统功能简介
本系统主要分为两个模块,学生信息管理模块以及学生成绩 管理模块,分别实现对学生信息的管理功能以及对学生成绩的管 理功能。 学生信息管理模块 1. 添加子模块:实现学生信息的添加功能 2. 删除子模块:实现学生信息的删除功能 3. 修改子模块:实现学生信息的修改功能 4. 查询子模块:实现学生信息的查询功能 学生成绩管理模块 1. 添加子模块:实现学生成绩的添加功能 2. 删除子模块:实现学生成绩的删除功能 3. 修改子模块:实现学生成绩的修改功能 4. 查询子模块:实现学生成绩的查询功能
11.2.2 学生信息模型
MVC模式当中的M指的是模型的意思,在JAVA WEB 开发当中,一般会采用JavaBean的方式来实现MVC模式当 中所指的M。学生模型包含学生ID、学生姓名、学生年龄、 学生性别、学生手机号码以及学生家庭属性。
11.2.3
访问学生信息DAO
服务器端接受浏览器端的数据或命令请求,需要对 student.xml文件进行相应的操作。JAVA EE架构当中,由 于软件扩展性的需求,一般会对数据访问操作封装一层 DAO(Data Access Object)的接口。
第11章 XML在线成绩管理系统
本章将会为大家介绍一个基于XML的在线成绩管理系 统的实例。此实例将会结合JAVA WEB的相关知识,采用 典型的MVC分层软件架构。MVC模式是软件工程中的一种 软件架构模式,把软件系统分为三个基本的部分:模型、视 图和控制器。
11.1 系统功能简介和架构设计
本章介绍的应用属于具备实战意义的整合应用。系统 的服务端由良好的JAVA EE架构实现,由控制器层( Servlet)+视图层(JSP)+数据访问层(DAO)实现了扩 展性比较良好的分层架构。
11.3.2
学生成绩模型
学生成绩模型包含成绩记录ID、学生信息ID、学科名 称、成绩、授课老师以及考试时间属性。其中通过学生信息 ID可以找到关于这个学生的详细信息,此属性相当于数据表 当中的外键字段。
11.3.3
访问学生成绩DAO
GradeDAO封装了对grade.xml文件进行增删改查等业 务逻辑操作所需要的抽象接口。
11.2.6
XML工具类
XmlUtils提供了两个重要的方法,第一个方法就是根 据相应的XML文件的路径来获取此XML文件所对应的 Document对象;第二个方法就是根据相应的Document对 象以及相应的XML文件的路径,对其XML文件进行更新。
11.3 学生成绩管理模块
模块主要实现学生成绩的增加、删除、修改和查询功能。