Tecnologías XML / XML / XML in a Nutshell / XML como formato documental / OpenOffice

(Extracto de «XML in a Nutshell» de Elliotte Rusty Harold & W. Scott Means)

Puede escribir el marcado a mano, pero muchos no programadores prefieren un enfoque WYSIWYG más amigable. Un procesador de textos puede guardar XML; Word 2003 y OpenOffice.org Writer ya lo hacen. Harold utilizó Writer para un libro XML bastante más corto, Effective XML, publicado por Addison Wesley.

Nota: Mirando atrás, lamento la decisión. Reescribiría el libro en XML a mano, como Processing XML with Java, en vez de utilizar OpenOffice. Una buena interfaz mejora la productividad y una mala la frena. Una interfaz gráfica no garantiza facilidad.
Scott y yo escribimos este libro en Word, sobre todo porque precedía a otras buenas herramientas XML. También lo lamentamos. Empezando de nuevo, utilizaríamos DocBook.

El código siguiente muestra un documento OpenOffice sencillo, con texto de «XML in a Nutshell». Se diferencia en varios aspectos de TEI y DocBook; por ejemplo, utiliza espacios de nombres, a diferencia de TEI y DocBook. El título y los autores están en un documento de metadatos separado. Los índices se generan a partir de estructura, contenido y marcado, no se insertan explícitamente. Lo más singular es la falta de elementos de sección: capítulos, secciones y subsecciones utilizan el elemento text:h. Una sección incluye todo hasta el siguiente elemento text:h del mismo nivel. El formato también es más general: además de texto narrativo, maneja otros formatos OpenOffice, incluidos gráficos y tablas.

<!DOCTYPE office:document-content PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "office.dtd">
<office:document-content xmlns:office="http://openoffice.org/2000/office" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:fo="http://www.w3.org/1999/XSL/Format" office:class="text" office:version="1.0">
<office:script/>
<office:font-decls>
  <style:font-decl style:name="Courier" fo:font-family="Courier" style:font-pitch="variable"/>
  <style:font-decl style:name="Times" fo:font-family="Times" style:font-pitch="variable"/>
  <style:font-decl style:name="Helvetica" fo:font-family="Helvetica" style:font-family-generic="swiss" style:font-pitch="variable"/>
</office:font-decls>
<office:automatic-styles>
  <style:style style:name="P1" style:family="paragraph" style:parent-style-name="ChapterLabel" style:master-page-name="First Page">
    <style:properties style:page-number="0"/>
  </style:style>
  <style:style style:name="T1" style:family="texstyle:parent-style-name="WW-Comment Reference">
    <style:properties fo:color="#000000"/>
  </style:style>
  <style:style style:name="T2" style:family="text" style:parent-style-name="emphasis">
    <style:properties fo:language="none" fo:country="none"/>
  </style:style>
  <style:style style:name="T3" style:family="text">
    <style:properties fo:language="none" fo:country="none"/>
  </style:style>
</office:automatic-styles>
<office:body>
  <text:sequence-decls>
    <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
    <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
    <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
    <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
  </text:sequence-decls>
  <text:p text:style-name="ChapterTitle">Einführung in XML</text:p>
  <text:p text:style-name="Standard"></text:p>
  <text:p text:style-name="ChapterTitle">XML als Dokumentformat</text:p>
  <text:p text:style-name="Standard">XML ist vor allen Dingen ein Dokumentformat. Es war immer für Webseiten, Bücher, wissenschaftliche Artikel, Gedichte, Kurzgeschichten, Reerenzhandbücher, Anleitungen, Lehrbücher, Plädoyers, Verträge, Gebrauchsanweisungen und andere Dokumente gedacht, die von Menschen gelesen werden. Sein Einsatz als Syntax für Computerdaten in Anwendungen wie Bestellabwicklung, Objektserialisierung, Datenbanken sowie elektronischen Datenaustauschsystemen ist eigentlich nur einglücklicher Zufall.</text:p>
  <text:h text:style-name="Heading 1" text:level="1">Das Vermächtnis von SGML####SGMLs Erbe !?###</text:h>
  <text:p text:style-name="Standard"></text:p>
  <text:h text:style-name="Heading 1" text:level="1">TEI</text:h>
  <text:p text:style-name="Standard"></text:p>
  <text:h text:style-name="Heading 1" text:level="1">DocBook</text:h>
  <text:p text:style-name="Standard">DocBook <text:alphabetical-index-mark text:string-value="DocBook" text:key1="narrative-orientierte XML-Dokumente"/><text:s/><text:alphabetical-index-mark text:string-value="DocBook"/>ist eine SGML-Anwendung, die für neue Dokumente, jedoch nicht für alte entworfen wurde.Sie ist besonders bei Computer-Dokumentationen gebräuchlich. Verschiedene O'Reilly-Bücher wurden in DocBook geschrieben, einschließlich <text:alphabetical-index-mark text:string-value="Walsh, Norman"/>Norm Walsh und Leonard <text:alphabetical-index-mark text:string-value="Muellner, Leonard"/>Muellner's <text:span text:style-name="emphasis">DocBook: The Definitive Guide</text:span>. Es sind keine besonderen Werkzeuge notwendig, um Dokumente in diesem Format zu schreiben. Ein Großteil des Texts des Linux Documentation Projects (LDP) ist in DocBook geschrieben.</text:p>
  <text:p text:style-name="ChapterTitle">XML im Web</text:p>
  <text:p text:style-name="Standard"></text:p>
</office:body>
</office:document-content>

Ejemplo de código: documento OpenOffice

Es solo parte de lo guardado, limpiada para mostrarla. OpenOffice reúne documentos XML relacionados en un zip. Descomprímalo para acceder al XML; el documento mostrado está en el archivo content.xml. Otros archivos contienen estilos, metadatos y preferencias. Podrían reunirse en un elemento office:document, pero normalmente no lo están. La separación entre contenido y presentación es muy útil.

OpenOffice sigue más orientado a presentación que DocBook o TEI. Esto conviene al tratamiento WYSIWYG, pero complica utilizar herramientas como SAX, DOM y XSLT. El tratamiento es posible, pero el marcado da menos pistas semánticas: básicamente títulos, párrafos, listas y tablas, estas últimas ausentes aquí. La información semántica es limitada y se oculta en la presentación, no en los nombres. Sin estilos de caracteres con nombre, con simples cursivas, negritas y Heltvetica, sería casi irrecuperable.

  

<< atrás

siguiente >>

 

 

 

volver arriba