Tecnologías XML / XML / XML in a Nutshell / XML en la Web / Documentos compuestos con XHTML modular
(Extracto de «XML in a Nutshell» de Elliotte Rusty Harold & W. Scott Means)
XHTML 1.1 divide las tres DTD XHTML en módulos. Las entidades parámetro los combinan incluyendo u omitiendo determinados módulos. Por ejemplo:
Módulo de estructura,
%xhtml-struct.module;Los elementos mínimos de un documento HTML:
html,head,titleybody.Módulo de texto,
%xhtml-text.module;Elementos básicos con texto y otros elementos en línea:
abbr,acronym,address,blockquote,br,cite,code,dfn,div,em,h1,h2,h3,h4,h5,h6,kbd,p,pre,q,samp,span,strongyvar.Módulo de hipertexto,
%xhtml-hypertext.module;Elementos de enlace, concretamente
a.Módulo de listas,
%xhtml-list.module;Elementos de los tres tipos de listas:
dl,dt,dd,ul,olyli.Módulo de applets,
%xhtml-applet.module;Elementos necesarios para applets Java:
appletyparam.Módulo de presentación,
%xhtml-pres.module;Marcado de presentación, concretamente los elementos
b,big,hr,i,small,sub,supytt.Módulo de edición,
%xhtml-edit.module;Elementos para seguir revisiones:
delyins.Módulo de texto bidireccional,
%xhtml-bdo.module;Información de dirección al mezclar texto de izquierda a derecha, como inglés, alemán o francés, con texto de derecha a izquierda, como árabe o hebreo.
Módulo de formularios básicos,
%xhtml-basic-form.module;Formularios HTML 3.2, con los elementos
form,input,select,optionytextarea.Módulo de formularios,
%xhtml-form.module;Formularios HTML 4.0, con los elementos
form,input,select,option,textarea,button,fieldset,label,legendyoptgroup.Módulo de tablas básicas,
%xhtml-basic-table.module;Compatibilidad mínima con tablas, con solo los elementos
table,caption,th,trytd.Módulo de tablas,
%xhtml-table.module;Compatibilidad más completa, con no solo los elementos
table,caption,th,trytdsino tambiéncol,colgroup,tbody,theadytfoot.Módulo de imágenes,
%xhtml-image.module;El elemento
img.Módulo de mapas de imagen del cliente,
%xhtml-csismap.module;Los elementos
mapyareay atributos de otros elementos para mapas de imagen del cliente.Módulo de mapas de imagen del servidor,
%xhtml-ssismap.module;Ningún elemento nuevo, pero añade al elemento
imgel atributoismap.Módulo de objetos,
%xhtml-object.module;El elemento
object, que integra contenido ejecutable, applets Java o controles ActiveX, en páginas web.Módulo de parámetros,
%xhtml-param.module;El elemento
param, que pasa parámetros a contenido ejecutable integrado, applets Java o controles ActiveX.Módulo de marcos,
%xhtml-frames.module;Elementos para marcos, incluidos
frame,framesetynoframes.Módulo Iframe
%xhtml-iframe.mod;El elemento
iframe, para marcos en línea.Eventos principales,
%xhtml-events.module;Atributos de scripts como
onsubmityonfocus, asociados a elementos de otros módulos.Módulo de metadatos,
%xhtml-meta.module;El elemento
meta, utilizado en cabeceras.Módulo de scripts,
%xhtml-script.module;Elementos compatibles con JavaScript y VBScript:
scriptynoscript.Módulo de hojas de estilo,
%xhtml-style.module;El elemento
style, que define hojas de estilo en cascada.Módulo de enlaces,
%xhtml-link.module;El elemento
link, que describe relaciones con documentos externos: traducciones, glosarios, páginas anteriores o siguientes.Módulo de base,
%xhtml-base.module;El elemento
base, que define la URL para resolver URL relativas.Módulo de destino,
%xhtml-target.module;El atributo
target, que especifica el marco o ventana de destino de un enlace.Módulo del atributo style,
%xhtml-inlstyle.module;El atributo
style, que asigna a elementos estilos CSS.Módulo de identificación por nombre,
%xhtml-nameident.module;El atributo
namees una versión antigua obsoleta del atributoid.Módulo de elementos y atributos obsoletos,
%xhtml-legacy.module;Elementos y atributos obsoletos, incluidos
basefont,center,font,s,strikeyu.Módulo Ruby,
%xhtml11-ruby.module;Los elementos
ruby,rbc,rtc,rb,rtyrp, que colocan pequeñas anotaciones junto a textos de Asia oriental, normalmente para indicar pronunciación.
Integrar XHTML en sus aplicaciones
La modularización permite elegir lo necesario. Incluya tablas si el documento las utiliza; omítalas si no. Solo obtiene las funciones necesarias.
Suponga que diseña una DTD para un catálogo. Cada entrada es un elemento katalog_eintrag. Cada katalog_eintrag contiene los elementos name, preis, produkt_nummer, farbe, größe y otros campos habituales. Cada katalog_eintrag también contiene una beschreibung del artículo. La beschreibung contiene texto narrativo con formato, por ejemplo:
<katalog_eintrag>
<name>Aluminium-Stopfen</name>
<preis>34,99</preis>
<produkt_nummer>54X8</produkt_nummer>
<farbe>silber</farbe>
<größe>XL</größe>
<beschreibung>
<p>Dieser starke <strong>silber</strong>farbene Stöpsel verschönert die <em>besten Küchen</em>. Er ist ein wunderbares Geschenk für</p>
<ul>
<li>Weihnachten</li>
<li>Geburtstage</li>
<li>Muttertag</li>
</ul>
<p>und alle anderen Gelegenheiten!</p>
</beschreibung>
</katalog_eintrag>Escribir este marcado es sencillo; validarlo lo es menos. En vez de reinventar una DTD para texto narrativo, reutilice XHTML. La DTD XHTML 1.1 utiliza referencias a entidades parámetro para modelos de contenido y listas de atributos. Tres merecen especial atención:
%Inline.mix;Una selección de elementos sin salto de línea, como
em,ayq. Se expande a:br | span | em | strong | dfn | code | samp | kbd | var | cite | abbr | acronym | q | tt | i | b | big | small | sub | sup | bdo | a | img | map | applet | ruby | input | select | textarea | label | button | ins | del | script | noscript%Block.mix;Una selección de elementos que requieren saltos de línea, como
b,blockquoteyul. Se expande a:h1 | h2 | h3| h4 |h5 | h6| ul| ol| dl| p | div | pre| blockquote | address | hr |table | form | fieldset | ins | del | script | noscript%Flow.mix;Una selección que reúne las dos referencias anteriores; se expande a:
h1 | h2 | h3 | h4 | h5 | h6 | ul | ol | dl | p | div | pre | blockquote | address | hr | table | form | fieldset | br | span | em | strong | dfn | code | samp | kbd | var | cite | abbr | acronym | q | tt | i | b | big | small | sub | sup | bdo | a | img | map | applet | ruby | input | select | textarea | label | button | ins | del | script | noscript
Declare así que el elemento beschreibung puede contener cualquier fragmento XHTML válido:
<!ENTITY % xhtml PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11.dtd">
%xhtml;
<!ELEMENT beschreibung (#PCDATA | %Flow.mix;)*>Para restringir beschreibung en el primer nivel a elementos de bloque, declare en su lugar:
<!ENTITY % xhtml PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11.dtd">
%xhtml;
<!ELEMENT beschreibung ((%Block.mix;)*)>Las dos primeras líneas importan la DTD principal desde una URL relativa. La encontrará con sus dependencias en el archivo ZIP del W3C. La segunda línea utiliza una referencia definida en esa DTD para el modelo de contenido del elemento beschreibung.
Nota: La DTD principal XHTML 1.1 importa módulos de «Modularization of XHTML» y «Ruby Annotation» mediante URL absolutas del W3C. Sin acceso rápido y fiable, considere la DTD unificada: xhtml11-flat.dtd. Reúne los módulos en un archivo.
Esta DTD incluye demasiado: además del HTML deseado como p, em y ul, incluye elementos inadecuados para catálogos impresos como a, applet, map y otros. Puede omitirlos: la DTD principal importa cada módulo en un bloque INCLUDE/IGNORE, ilustrado aquí con hipertexto:
<!-- Hypertext Module (required) ................................. -->
<!ENTITY % xhtml-hypertext.module "INCLUDE" >
<![%xhtml-hypertext.module;[<!ENTITY % xhtml-hypertext.mod PUBLIC "-//W3C//ELEMENTS XHTML Hypertext 1.0//EN "http://www.w3c.org/TR/xhtml-moularization/DTD/xhtml-hypertext-1.mod" >%xhtml-hypertext.mod;]]>Si la referencia a entidad parámetro %xhtml-hypertext.module; se definió previamente como IGNORE en vez de INCLUDE, esa declaración prevalece: los elementos y atributos del módulo, especialmente el elemento a, desaparecen de la DTD resultante.
Para usar solo estructura, texto y listas, defina las referencias de los demás módulos como IGNORE, como en el siguiente ejemplo.
<!ELEMENT katalog (katalog_eintrag*)>
<!ELEMENT katalog_eintrag (name, preis, produkt_nummer, farbe, größe, beschreibung)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT größe (#PCDATA)>
<!ELEMENT preis (#PCDATA)>
<!ELEMENT produkt_nummer (#PCDATA)>
<!ELEMENT farbe (#PCDATA)>
<!-- entfernt alle Module, die wir nicht benötigen -->
<!ENTITY % xhtml-hypertext.module "IGNORE" >
<!ENTITY % xhtml-ruby.module "IGNORE" >
<!ENTITY % xhtml-edit.module "IGNORE" >
<!ENTITY % xhtml-pres.module "IGNORE" >
<!ENTITY % xhtml-applet.module "IGNORE" >
<!ENTITY % xhtml-param.module "IGNORE" >
<!ENTITY % xhtml-bidi.module "IGNORE" >
<!ENTITY % xhtml-form.module "IGNORE" >
<!ENTITY % xhtml-table.module "IGNORE" >
<!ENTITY % xhtml-image.module "IGNORE" >
<!ENTITY % xhtml-csismap.module "IGNORE" >
<!ENTITY % xhtml-ssismap.module "IGNORE" >
<!ENTITY % xhtml-meta.module "IGNORE" >
<!ENTITY % xhtml-script.module "IGNORE" >
<!ENTITY % xhtml-style.module "IGNORE" >
<!ENTITY % xhtml-link.module "IGNORE" >
<!ENTITY % xhtml-base.module "IGNORE" >
<!-- importiert die XHTML-DTD, zumindest die Teile, die wir nicht ignorieren. Sie müssen wahrscheinlich den SYSTEM-Identifier ändern, um auf das Verzeichnis zu verweisen, in dem bei Ihnen die DTD gespeichert ist. -->
<!ENTITY % xhtml11.mod PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11/DTD/xhtml11.dtd"> %xhtml11.mod;
<!ELEMENT beschreibung ( %Block.mix; )+>Ejemplo de código: Una DTD de catálogo con XHTML sencillo que omite ciertos elementos
Integrar sus aplicaciones en XHTML
XHTML modular permite sobre todo añadir elementos ausentes en HTML. Para integrar imágenes SVG, importe la DTD SVG y defina la entidad parámetro Misc.extra para permitir la raíz SVG svg. Esto solo valida XHTML con SVG, sin enseñar mágicamente al navegador a mostrarlo. Redefina una de estas tres referencias a entidades parámetro:
%Inline.extra;Ponga aquí sus raíces para añadirlas a modelos de contenido de elementos en línea como
span,em,codeytextarea.%Block.extra;Ponga aquí sus raíces para añadirlas a modelos de elementos de bloque como
div,h1,pypre.%Misc.extra;Ponga aquí sus raíces para añadirlas a modelos de contenido tanto en línea como de bloque.
Defina cada entidad como una lista de elementos separados por barras verticales y empezando por una barra. Para añadir ecuaciones MathML en línea y en bloque, importe la DTD MathML y defina la entidad parámetro Misc.extra para incluir la raíz MathML math:
<!ENTITY % Misc.extra "| math"> Para permitir ecuaciones MathML e imágenes SVG como bloques, importe ambas DTD y defina la entidad parámetro Block.extra así:
<!ENTITY % Block.extra "| math | svg"> El orden importa. La DTD MathML y la declaración Block.extra deben analizarse antes de la DTD XHTML. El siguiente ejemplo combina MathML 1.0 y XHTML y añade por precaución una declaración de espacio de nombres.
<!ENTITY % mathml SYSTEM "mathml/mathml.dtd">
%mathml;
<!ATTLIST math xmlns CDATA #FIXED "http://www.w3.org/1998/Math/MathML/">
<!ENTITY % Misc.extra "| math">
<!ENTITY % xhtml PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11/DTD/xhtml11.dtd">
%xhtml;Ejemplo de código: Una DTD que integra MathML en XHTML
Elementos nuevos como math también pueden mezclarse con elementos concretos como p sin cambiar todos los bloques. El modelo de un elemento XHTML lo define una entidad parámetro llamada Element.content, por ejemplo %p.content;, %em.content; o %td.content;. La definición predeterminada de p.content es:
<!ENTITY % p.content "( #PCDATA | %Inline.mix; )*" > Para permitir math como hijo de elementos p, pero no de todos los bloques, redefina p.content así:
<!ENTITY % p.content "( #PCDATA | %Inline.mix; | math )*" > La DTD XHTML 1.1 está madura. Definir y redefinir sus entidades parámetro permite muchas más combinaciones. Lea las propias DTD: sus comentarios suelen ser más claros y precisos que la especificación.
Construir su propio XHTML
XHTML 1.1 omite algunos módulos, deliberadamente marcos y elementos antiguos de presentación, que no pueden simplemente activarse. Así el W3C sugiere que no se utilicen. Para incluirlos, cree una DTD completa con los módulos necesarios.
Defina primero el URI del espacio de nombres y el prefijo de sus elementos y atributos. El W3C ofrece una plantilla que puede adaptar. El siguiente fragmento define nombres para los elementos today y quoteoftheday utilizados en los sitios del autor Harold. El módulo se basa en la plantilla del W3C.
<!-- ................................................................. -->
<!-- CafeML Qualified Names Module ................................... -->
<!-- file: cafe-qname-1.mod
Dies ist eine Erweiterung von XHTML, einer neuen Variante von HTML als
eine modulare XML-Anwendung.
Dieses DTD-Modul wird durch PUBLIC- und SYSTEM-Identifier identifiziert:
PUBLIC "-//Elliotte Rusty Harold//ELEMENTS CafeML Qualified Names 1.0//EN"
"cafe-qname-1.mod"
................................................................. -->
<!-- NOTES: Die CafeML Qualified Names Extension benutzen
Dies ist ein Modul für die Markup-Sprache 'CafeML',
die momentan zwei Erweiterungselemente deklariert, <quoteoftheday> und <today>.
Entsprechend der Namenskonvention für Parameter-Entities werden Großbuchstaben für
den Namen des Entity und Kleinbuchstaben für das Namensraumpräfix verwendet,
das heißt, dieses Beispiel benutzt 'CAFEML' bzw. 'cafeml'.
Beachten Sie bitte diese drei Schreibweisen:
'CafeML' der Name der Markup-Sprache
'CAFEML' wird als Präfix des Namens eines Parameter-Entity verwendet
'cafeml' wird als Default-Namensraum-Präfix benutzt
Das Schlüsselwort %NS.prefixed; für den bedingten Abschnitt muss als
"INCLUDE" deklariert werden, damit Präfixe benutzt werden können.
-->
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<!-- CafeML Qualified Names
Dieses Modul ist in zwei Teilen enthalten, die mit Section 'A' und 'B'
bezeichnet werden:
Section A deklariert Parameter-Entities, um namensraumqualifizierte
Namen, Namensraum-Deklarationen und Namens-Präfixe für CafeML
zu unterstützen.
Section B deklariert Parameter-Entities, die benutzt werden, um
namensraumqualifizierte Namen für alle CafeML-Elementtypen zu ermöglichen.
Die empfohlene Vorgehensweise zum Erzeugen konformer
Module ist unten angegeben und umfasst die Module CafeML Qualified
Names Template und CafeML Extension Template.
-->
<!-- Section A: XHTML XML Namespace Framework :::::::::::::::::::: -->
<!-- 1. Deklariert ein Schlüsselwort %CAFEML.prefixed; für bedingte Abschnitte,
das verwendet wird, um den Einsatz von Namensraum-Präfixen zu
aktivieren. Der Standardwert sollte vom DTD-Treiber '%NS.prefixed;'
erben, so dass das Standardverhalten dem allgemeinen DTD-Präfix-Schema
entspricht, solange der Wert nicht überschrieben wird.
-->
<!ENTITY % NS.prefixed "IGNORE" >
<!ENTITY % CAFEML.prefixed "%NS.prefixed;" >
<!-- 2. Deklariere ein Parameter-Entity (z.B. %CAFEML.xmlns;), das den
URI enthält, mit dem der Modul-Namensraum identifiziert wird:
-->
<!ENTITY % CAFEML.xmlns "http://www.cafeconleche.org/xmlns/cafeml/" >
<!-- 3. Deklariere Parameter-Entities (z.B. %CAFEML.prefix;), die den oder die
vorgegebenen Namensraum-Präfix-Strings enthalten, die beim Einsatz von Präfixen
verwendet werden. Diese können im DTD-Treiber oder der internen Teilmenge
einer Dokumentinstanz überschrieben werden. Wenn kein Default-Präfix erwünscht
ist, kann das Entity als leerer String deklariert werden.
HINWEIS: Wie in [XMLNAMES] angegeben, dient das Namensraum-Präfix
als Proxy für die URI-Referenz und ist selbst nicht entscheidend.
-->
<!ENTITY % CAFEML.prefix "cafeml" >
<!-- 4. Deklariere Parameter-Entities (z.B. %CAFEML.pfx;), die das oder die Präfixe
mit Doppelpunkt (z.B. '%CAFEML.prefix;:') enthalten, die verwendet werden, wenn
der Einsatz von Präfixen aktiviert ist; sonst einen leeren String.
-->
<![%CAFEML.prefixed;[<!ENTITY % CAFEML.pfx "%CAFEML.prefix;:" >]]>
<!ENTITY % CAFEML.pfx "" >
<!-- 5. Das Parameter-Entity %CAFEML.xmlns.extra.attrib; kann neu deklariert werden, um
alle Nicht-CafeML-Namensraum-Attribute für Namensräume aufzunehmen, die in CafeML
eingebettet werden. Es enthält das xmlns-Attribut und alle Namensraum-
Deklarationen, die in CafeML eingebettet werden, wenn der Einsatz von Präfixen
aktiviert wurde, und einen leeren String, falls nicht.
-->
<![%CAFEML.prefixed;[<!ENTITY % CAFEML.xmlns.extra.attrib "xmlns:%CAFEML.prefix; %URI.datatype; #FIXED '%CAFEML.xmlns;' ">]]>
<!ENTITY % CAFEML.xmlns.extra.attrib "" >
<!ENTITY % XHTML.xmlns.extra.attrib "%CAFEML.xmlns.extra.attrib;" >
<!-- Section B: CafeML Qualified Names ::::::::::::::::::::::::::::: -->
<!-- Dieser Abschnitt deklariert Parameter-Entities, die benutzt werden, um
namensraumqualifizierte Namen für alle CafeML-Elementtypen bereitzustellen.
-->
<!-- module: cafe-1.mod -->
<!ENTITY % CAFEML.quoteoftheday.qname "%CAFEML.pfx;quoteoftheday" >
<!ENTITY % CAFEML.today.qname "%CAFEML.pfx;today" >
<!-- end of cafe-qname-1.mod -->Ejemplo de código: Un fragmento DTD que define nombres y espacios de nombres de today y quoteoftheday
Defina después estos elementos y atributos en su módulo. El W3C ofrece una plantilla adaptable. Sigue las técnicas de módulos XHTML, con referencias a entidades parámetro que se expanden a INCLUDE o IGNORE.
El siguiente fragmento define los elementos today y quoteoftheday. El elemento today permite contenido en párrafos mediante la entidad parámetro Block.mix y exige un atributo date. El elemento quoteoftheday contiene exactamente un elemento blockquote seguido de exactamente un elemento p, sin atributos.
<!-- ................................................................. -->
<!-- CafeML Extension Module ......................................... -->
<!-- file: CafeML-1.mod
Dies ist eine Erweiterung von XHTML, einer Neufassung von HTML als
einer modularen XML-Anwendung.
Dieses DTD-Modul wird durch PUBLIC- und SYSTEM-Identifier identifiziert:
PUBLIC "-//Elliotte Rusty Harold//ELEMENTS CafeML Qualified Names 1.0//EN"
SYSTEM "CafeML-1.mod"
Revisionen:
(keine)
................................................................. -->
<!-- Extension Template
Dieses Template-Modul deklariert zwei Erweiterungselemente,
<today> und <quoteoftheday>. Entsprechend der Namenskonvention für Parameter-Entities
werden Großbuchstaben für den Namen des Entity und Kleinbuchstaben für die
Namensraum-Präfixe verwendet, das heißt, dieses benutzt 'CAFEML' bzw.
'cafe.ml'.
Dieses Modul deklariert Parameter-Entities, die benutzt werden, um
namensraumqualifizierte Namen für alle CafeML-Elementtypen bereitzustellen,
sowie um als erweiterbares Framework für attributbasierte
Namensraum-Deklarationen aller Elementtypen zu dienen.
Das Schlüsselwort %NS.prefixed; für bedingte Abschnitte muss als
"INCLUDE" deklariert werden, damit Präfixe benutzt werden können.
Standardmäßig sollten fremde (d.h. Nicht-XHTML-)Namensraum-Module
%NS.prefixed; von XHTML übernehmen; dies kann aber überschrieben werden, wenn
nur das Nicht-XHTML-Markup mit Präfixen versehen werden soll.
Der in XHTML vorgegebene Wert für das 'Namensraum-Präfix' ist ein leerer
String. Der Präfix-Wert kann entweder in einem DTD-Treiber oder in der internen
Teilmenge eines Dokuments nach Wunsch neu deklariert werden.
HINWEIS: Wie in [XMLNAMES] angegeben, dient das Namensraum-Präfix
als Proxy für die URI-Referenz und ist selbst nicht entscheidend.
-->
<!-- ................................................................ -->
<!-- 1. Deklariert die xmlns-Attribute, die von CAFEML benutzt werden, in Abhängigkeit
davon, ob der Einsatz von Präfixen in CafeML aktiviert wurde. Dies sollte
bei allen CafeML-Elementtypen als Bestandteil der üblichen Attribute
von CafeML eingesetzt werden.
Wenn in der gesamten DTD Namensraum-Präfixe verwendet werden, sollte CafeML
%NS.decl.attrib; übernehmen, ansonsten sollte es %NS.decl.attrib; und ein
xmlns-Attribut auf seinen eigenen Elementtypen deklarieren.
-->
<![%CAFEML.prefixed;[<!ENTITY % CAFEML.xmlns.attrib "%NS.decl.attrib;">]]>
<!ENTITY % CAFEML.xmlns.attrib
"xmlns %URI.datatype; #FIXED '%CAFEML.xmlns;'"
>
<!-- als Nächstes kommen die diversen Markup-Deklarationen ... -->
<!ENTITY % CAFEML.Common.attrib
"%CAFEML.xmlns.attrib;
id ID #IMPLIED"
>
<!-- 2. In der Attributliste jedes Elements werden die XML-Namensräume
deklariert, die in der Dokumentinstanz zulässig sind. Dazu wird
jeder ATTLIST das Parameter-Entity %CAFEML.Common.attrib;
hinzugefügt.
-->
<!ENTITY % CAFEML.today.qname "today" >
<!ELEMENT %CAFEML.today.qname; ( %Flow.mix; )* >
<!ATTLIST %CAFEML.today.qname;
%CAFEML.Common.attrib;
date CDATA #REQUIRED
>
<!ENTITY % CAFEML.quoteoftheday.qname "quoteoftheday" >
<!ELEMENT %CAFEML.quoteoftheday.qname; ( %blockquote.qname;,
%p.qname; ) >
<!ATTLIST %CAFEML.quoteoftheday.qname;
%CAFEML.Common.attrib;
>
<!-- 3. Wenn das Modul Attribute zu Elementen hinzufügt,
die in Modulen definiert wurden,
die nicht den gleichen Namensraum wie dieses Modul haben, deklariere diese
Attribute so, dass sie das Präfix %CAFEML.pfx; verwenden, z.B.:
<!ENTITY % CAFEML.img.myattr.qname "%CAFEML.pfx;myattr" >
<!ATTLIST %img.qname;
%CAFEML.img.myattr.qname; CDATA #IMPLIED
>
Das würde dem Element img des Image-Moduls ein Attribut myattr hinzufügen,
aber der Name des Attributs ist der qualifizierte Name inklusive Präfix,
wenn Präfixe bei der Dokumentinstanz ausgewählt sind.
Für dieses Modul brauchen wir das nicht.
-->
<!-- end of CafeML-1.mod -->Ejemplo de código: Un fragmento DTD que define today y quoteoftheday
Escriba después un módulo de modelo documental que defina entidades de contenido para CafeML y XHTML: así sus elementos forman parte de elementos XHTML. El W3C no ofrece plantilla, pero puede adaptar la de XHTML 1.1 o XHTML Basic. El siguiente ejemplo deriva de XHTML 1.1.
<!-- ............................................................ -->
<!-- CafeML Model Module ....................................... -->
<!-- Datei: CafeML-model-1.mod
PUBLIC "-//Elliotte Rusty Harold//ELEMENTS XHTML CafeML Model 1.0//EN"
SYSTEM "CafeML-model-1.mod"
xmlns:cafeml="http://www.cafeconleche.org/xmlns/cafeml"
............................................................ -->
<!-- Das Inhaltsmodell für Misc.extra definieren -->
<!ENTITY % Misc.extra
"| %CAFEML.today.qname; | %CAFEML.quoteoftheday.qname; ">
<!-- .................... Inline-Elemente ..................... -->
<!ENTITY % HeadOpts.mix "( %meta.qname; )*" >
<!ENTITY % I18n.class "" >
<!ENTITY % InlStruct.class "%br.qname; | %span.qname;" >
<!ENTITY % InlPhras.class
"| %em.qname; | %strong.qname; | %dfn.qname; | %code.qname;
| %samp.qname; | %kbd.qname; | %var.qname; | %cite.qname;
| %abbr.qname; | %acronym.qname; | %q.qname;" >
<!ENTITY % InlPres.class "" >
<!ENTITY % Anchor.class "| %a.qname;" >
<!ENTITY % InlSpecial.class "| %img.qname; " >
<!ENTITY % Inline.extra "" >
<!-- %Inline.class; fügt alle Inline-Elemente ein, die als Komponente
in Mischungen verwendet werden
-->
<!ENTITY % Inline.class
"%InlStruct.class;
%InlPhras.class;
%InlPres.class;
%Anchor.class;
%InlSpecial.class;"
>
<!-- %InlNoAnchor.class; fügt alle Nicht-Anchor-Inline-Elemente ein, die als Komponente in Mischungen verwendet werden
-->
<!ENTITY % InlNoAnchor.class
"%InlStruct.class;
%InlPhras.class;
%InlPres.class;
%InlSpecial.class;"
>
<!-- %InlNoAnchor.mix; fügt alle Nicht-Anchor-Inline-Elemente ein -->
<!ENTITY % InlNoAnchor.mix
"%InlNoAnchor.class;
%Misc.class;"
>
<!-- %Inline.mix; alle Inline-Elemente inklusive %Misc.class; -->
<!ENTITY % Inline.mix
"%Inline.class;
%Misc.class;"
>
<!-- ..................... Block-Elemente ...................... -->
<!ENTITY % Heading.class
"%h1.qname; | %h2.qname; | %h3.qname;
| %h4.qname; | %h5.qname; | %h6.qname;" >
<!ENTITY % List.class "%ul.qname; | %ol.qname; | %dl.qname;" >
<!ENTITY % BlkStruct.class "%p.qname; | %div.qname;" >
<!ENTITY % BlkPhras.class
"| %pre.qname; | %blockquote.qname; | %address.qname;" >
<!ENTITY % BlkPres.class "| %hr.qname;" >
<!ENTITY % Block.extra "" >
<!ENTITY % Table.class "| %table.qname;" >
<!ENTITY % BlkSpecial.class
"%Table.class;"
>
<!-- %Block.class; bindet alle Block-Elemente ein, die als Komponenten in Mischungen verwendet werden -->
<!ENTITY % Block.class
"%BlkStruct.class;
%BlkPhras.class;
%BlkPres.class;
%BlkSpecial.class;
%Block.extra;"
>
<!-- %Block.mix; bindet alle Block-Elemente plus %Misc.class; ein -->
<!ENTITY % Block.mix
"%Heading.class;
| %List.class;
| %Block.class;
%Misc.class;"
>
<!-- ................ Alle Inhaltselemente .................. -->
<!-- %Flow.mix; bindet den Textinhalt ein, sowohl als Block wie auch als Inline -->
<!ENTITY % Flow.mix
"%Heading.class;
| %List.class;
| %Block.class;
| %Inline.class;
%Misc.class;"
>
<!-- Besonderes Inhaltsmodell für das Element pre -->
<!ENTITY % pre.content
"( #PCDATA
| %Inline.class; )*"
>
<!-- Ende von CafeML-model-1.mod -->Ejemplo de código: Un módulo de modelo documental para CafeML
Sustituya por último la DTD estándar por una que importe sus módulos estándar y personalizados. El W3C también ofrece una plantilla. Esta plantilla es una DTD mínima que importa y declara las entidades de las que dependen los demás módulos. El siguiente ejemplo la utiliza, combinando el módulo definido en «Un fragmento DTD que define today y quoteoftheday» con módulos XHTML estándar de tablas, imágenes, etc.
<!-- ................................................................. -->
<!-- XHTML + CafeML DTD ............................................. -->
<!-- file: CafeML.dtd -->
<!-- CafeML DTD -->
<!-- Benutzen Sie bitte diesen formalen PUBLIC-Identifier, um sie zu identifizieren:
"-//Elliotte Rusty Harold//DTD XHTML CafeDTD//EN"
-->
<!ENTITY % XHTML.version "-//W3C//DTD XHTML CafeDTD//EN" >
<!-- Holt alle Module für qualifizierte Namen, die nicht aus XHTML stammen -->
<!ENTITY % CAFEML-qname.mod SYSTEM "cafe-qname-1.mod">
%CAFEML-qname.mod;
<!-- Definiert alle zusätzlichen, mit Präfixen versehenen Namensräume, auf die diese DTD zurückgreift -->
<!ENTITY % NS.prefixed.extras.attrib "" >
<!-- Definiert das Inhaltsmodell für das zu benutzende Framework -->
<!ENTITY % xhtml-model.mod SYSTEM "CafeML-model-1.mod">
<!-- Für die zukünftige Verwendung mit Dokumentprofilen reserviert -->
<!ENTITY % XHTML.profile "" >
<!-- Unterstützung für bidirektionalen Text
Dieses Entity wird eingesetzt, um Elemente und Attribute zu deklarieren,
die zur Internationalisierung dienen. Setzen Sie es auf INCLUDE
oder IGNORE, wie es Ihre Markup-Sprache erfordert.
-->
<!ENTITY % XHTML.bidi "IGNORE" >
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<!-- Prä-Framework-Platzhalter für Neudeklarationen .................... -->
<!-- An dieser Stelle können Auszeichnungsdeklarationen
in die DTD vor den Framework-Deklarationen eingefügt werden.
-->
<!ENTITY % xhtml-prefw-redecl.module "IGNORE" >
<![%xhtml-prefw-redecl.module;[%xhtml-prefw-redecl.mod;<!-- Ende von xhtml-prefw-redecl.module -->]]>
<!-- Das Ereignismodul sollte hier eingefügt werden, falls Sie es benötigen. In diesem Beispiel ist es auf IGNORE gesetzt. -->
<!ENTITY % xhtml-events.module "IGNORE" >
<!-- Modular Framework Module ................................... -->
<!ENTITY % xhtml-framework.module "INCLUDE" >
<![%xhtml-framework.module;[
<!ENTITY % xhtml-framework.mod
PUBLIC "-//W3C//ENTITIES XHTML 1.1 Modular Framework 1.0//EN"
"xhtml11-framework-1.mod" >
%xhtml-framework.mod;]]>
<!-- Post-Framework-Platzhalter für Neudeklarationen ................... -->
<!-- Hier können Auszeichnungsdeklarationen in die DTD eingefügt werden, die den Framework-Deklarationen folgen sollen. -->
<!ENTITY % xhtml-postfw-redecl.module "IGNORE" >
<![%xhtml-postfw-redecl.module;[
%xhtml-postfw-redecl.mod;
<!-- Ende von xhtml-postfw-redecl.module -->]]>
<!-- Textmodul (notwendig) ............................... -->
<!ENTITY % xhtml-text.module "INCLUDE" >
<![%xhtml-text.module;[
<!ENTITY % xhtml-text.mod
PUBLIC "-//W3C//ELEMENTS XHTML 1.1 Text 1.0//EN"
"xhtml11-text-1.mod" >
%xhtml-text.mod;]]>
<!-- Hypertext-Modul (notwendig) ................................. -->
<!ENTITY % xhtml-hypertext.module "INCLUDE" >
<![%xhtml-hypertext.module;[
<!ENTITY % xhtml-hypertext.mod
PUBLIC "-//W3C//ELEMENTS XHTML 1.1 Hypertext 1.0//EN"
"xhtml11-hypertext-1.mod" >
%xhtml-hypertext.mod;]]>
<!-- Listenmodul (notwendig) .................................... -->
<!ENTITY % xhtml-list.module "INCLUDE" >
<![%xhtml-list.module;[
<!ENTITY % xhtml-list.mod
PUBLIC "-//W3C//ELEMENTS XHTML 1.1 Lists 1.0//EN"
"xhtml11-list-1.mod" >
%xhtml-list.mod;]]>
<!-- Ihre Module können hier eingefügt werden. Benutzen Sie die oben definierte Grundform,
und achten Sie darauf, dass Sie für jedes von Ihnen definierte Modul die öffentliche
FPI-Definition in Ihre Katalog-Datei einfügen. Sie können hier auch die vom W3C
definierten Module angeben.
-->
<!-- CafeML-Modul (eigenes Modul) ....................... -->
<!ENTITY % cafeml.module "INCLUDE" >
<![%cafeml.module;[
<!ENTITY % cafeml.mod
PUBLIC "-//Cafe con Leche//XHTML Extensions today 1.0//EN"
"CafeML-1.mod" >
%cafeml.mod;]]>
<!-- Tabellenmodul (optional) ....................... -->
<!ENTITY % xhtml-table.module "INCLUDE" >
<![%xhtml-table.module;[
<!ENTITY % xhtml-table.module
PUBLIC "-//W3C//ELEMENTS XHTML Tables 1.0//EN"
"xhtml-table-1.mod" >
%xhtml-basic-table.mod;]]>
<!-- Metamodul (optional) ....................... -->
<!ENTITY % xhtml-meta.module "INCLUDE" >
<![%xhtml-meta.module;[
<!ENTITY % xhtml-meta.mod
PUBLIC "-//W3C//ELEMENTS XHTML Meta 1.0//EN"
"xhtml-meta-1.mod" >
%xhtml-meta.mod;]]>
<!-- Bildmodul (optional) ....................... -->
<!ENTITY % xhtml-image.module "INCLUDE" >
<![%xhtml-image.module;[
<!ENTITY % xhtml-image.mod
PUBLIC "-//W3C//ELEMENTS XHTML Images 1.0//EN"
"xhtml-image-1.mod" >
%xhtml-image.mod;]]>
<!-- Block-Präsentationsmodul (optional) ....................... -->
<!ENTITY % xhtml-blkpres.module "INCLUDE" >
<![%xhtml-blkpres.module;[
<!ENTITY % xhtml-blkpres.mod
PUBLIC "-//W3C//ELEMENTS XHTML Block Presentation 1.0//EN"
"xhtml-blkpres-1.mod" >
%xhtml-blkpres.mod;]]>
<!-- Dokumentstrukturmodul (notwendig) ....................... -->
<!ENTITY % xhtml-struct.module "INCLUDE" >
<![%xhtml-struct.module;[
<!ENTITY % xhtml-struct.mod
PUBLIC "-//W3C//ELEMENTS XHTML 1.1 Document Structure 1.0//EN"
"xhtml11-struct-1.mod" >
%xhtml-struct.mod;]]>
<!-- Ende der CafeML DTD ............................................ -->
<!-- ................................................................. -->Ejemplo de código: Una DTD XHTML combinada con la DTD Cafe
Copyright © 2005 O'Reilly Verlag GmbH & Co. KG
Puede imprimir la versión en línea para uso privado.
Para cualquier otro uso, este capítulo de «XML in a Nutshell» está sujeto a las mismas condiciones que la edición encuadernada: la obra y todas sus partes están protegidas por derechos de autor. Todos los derechos reservados, incluidos reproducción, traducción, microfilmación, almacenamiento y procesamiento en sistemas electrónicos.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de