XML规范英文版.docx
《XML规范英文版.docx》由会员分享,可在线阅读,更多相关《XML规范英文版.docx(68页珍藏版)》请在冰豆网上搜索。
![XML规范英文版.docx](https://file1.bdocx.com/fileroot1/2023-2/3/b7ddf358-4644-4642-982a-33b1f5d8da48/b7ddf358-4644-4642-982a-33b1f5d8da481.gif)
XML规范英文版
REC-xml-19980210
ExtensibleMarkupLanguage(XML)1.0
W3CRecommendation10-February-1998
Thisversion:
http:
//www.w3.org/TR/1998/REC-xml-19980210
http:
//www.w3.org/TR/1998/REC-xml-19980210.xml
http:
//www.w3.org/TR/1998/REC-xml-19980210.html
http:
//www.w3.org/TR/1998/REC-xml-19980210.pdf
http:
//www.w3.org/TR/1998/REC-xml-19980210.ps
Latestversion:
http:
//www.w3.org/TR/REC-xml
Previousversion:
http:
//www.w3.org/TR/PR-xml-971208
Editors:
TimBray(TextualityandNetscape)
JeanPaoli(Microsoft)
C.M.Sperberg-McQueen(UniversityofIllinoisatChicago)
Abstract
TheExtensibleMarkupLanguage(XML)isasubsetofSGMLthatiscompletelydescribedinthisdocument.ItsgoalistoenablegenericSGMLtobeserved,received,andprocessedontheWebinthewaythatisnowpossiblewithHTML.XMLhasbeendesignedforeaseofimplementationandforinteroperabilitywithbothSGMLandHTML.
Statusofthisdocument
ThisdocumenthasbeenreviewedbyW3CMembersandotherinterestedpartiesandhasbeenendorsedbytheDirectorasaW3CRecommendation.Itisastabledocumentandmaybeusedasreferencematerialorcitedasanormativereferencefromanotherdocument.W3C'sroleinmakingtheRecommendationistodrawattentiontothespecificationandtopromoteitswidespreaddeployment.ThisenhancesthefunctionalityandinteroperabilityoftheWeb.
Thisdocumentspecifiesasyntaxcreatedbysubsettinganexisting,widelyusedinternationaltextprocessingstandard(StandardGeneralizedMarkupLanguage,ISO8879:
1986(E)asamendedandcorrected)foruseontheWorldWideWeb.ItisaproductoftheW3CXMLActivity,detailsofwhichcanbefoundathttp:
//www.w3.org/XML.AlistofcurrentW3CRecommendationsandothertechnicaldocumentscanbefoundathttp:
//www.w3.org/TR.
ThisspecificationusesthetermURI,whichisdefinedby[Berners-Leeetal.],aworkinprogressexpectedtoupdate[IETFRFC1738]and[IETFRFC1808].
Thelistofknownerrorsinthisspecificationisavailableathttp:
//www.w3.org/XML/xml-19980210-errata.
Pleasereporterrorsinthisdocumenttoxml-editor@w3.org.
ExtensibleMarkupLanguage(XML)1.0
TableofContents
1.Introduction
1.1OriginandGoals
1.2Terminology
2.Documents
2.1Well-FormedXMLDocuments
2.2Characters
2.3CommonSyntacticConstructs
2.4CharacterDataandMarkup
2.5Comments
2.6ProcessingInstructions
2.7CDATASections
2.8PrologandDocumentTypeDeclaration
2.9StandaloneDocumentDeclaration
2.10WhiteSpaceHandling
2.11End-of-LineHandling
2.12LanguageIdentification
3.LogicalStructures
3.1Start-Tags,End-Tags,andEmpty-ElementTags
3.2ElementTypeDeclarations
3.2.1ElementContent
3.2.2MixedContent
3.3Attribute-ListDeclarations
3.3.1AttributeTypes
3.3.2AttributeDefaults
3.3.3Attribute-ValueNormalization
3.4ConditionalSections
4.PhysicalStructures
4.1CharacterandEntityReferences
4.2EntityDeclarations
4.2.1InternalEntities
4.2.2ExternalEntities
4.3ParsedEntities
4.3.1TheTextDeclaration
4.3.2Well-FormedParsedEntities
4.3.3CharacterEncodinginEntities
4.4XMLProcessorTreatmentofEntitiesandReferences
4.4.1NotRecognized
4.4.2Included
4.4.3IncludedIfValidating
4.4.4Forbidden
4.4.5IncludedinLiteral
4.4.6Notify
4.4.7Bypassed
4.4.8IncludedasPE
4.5ConstructionofInternalEntityReplacementText
4.6PredefinedEntities
4.7NotationDeclarations
4.8DocumentEntity
5.Conformance
5.1ValidatingandNon-ValidatingProcessors
5.2UsingXMLProcessors
6.Notation
Appendices
A.References
A.1NormativeReferences
A.2OtherReferences
B.CharacterClasses
C.XMLandSGML(Non-Normative)
D.ExpansionofEntityandCharacterReferences(Non-Normative)
E.DeterministicContentModels(Non-Normative)
F.AutodetectionofCharacterEncodings(Non-Normative)
G.W3CXMLWorkingGroup(Non-Normative)
1.Introduction
ExtensibleMarkupLanguage,abbreviatedXML,describesaclassofdataobjectscalledXMLdocumentsandpartiallydescribesthebehaviorofcomputerprogramswhichprocessthem.XMLisanapplicationprofileorrestrictedformofSGML,theStandardGeneralizedMarkupLanguage[ISO8879].Byconstruction,XMLdocumentsareconformingSGMLdocuments.
XMLdocumentsaremadeupofstorageunitscalledentities,whichcontaineitherparsedorunparseddata.Parseddataismadeupofcharacters,someofwhichformcharacterdata,andsomeofwhichformmarkup.Markupencodesadescriptionofthedocument'sstoragelayoutandlogicalstructure.XMLprovidesamechanismtoimposeconstraintsonthestoragelayoutandlogicalstructure.
AsoftwaremodulecalledanXMLprocessorisusedtoreadXMLdocumentsandprovideaccesstotheircontentandstructure.ItisassumedthatanXMLprocessorisdoingitsworkonbehalfofanothermodule,calledtheapplication.ThisspecificationdescribestherequiredbehaviorofanXMLprocessorintermsofhowitmustreadXMLdataandtheinformationitmustprovidetotheapplication.
1.1OriginandGoals
XMLwasdevelopedbyanXMLWorkingGroup(originallyknownastheSGMLEditorialReviewBoard)formedundertheauspicesoftheWorldWideWebConsortium(W3C)in1996.ItwaschairedbyJonBosakofSunMicrosystemswiththeactiveparticipationofanXMLSpecialInterestGroup(previouslyknownastheSGMLWorkingGroup)alsoorganizedbytheW3C.ThemembershipoftheXMLWorkingGroupisgiveninanappendix.DanConnollyservedastheWG'scontactwiththeW3C.
ThedesigngoalsforXMLare:
1.XMLshallbestraightforwardlyusableovertheInternet.
2.XMLshallsupportawidevarietyofapplications.
3.XMLshallbecompatiblewithSGML.
4.ItshallbeeasytowriteprogramswhichprocessXMLdocuments.
5.ThenumberofoptionalfeaturesinXMListobekepttotheabsoluteminimum,ideallyzero.
6.XMLdocumentsshouldbehuman-legibleandreasonablyclear.
7.TheXMLdesignshouldbepreparedquickly.
8.ThedesignofXMLshallbeformalandconcise.
9.XMLdocumentsshallbeeasytocreate.
10.TersenessinXMLmarkupisofminimalimportance.
Thisspecification,togetherwithassociatedstandards(UnicodeandISO/IEC10646forcharacters,InternetRFC1766forlanguageidentificationtags,ISO639forlanguagenamecodes,andISO3166forcountrynamecodes),providesalltheinformationnecessarytounderstandXMLVersion1.0andconstructcomputerprogramstoprocessit.
ThisversionoftheXMLspecificationmaybedistributedfreely,aslongasalltextandlegalnoticesremainintact.
1.2Terminology
TheterminologyusedtodescribeXMLdocumentsisdefinedinthebodyofthisspecification.ThetermsdefinedinthefollowinglistareusedinbuildingthosedefinitionsandindescribingtheactionsofanXMLprocessor:
may
ConformingdocumentsandXMLprocessorsarepermittedtobutneednotbehaveasdescribed.
must
ConformingdocumentsandXMLprocessorsarerequiredtobehaveasdescribed;otherwisetheyareinerror.
error
Aviolationoftherulesofthisspecification;resultsareundefined.Conformingsoftwaremaydetectandreportanerrorandmayrecoverfromit.
fatalerror
AnerrorwhichaconformingXMLprocessormustdetectandreporttotheapplication.Afterencounteringafatalerror,theprocessormaycontinueprocessingthedatatosearchforfurthererrorsandmayreportsucherrorstotheapplication.Inordertosupportcorrectionoferrors,theprocessormaymakeunprocesseddatafromthedocument(withintermingledcharacterdataandmarkup)availabletotheapplication.Onceafatalerrorisdetected,however,theprocessormustnotcontinuenormalprocessing(i.e.,itmustnotcontinuetopasscharacterdataandinformationaboutthedocument'slogicalstructuretotheapplicationinthenormalway).
atuseroption
Conformingsoftwaremayormust(dependingonthemodalverbinthesentence)behaveasdescribed;ifitdoes,itmustprovideusersameanstoenableordisablethebehaviordescribed.
validityconstraint
ArulewhichappliestoallvalidXMLdocuments.Violationsofvalidityconstraintsareerrors;theymust,atuseroption,bereportedbyvalidatingXMLprocessors.
well-formednessconstraint
Arulewhichappliestoallwell-formedXMLdocuments.Violationsofwell-formednessconstraintsarefatalerrors.
match
(Ofstringsornames:
)Twostringsornamesbeingcomparedmustbeidentical.CharacterswithmultiplepossiblerepresentationsinISO/IEC10646(e.g.characterswithbothprecomposedandbase+diacriticforms)matchonlyiftheyhavethesamerepresentationinbothstrings.Atuseroption,processorsmaynormalizesuchcharacterstosomecanonicalform.Nocasefoldingisperformed.(Ofstringsandrulesinthegrammar:
)Astringmatchesagrammaticalproductionifitbelongstothelanguagegeneratedbythatproduction.(Ofcontentandcontentmodels:
)Anelementmatchesitsdeclarationwhenitconformsinthefashiondescribedintheconstraint"ElementValid".
forcompatibility
AfeatureofXMLincludedsolelytoensurethatXMLremainscompatiblewithSGML.
forinteroperability
Anon-bindingrecommendationincludedtoincreasethechancesthatXMLdocumentscanbeprocessedbytheexistinginstalledbaseofSGMLprocessorswhichpredatetheWebSGMLAdaptationsAnnextoISO8879.
2.Documents
AdataobjectisanXMLdocumentifitiswell-formed,asdefinedinthisspecification.Awell-formedXMLdoc