„Dokumentumtípus-definíció” változatai közötti eltérés

[nem ellenőrzött változat][nem ellenőrzött változat]
Tartalom törölve Tartalom hozzáadva
Tiplity (vitalap | szerkesztései)
Tiplity (vitalap | szerkesztései)
190. sor:
However, the references to predefined numeric character entities are substituted wherever they occur, without needing a validating parser (they are only introduced by the "&" character).
 
=== NotationA declarationsNOTATION deklaráció ===
 
SGML vagy XML dokumentumokban szerepelhet. Amikor egy entitás nem feldolgozott adatot tartalmaz, akkor a feldolgozóprogramnak fel kell ismernie, hogy miként ágyazza azt be a dokumentumokba.A <tt>NOTATION</tt> deklaráció rendszerint az adatokat feldolgozó alkalmazást adja meg.
Notations are used in SGML or XML. They provide a complete reference to unparsed external entities whose interpretation is left to the application (which will interpret them directly or will retrieve the external entity themselves), by assigning them a simple name which is usable in the body of the document. For example, notations may be used to reference non-XML data in an XML 1.1 document. For example, to annotate SVG images, in order to associate them with a specific renderer:
 
Így lehet annotálni az SVG file-okat annak érdekében, hogy a megfelelő megjelenítővel társítsuk őket:
 
<source lang="xml">
<!NOTATION type-image-svg SYSTEM "image/svg">
</source>
 
This declares the [[MIME type]] of external images with this type, and associates it with a notation name "type-image-svg". However, notation names usually follow a naming convention that is specific to the application generating or using the notation: notations are interpreted as additional meta-data whose effective content is an external entity and either a PUBLIC FPI, registered in the catalogs used by XML or SGML parsers, or a SYSTEM URI, whose interpretation is application dependent (here a MIME type, interpreted as a relative URI, but it could be an absolute URI to a specific renderer, or a URN indicating a OS-specific object identifier such as a UUID).
 
