マークアップ

odtファイルの中に書かれたマークアップ

Openoffice.prg のワープロである Writer が保存するときのファイルにもタグによるマークアップが使われています。

以下がそれです。< > で囲まれた部分がタグで、これは文書には表示されず、どの部分が見出しであるか、本文であるかなどの情報を示すものです。

<?xml version="1.0" encoding="UTF-8"?><office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" office:version="1.2" grddl:transformation="http://docs.oasis-open.org/office/1.2/xslt/odf2rdf.xsl"><office:scripts/><office:font-face-decls><style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="VL ゴシック" svg:font-family="&apos;VL ゴシック&apos;" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles/><office:body><office:text><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:h text:style-name="Heading_20_1" text:outline-level="1">見出し1にするとこういうスタイル</text:h><text:p text:style-name="Text_20_body">Enterを押して次の「段落」に移ると自動的にスタイルが「本文」になり、字の大きさも変化します。</text:p><text:h text:style-name="Heading_20_2" text:outline-level="2">見出し2です</text:h><text:p text:style-name="Text_20_body">2というのは2番目でなくてレベルが2という意味です。レベルが1,2,3とあれば、1が大見出し2は中見出し3は小見出しという具合になります。</text:p><text:p text:style-name="Text_20_body">やはりEnterで次の「段落」に移ると自動的にスタイルが本文になります。本文の中でEnterを押すと次の「段落」になります。Enterは「改行」ではなく、新しい「段落」にするキーです。</text:p><text:h text:style-name="Heading_20_2" text:outline-level="2">もう一度見出し2です</text:h><text:p text:style-name="Text_20_body">普通のメモや報告文はこの形式があれば十分だと思います。<text:line-break/>段落内の改行は[Shift]+Enterでできます。[Ctrl]+Enterは「改ページ」になります。</text:p><text:p text:style-name="Text_20_body" /></office:text></office:body></office:document-content>

この文書のワープロ画面

画面の日本語の文章を手がかりに、タグの内容と見比べてみましょう。

odtファイルの中に書かれたマークアップを見る方法

.odt ファイルの拡張子を .zip に

右クリックしてしょこマネージャーで開く

これがzipファイルの中身。中でも content.xml に文章が入っています。

content.xml を右クリックして「別のアプリで開く」を選択。

content.xml はテキストファイルですので、エディタで見ることができます。gedit を選択します。

これが gedit で見た content.xml の内容です。xml に合わせて色分けしています。上の配色と異なりますが、プログラム設計者の好みによります。

xml とは

Extensible Markup Language の略。日本語では「拡張可能なマーク付け言語」。

いろいろな目的に応じて独自のマークアップのきまりを作るための約束事です。どんなタグを使ってマークするかを自分で決めることができ、文書の中に一緒に記述したり別ファイルで用意したりします。

オープンな仕様なので広く使われています。

ウェブページ

ウェブページのデータもマークアップされた文書です。.odt と異なり圧縮されていないのでただのテキストファイルです。

HTML( Hyper Text Markup Language )と呼ばれています。これを xml の仕様に合わせた XHTML も使われています。

<html>
<head>
<title>このページのタイトル</title>
</head>
<body>
<h1>私の ウェブページ</h1>
<p>はじめてのウェブページです。</p>
<p>ウェブページでも見出しや太字は<strong>タグ</strong>で指定します。</p>
</body>
</html>

エディタを立ち上げて、上記の灰色地の部分を入力してください。黒色の部分は別の文でもかまいません。青緑色部分は必ず半角文字(直接入力)で入れます。

kadai フォルダに webpage.html という名前で保存します。

kadai フォルダの webpage.html を ブラウザで開きます。右クリックして iceweasel(firefox) で開くのがよいでしょう。

聖愛中学高等学校
http://www.seiai.ed.jp/
Jul. 2011