1 / 11

Intro to TEI Tomaž Erjavec XML entities and namespaces

Intro to TEI Tomaž Erjavec XML entities and namespaces. Zadar, 2010. poem. stanza. stanza. title. line. line. line. line. line. line. line. line. The SICK ROSE. O Rose thou art sick. The invisible worm,. That flies in the night. In the howling storm :. Has found

rosine
Télécharger la présentation

Intro to TEI Tomaž Erjavec XML entities and namespaces

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Intro to TEITomaž ErjavecXML entities and namespaces Zadar, 2010

  2. poem stanza stanza title line line line line line line line line The SICK ROSE O Rose thou art sick The invisible worm, That flies in the night In the howling storm: Has found out thy bed Of crimson joy And his dark secret love Does thy life destroy. XML data model • <poem><title>The SICK ROSE</title> <stanza><line>O Rose thou art sick.</line> <line>The invisible worm,</line> <line>That flies in the night</line> <line>In the howling storm:</line></stanza> <stanza><line>Has found out thy bed</line> <line>Of crimson joy:</line> <line>And his dark secret love</line> <line>Does thy life destroy.</line></stanza></poem> serialization ~ data model

  3. Empty elements • elements with content: <tag> … </tag> • empty elements have no content:<tag/> • used for indicating “points” in the document, for example page breaks • formally<tag/> = <tag></tag>

  4. Entities • XML documents can also contain entity references, which are, when processing the document, substituted by their interpretation (the entity) • an entity reference starts with the character ampersand and ends with the semicolon: &…; • a few entities are predefinirane in XML: &lt;= < &gt;= > &amp;= & &apos; ='&quot; =" • < and & are “magic” characters and must always be escaped when using them in the text: • 1 < 2 must be written as 1 &lt; 2 • Procter & Gamblemust be written as Procter &amp; Gamble • entities are also used for other purposes

  5. Character references • Character references are used for cases where certain characters cannot represented (entered, stored, transmitted, displayed) directly. • Character reference starts with • &# followed by the decimal number of the character, or by • &#x followed by the hexadecimal number of the character, and ending with ;, e.g.: Saarbr&#252;cken • When processing, such references are substituted by their Unicode codepoint • Codepoints can be found on the Unicode Web pages

  6. XML namespaces A single XML document may contain elements and attributesthat are defined for and used by multiple software modules. Such documents, containing multiple markup vocabularies, pose problems of recognition and collision. Software modules need to be able to recognize the elements and attributes which they are designed to process, even in the face of "collisions" occurring when markup intended for some other software package uses the same element name or attribute name. XML namespaces allow constructions of names so as to avoid clashes between names from different markup vocabularies. This is accomplished by assigning expanded namesto elements and attributes.

  7. XML Namespaces provide a two-part naming system for element types and attributes The xmlns prefixed attributes give the URI and the local prefix of the namespaces Qualified names consist of the prefix, colon, and local part of the name The meaning of the prefix of qualified names is inherited - and possibly overridden - by child elements The default namespace is introduced by the attribute xmlns, without a local prefix

  8. <?xml version="1.0" ?> <html:html xmlns:html="http://www.w3.org/HTML/1998/html4" xmlns:nms="http://www.names.net/address"> <html:head><html:title>Addresses</html:title></html:head> <html:body> <nms:addresses nms:version="1.0"> <html:hr/> <nms:person> <nms:title>Mr.</nms:title> <nms:first>Simon</nms:first> <nms:last>Schuster</nms:last> </nms:person> <html:hr/> <!-- ... --> </html:body> </html:html>

  9. <?xml version="1.0" ?> <html xmlns="http://www.w3.org/HTML/1998/html4" xmlns:nms="http://www.names.net/address"> <head><title>Addresses</title></head> <body> <nms:addresses nms:version="1.0"> <hr/> <nms:person> <nms:title>Mr.</nms:title> <nms:first>Simon</nms:first> <nms:last>Schuster</nms:last> </nms:person> <hr/> <!-- ... --> </body> </html>

  10. XML Namespace Myths There is less to XML Namespaces than meets the eye! The URI is not a URL - it does not need to refer to a DTD or to be accessible; it is never resolved: <?xml version="1.0" ?> <isbn:book xmlns:isbn="urn:ISBN:0-395-36341-6“xmlns:nms="booya://completely-silly-address/ha/ha"> ... The XML Namespaces recommendation is compatible with XML 1.0, hence it does not provide a way to validate a document against two or more DTDs; in fact, it is almost impossible to validate a document using XML Namespaces against a DTD.

  11. Namespaces and TEI With any luck, the only time you will see namespaces in TEI documents is on the root element: <TEI xmlns=“http://www.tei-c.org/ns/1.0”> However, you will need to deal with them if you ever program in XSLT!

More Related