The declared notation name must be unique within all the document type declaration, i.e. in the external subset as well as the internal subset, at least for conformance with XML.<ref>[http://www.w3.org/TR/REC-xml/#Notations ''Notation Declarations''], Specifications of ''Extensible Markup Language'' (XML) 1.0, W3C.</ref><ref>[http://www.w3.org/TR/xml11/#NT-PublicID ''Notation Declarations''], Specifications of ''Extensible Markup Language'' (XML) 1.1, W3C.</ref>
 
Notations can be associated to unparsed external entities included in the body of the SGML or XML document. The <tt>PUBLIC</tt> or <tt>SYSTEM</tt> parameter of these external entities specifies the FPI and/or the URI where the unparsed data of the external entity is located, and the additional <tt>NDATA</tt> parameter of these defined entities specifies the additional notation (i.e., effectively the MIME type here). For example:
 
<source lang="xml">
<!DOCTYPE sgml [
<!ELEMENT sgml (img)*>
 
<!ELEMENT img EMPTY>
<!ATTLIST img
data ENTITY #IMPLIED>
 
<!ENTITY example1SVG SYSTEM "example1.svg" NDATA example1SVG-rdf>
<!NOTATION example1SVG-rdf SYSTEM "example1.svg.rdf">
]>
<sgml>
<img data="example1SVG" />
</sgml>
</source>
 
Within the body of the SGML document, these referenced external entities (whose name is specified between "&" and ";") are ''not'' replaced like usual named entities (defined with a CDATA value), but are left as distinct unparsed tokens that may be used either as the value of an element attribute (like above) or within the element contents, provided that either the DTD allows such external entities in the declared content type of elements or in the declared type of attributes (here the <tt>ENTITY</tt> type for the <tt>data</tt> attribute), or the SGML parser is not validating the content.
 
Notations may also be associated directly to elements as additional meta-data, without associating them to another external entity, by giving their names as possible values of some additional attributes (also declared in the DTD within the <tt><!ATTLIST ...></tt> declaration of the element). For example:
 
<source lang="xml">
<!DOCTYPE sgml [
<!ELEMENT sgml (img)*>
<!--
the optional "type" attribute value can only be set to this notation.
-->
<!ATTLIST sgml
type NOTATION (
type-vendor-specific ) #IMPLIED>
 
<!ELEMENT img ANY> <!-- optional content can be only parsable SGML or XML data -->
<!--
the optional "title" attribute value must be parsable as text.
the optional "data" attribute value will be set to an unparsed external entity.
the optional "type" attribute value can only be one of the two notations.
-->
<!ATTLIST img
title CDATA #IMPLIED
data ENTITY #IMPLIED
type NOTATION (
type-image-svg |
type-image-gif ) #IMPLIED>
 
<!--
Notations are referencing external entities and may be set in the "type" attributes above,
or must be referenced by any defined external entities that cannot be parsed.
-->
<!NOTATION type-image-svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!NOTATION type-image-gif PUBLIC "image/gif">
<!NOTATION type-vendor-specific PUBLIC "application/VND.specific+sgml">
 
<!ENTITY example1SVGTitle "Title of example1.svg"> <!-- parsed internal entity -->
<!ENTITY example1SVG SYSTEM "example1.svg"> <!-- parsed external entity -->
<!ENTITY example1GIFTitle "Title of example1.gif"> <!-- parsed internal entity -->
<!ENTITY example1GIF SYSTEM "example1.gif" NDATA type-image-gif> <!-- unparsed external entity -->
]>
<sgml type="type-vendor-specific">
<!-- an SVG image is parsable as valid SGML or XML text -->
<img title="&example1SVGTitle;" type="type-image-svg">&example1SVG;</img>
 
<!-- it can also be referenced as an unparsed external entity -->
<img title="&example1SVGTitle;" data="example1SVG" />
 
<!-- a GIF image is not parsable and can only be referenced as an external entity -->
<img title="&example1GIFTitle;" data="example1GIF" />
</sgml>
</source>
 
The example above shows a notation named "type-image-svg" that references the standard public FPI and the system identifier (the standard URI) of an SVG 1.1 document, instead of specifying just a system identifier as in the first example (which was a relative URI interpreted locally as a MIME type). This annotation is referenced directly within the unparsed "type" attribute of the "img" element, but its content is not retrieved. It also declares another notation for a vendor-specific application, to annotate the "sgml" root element in the document. In both cases, the declared notation named is used directly in a declared "type" attribute, whose content is specified in the DTD with the "NOTATION" attribute type (this "type" attribute is declared for the "sgml" element, as well as for the "img" element).
 
However, the "title" attribute of the "img" element specifies the internal entity "example1SVGTitle" whose declaration that does not define an annotation, so it will be parsed by validating parsers and the entity replacement text will be "Title of example1.svg".
 
And the content of the "img" element is referencing another external entity "example1SVG" whose declaration also does not define an notation, so it will also be parsed by validating parsers and the entity replacement text will be located by its defined SYSTEM identifier "example1.svg" (also interpreted as a relative URI). The effective content for the "img" element be the content of this second external resource. The difference with the GIF image, is that the SVG image will be parsed within the SGML document, according to the declarations in the DTD, where the GIF image is just referenced as an opaque external object (which is not parsable with SGML) via its "data" attribute (whose value type is an opaque ENTITY).
 
Only one notation name may be specified in the value of ENTITY attributes (there's no support in SGML, XML 1.0 or XML 1.1 for multiple notation names in the same declared external ENTITY, so separate attributes will be needed). However multiple external entities may be referenced (in a space-separated list of names) in attributes declared with type ENTITIES, and where each named external entity is also declared with its own notation).
 
Notations are also completely opaque for XML and SGML parsers, so they are not differentiated by the type of the external entity that they may reference (for these parsers they just have a unique name associated to a public identifier (an FPI) and/or a system identifier (a URI)).
 
Some applications (but not XML or SGML parsers themselves) also allow referencing notations indirectly by naming them in the <tt>"URN:''name''"</tt> value of a standard CDATA attribute, everywhere a URI can be specified. However this behaviour is application-specific, and requires that the application maintains a catalog of known URNs to resolve them into the notations that have been parsed in a standard SGML or XML parser. This use allows notations to be defined only in a DTD stored as an external entity and referenced only as the external subset of documents, and allows these documents to remain compatible with validating XML or SGML parsers that have no direct support for notations.
 
Notations are not used in HTML, or in basic profiles for XHTML and SVG, because:
* all the external entities used by these standard document types are referenced by simple attributes, declared with the CDATA type in their standard DTD (such as the "href" attribute of an anchor "a" element, or the "src" attribute of an image "img" element, whose values are interpreted as a URI, without needing any catalog of public identifiers, i.e., known FPI);
* all the external entities for additional meta-data are referenced:
** either by additional attributes (such as the "type" attribute which indicates the MIME type of the external entity, or the "charset" attribute which indicates its encoding),
** or by additional elements (such as "link" or "meta" in HTML and XHTML) within their own attributes,
** or by standard pseudo-attributes in XML and XHTML (such as "xml:lang", or "xmlns" and "xmlns:*" for namespace declarations).
 
Note also that even in validating SGML or XML 1.0 or XML 1.1 parsers, the external entities referenced by an FPI and/or URI in declared notations are not retrieved automatically by the parsers themselves. Instead, these parsers just provide to the application the parsed FPI and/or URI associated to the notations found in the parsed SGML or XML document, and with a facility for a dictionary containing all notation names declared in the DTD; these validating parsers will also check the uniqueness of notation name declarations, and will report a validation error if some notation names are used anywhere in the DTD or in the document body but not declared:
* if the application can't use any notation (or if their FPI and/or URI are unknown or not supported in their local catalog), these notations may be either ignored silently by the application or the application could signal an error;
* otherwise the applications will decide themselves how to interpret them, then if the external entities must be retrieved and then parsed separately;
* applications may then signal an error if such interpretation, retrieval or separate parsing ever fails.
* Unrecognized notations that may cause an application to signal an error should not be blocking the interpretation of the validated document using them.
 
== Lásd még ==