XML头里standalone的作用

2022-12-12 11:02:33   第一文档网     [ 字体: ] [ 阅读: ] [ 文档下载 ]
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。下载word有问题请添加QQ:admin处理,感谢您的支持与谅解。点击这里给我发消息

#第一文档网# 导语】以下是®第一文档网的小编为您整理的《XML头里standalone的作用》,欢迎阅读!
头里,standalone,作用,XML

Eclipse Warning: No grammar constraints (DTD or XML schema) detected for the document

Use 'yes' if the XML document has an internal DTD. Use 'no' if the XML document is linked to an external DTD, or any external entity references

xml version="1.0" encoding="UTF-8" standalone="no"?> DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd">



standalone用来表示该文件是否呼叫其它外部的文件。若值是 yes 表示没有呼叫外部文件,若值是 no 则表示有呼叫外部文件。默认值是 yes

这里所指的外部文件其实就是查检XML是不是有效的约束文件,或是DTD或是Schema,那这两者又有什么区别呢?

尽管XML1.0提供了一种机制,即文档类型定义(DTD)来规范XML的格式规则。但是它天生存在一些缺点,比如,它采用了非XML的语法规则、不支持更多的数据类型、扩展性差等,为了克服这些缺点,XML Schema 出现了。W3C推荐在XML中使用XML Schema来代替DTD

XML Schema(模式) DTD一样,也用于定义 XML 文档的约束。但它与DTD明显不同的是,XML SchemaXML语法规则,更好地支持数据类型以及命名空间。W3C称:XML Schema is an XML based alternative to DTD。模式在单独的文件中定义,通常扩展名为 .xsd。每个模式定义都有一个根元素 schema,该元素属于名称空间http://www.w3.org/2001/XMLSchemaschema 元素可以包含可选的属性。比如:

elementFormDefault="qualified" attributeFormDefault="unqualified">

这表示模式中使用的元素来自http://www.w3.org/2001/XMLSchema名称空间。

XML 文件使用 schema 名称空间中的 schemaLocation 属性链接到对应的模式。使用schemaLocation 属性必须定 schema 名称空间。所有这些定义都出现在 XML 文档的根元素中。语法如下: schema_namespace_definition schema_location_definition> 下面是一个例子:

xs:schemaLocation="http://www.example.com Books.xsd">

先来看看一个XML文件示例(message.xml,分别用DTDXML Schema 描述这个文件,看看它们之间的区别:

1、使用DTD



(#PCDATA)> (#PCDATA)> (#PCDATA)> ]>



rose

alex

Hi,My Girl!

2、使用XML Schema




message.xml:



xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation="http://www.example.com message.xsd"> Rose

Alex

Hi,My Girl!


message.xsd:



targetNamespace=http://www.example.com

xmlns="http://www.example.com" elementFormDefault="qualified">



Common DOCTYPE Declarations

HTML 5



HTML 4.01 Strict

This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed.



HTML 4.01 Transitional

This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed.


本文来源:https://www.dywdw.cn/098d831e1eb91a37f0115c47.html

相关推荐
推荐阅读