For good short XML tutorials see here.
Parts of today's lecture are based on this site.
To have an external part and an internal part, write
<!DOCTYPE NAME SYSTEM "file" [ ... ]>
where [ ... ] indicates the internal DTD.
One of the limitations of DTDs is there is no way of making them modular
by combining several DTDs into one. The DTD for addresses above includes
a DTD for names. This has to be repeated explicitly. It should
be included by referring to it in some way.
<!-- Copyright 2000 The HR-XML Consortium (TM) -->You may use this DTD instead of the newer XML schema mentioned in the project description. For an explanation of XML schemas see here.
<!-- version 1.0 October 17 2000 -->
<!-- 11/05/2000<!ELEMENT PostalAddress (CountryCode , PostalCode? , Region* , Municipality? , DeliveryAddress? , Recipient* )>
<!ATTLIST PostalAddress type (postOfficeBoxAddress | streetAddress | undefined ) 'undefined' >
<!ELEMENT PostalCode (#PCDATA )>
<!ELEMENT CountryCode (#PCDATA )>
<!ELEMENT Region (#PCDATA )>
<!ELEMENT Municipality (#PCDATA )>
<!ELEMENT DeliveryAddress (AddressLine* )>
<!ELEMENT AddressLine (#PCDATA )>
<!ELEMENT Recipient (PersonName? , AdditionalText* , Organization? )>
<!ELEMENT PersonName (FormattedName* , GivenName* , PreferredGivenName? , MiddleName? , FamilyName* , Affix* )>
<!ELEMENT FormattedName (#PCDATA )>
<!ATTLIST FormattedName type (presentation | legal | sortOrder ) 'presentation' >
<!ELEMENT GivenName (#PCDATA )>
<!ELEMENT PreferredGivenName (#PCDATA )>
<!ELEMENT MiddleName (#PCDATA )>
<!ELEMENT FamilyName (#PCDATA )>
<!ATTLIST FamilyName primary (true | false | undefined ) 'undefined' >
<!ELEMENT Affix (#PCDATA )>
<!ATTLIST Affix type (academicGrade |
aristocraticPrefix |
aristocraticTitle|
familyNamePrefix |
familyNameSuffix |
formOfAddress |
generation ) #REQUIRED >
<!ELEMENT AdditionalText (#PCDATA )>
<!ELEMENT Organization (#PCDATA )>
<!ATTLIST image source CDATA #REQUIREDThe meaning of the modifier #REQUIRED is obvious. #IMPLIED means the attribute is optional, and no default value is provided. A literal value is a default for when the attribute is not given a value.
width NMTOKEN #IMPLIED
height NMTOKEN #IMPLIED
format CDATA #FIXED "jpeg"
alt CDATA "No caption provided."
catalogno ID #REQUIRED
owner IDREF "Unknownn_owner"
>
CDATA means that the content of an attribute value can be aribtrary
text inside quotation marks, while NMTOKEN means the content must
be a legal XML name.
<!ENTITY notice "Copyright Regents of the University of California, 2001. All rights reserved.">Then in every document using this DTD you can just write
<header>¬ice;<header>External entities are useful for including non-XML data in an XML document. You do this indirectly, by declaring the external data to be an "entity" in the DTD for the document, for example
<!ENTITY pic SYSTEM "http://www.w3schools.com/entities/photo.gif">Then in the document you can write
<author>&pic;</author>It is the job of the software that parses the XML document to refer back to the DTD and to do something with the URL it finds there.
<f:table xmlns:f="http://www.w3schools.com/furniture">The URL that identifies the namespace is just a placeholder. No corresponding file has to exist, and no information is looked up at this URL. (Technically it is a URI, not a URL.)
In an XSL document, the root element is
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/xsl">All tags that are XSL commands then start with the prefix xsl.
Unfortunately DTDs know nothing about namespaces. If you have
a DTD for a document that uses namespaces, the DTD has to use the same
prefixes. Each namespace should be associated with its own namespace,
which should be included automatically when the namespace is used.
But this is not the case.