<!--    $Id: kword.dtd,v 1.12 2000/09/13 18:44:58 shaheed Exp $

This is an XML document type definition (DTD) for the KWord document format.
Written by Kalle Dalheimer <kalle@kde.org> with (obviously) input from KWord's
author Reginald Stadlbauer <reggie@kde.org>.

Please report all bugs to Kalle and Reginald at the above addresses.

KWord overview
--------------

The main structure of each KWord document is a header and a body. The header
contains things like the paper size, the author and so on.

The body is organised around the concept of frames. You might have noticed
that you can do nearly everything with the frames in your KWord document (e.g.
move them around, interlock them, let your text "flow" through them, etc.). To
achieve this flexibility, the body actually has to store the data in a
hierarchy including framesets, frames, paragraphs, and so on.


Some basic notes on XML
-----------------------

- All kinds of numbers are stored like this: foo="1" (between " and " :)

- A rational number looks like this: width="1.03" (note: the '.' separates
integer and fractional parts).

- <XYZ foo="100" bar="0"/> equals <XYZ foo="100" bar="0"></XYZ>

- Unicode-letters (UTF-8 compressed) are used to store the text

- Some special characters ('<', '>') are "escaped" ('&lt;', '&gt;')

- Please launch Kword and save an empty file - it is much easier to follow
this documentation if you wade trough an (almost empty) example document.

- The XML begins with a special tag like this:

    <?xml version="1.0" encoding="UTF-8"?>

Each file starts with this tag. Note: You must not "close" this tag (i.e.
don't put a </?xml...> at the end of the file!).

-->

<!--    A KWord document consists of a paper description, a number of
        attributes and the framesets which contain the actual data. It
        can also define a number of styles.

        Attributes:

            author:         The document's author.

            email:          The document's author's email address.

            editor:         The program this file was written with.

            mime:           The MIME type (must always have the value
                            application/x-kword).

            syntaxVersion:  Integer version of the syntax in the remainder of
                            this file:

                                1...as for KDE 2.0

            url:            ?
-->
<!ELEMENT DOC
    (PAPER, ATTRIBUTES, FRAMESETS, STYLES)>
<!ATTLIST DOC
    author CDATA #IMPLIED
    email CDATA #IMPLIED
    editor CDATA #IMPLIED
    mime CDATA "application/x-kword"
    syntaxVersion CDATA #REQUIRED
    url CDATA #IMPLIED>

<!--    Describes the page format. Can have no or one PAPERBORDERS child that
        describes the margins. Normally this is the first tag in the "header".

        Attributes:

            format:         integer value for the page format:

                                0...DIN A3
                                1...DIN A4
                                2...DIN A5
                                3...US LETTER
                                4...US LEGAL
                                5...SCREEN (screen sized)
                                6...CUSTOM (just enter your prefered size)
                                7...DIN B5
                                8...US EXECUTIVE

            width:          width in millimeters.

            height:         height in millimeters.

            orientation:    page orientation:

                                0...Portrait
                                1...Landscape

            columns:        the number of columns (only in wordprocessing
                            mode).

            columnspacing:  the gap between the columns (only in
                            wordprocessing mode).

            hType:          header style:

                                0...same on all pages
                                1...different on first and other pages
                                2...different on even and odd pages

            fType:          footer style:

                                0...same on all pages
                                1...different on first and other pages
                                2...different on even and odd pages

            spHeadBody:     distance (in pt) between headers and the text body (only in
                            wordprocessing mode).

            spFootBody:     distance (in pt) between footers and the text body (only in
                            wordprocessing mode).
-->
<!ELEMENT PAPER
    (PAPERBORDERS?)>
<!ATTLIST PAPER
    format CDATA #REQUIRED
    width CDATA #REQUIRED
    height CDATA #REQUIRED
    orientation CDATA #REQUIRED
    columns CDATA #REQUIRED
    columnspacing CDATA #REQUIRED
    hType CDATA #IMPLIED
    fType CDATA #IMPLIED
    spHeadBody CDATA #IMPLIED
    spFootBody CDATA #IMPLIED>


<!--    Describes the margins of the page.

        Attributes:

            left:           left margin in pixels.

            right:          right margin in pixels.

            top:            top margin in pixels.

            bottom:         bottom margin in pixels.
-->
<!ELEMENT PAPERBORDERS
    EMPTY>
<!ATTLIST PAPERBORDERS
    left CDATA #REQUIRED
    right CDATA #REQUIRED
    top CDATA #REQUIRED
    bottom CDATA #REQUIRED>


<!--    Contains general attributes of the document. Has no children.

        Attributes:

            processing:     0..."Normal" document (Wordprocessing)
                            1...DTP-document (DTPing)

            standardpage:   currently ignored.

            hasHeader:      0...the document has no headers
                            1...the document has headers

            hasFooter:      0...the document has no footers
                            1...the document has footers

            unit:           Basic unit for positioning, ruler,...
                                mm...
                                pt...
                                inch...
-->
<!ELEMENT ATTRIBUTES
    EMPTY>
<!ATTLIST ATTRIBUTES
    processing CDATA #REQUIRED
    standardpage CDATA #IMPLIED
    hasHeader CDATA #IMPLIED
    hasFooter CDATA #IMPLIED
    unit CDATA #IMPLIED>


<!--    Container that has a number of FRAMESET children.
-->
<!ELEMENT FRAMESETS
    (FRAMESET+)>


<!--    One frameset that bundles a number of FRAME elements.

        Attributes:

            frametype:      0...Base frame (for internal use only!!!)
                            1...Text frame
                            2...Picture frame
                            3...Part frame (e.g. KImage-Part)
                            4...Formula

            frameInfo:      0...normal text
                            1...header for first page
                            2...header for odd pages
                            3...header for even pages
                            4...footer for first pages
                            5...footer for odd pages,
                            6...footer for even pages
                            7...footnote

            removable:      Whether the header-frame is removable or not:

                                0...no
                                1...yes

            visible:        Whether the frame is visible or not:

                                0...no
                                1...yes

            grpMgr:         If present, indicates that this frameset is
                            a cell in a table. The value is the name of the
                            group manager for this table. (i.e. If this
                            frameset "belongs" to a table the position and the
                            size are contolled by a group manager (one for
                            each table)).

            row:            Position in the table (only for tables). Index
                            starts at 0. The index for the next row must equal
                            the index for the current row, plus the
                            value of "rows" for the current row.

            col:            Ditto for columns.

            rows:           Size of this cell in rows (only for tables).

            cols:           Ditto for columns.

-->
<!ELEMENT FRAMESET
    (FRAME|PARAGRAPH)*>
<!ATTLIST FRAMESET
    name CDATA
    frameType CDATA #REQUIRED
    frameInfo CDATA #REQUIRED
    removable CDATA #REQUIRED
    visible CDATA #REQUIRED
    grpMgr CDATA #IMPLIED
    row CDATA #IMPLIED
    col CDATA #IMPLIED
    rows CDATA #IMPLIED
    cols CDATA #IMPLIED>

<!ELEMENT FRAME
    EMPTY>

<!--    Describes a frame of a frameset.

        Attributes:

            right, left, top,
            bottom:             absolute coordinates in pt.

            runaround:          0...No run around
                                1...frame repels text in overlapping frames
                                2...Text in overlapping frames will avoid the
                                    complete horizontal space of this frame.

            runaroundGap:       when runaround is 1 specify here the distance
                                between overlapping frames and runaround text

            autocreatenewframe: 0...AutoExtendFrame
                                1...AutoCreateNewFrame
                                2...Ignore extra text

            newFrameBehaviour:  0...on new page creation; Reconnect frame
                                    to current frameset.
                                1...don't create a followup frame on the new
                                    page.
                                2...This frame will be shown on the new page
                                    as well (with the same content)

            sheetSide:          0...AnySide
                                1...this frame will only be shown on odd pages
                                2...this frame will only be shown on even pages

-->
<!ATTLIST FRAME
    left CDATA #REQUIRED
    right CDATA #REQUIRED
    top CDATA #REQUIRED
    bottom CDATA #REQUIRED
    runaround CDATA #IMPLIED
    runaroundGap CDATA #IMPLIED
    autoCreateNewFrame CDATA #REQUIRED
    newFrameBehaviour CDATA #REQUIRED>

<!ELEMENT PARAGRAPH
    (TEXT|FORMATS|LAYOUT)*>
<!ELEMENT TEXT
    EMPTY>
<!--    Just guess :) Currently the text is stored as UTF-8 compressed Unicode
        glyphs. Note: the format-tags navigate in the text using an index
        which starts at 0 and runs up till it reaches length-1. Also the
        length of the text is used to express format-information.
-->
<!ATTLIST TEXT
    value CDATA #IMPLIED>
<!ELEMENT FORMATS
    (FORMAT*)>
<!ELEMENT FORMAT
    (ANCHOR|COLOR|FONT|SIZE|WEIGHT|ITALIC|UNDERLINE|VERTALIGN)*>

<!--    A format tag describes the format of one or more characters in the
        text.

        Attributes:

            removable:          Whether the header-frame is removable or not.

            id:                 type of format information:

                                    0...none (mustn't be in a file)
                                    1..."normal" text
                                    2...a picture
                                    3...tabulator
                                    4...a variable
                                    5...a footnote
                                    6...an anchor for a floating frame.

            pos:                position where the format starts. This is a
                                zero-based index into the text of the
                                paragraph.

            len:                number of characters after pos for which the
                                format is used.
-->
<!ATTLIST FORMAT
    id CDATA #REQUIRED
    pos CDATA #REQUIRED
    len CDATA #IMPLIED>

<!--    An anchor describes an object which is anchored.

        Attributes:

            type:               What kind of object is being anchored?

                                    grpMgr...a table

            instance:           An identifier that uniquely names the
                                particular instance of the type of object
                                being anchored.
-->
<!ELEMENT ANCHOR
    EMPTY>
<!ATTLIST ANCHOR
    type CDATA #REQUIRED
    instance CDATA #REQUIRED>
<!ELEMENT COLOR
    EMPTY>
<!ATTLIST COLOR
    red CDATA #REQUIRED
    green CDATA #REQUIRED
    blue CDATA #REQUIRED>
<!ELEMENT FONT
    EMPTY>
<!ATTLIST FONT
    name CDATA #REQUIRED>
<!ELEMENT SIZE
    EMPTY>
<!ATTLIST SIZE
    value CDATA #REQUIRED>
<!ELEMENT WEIGHT
    EMPTY>
<!ATTLIST WEIGHT
    value CDATA #REQUIRED>
<!ELEMENT ITALIC
    EMPTY>
<!ATTLIST ITALIC
    value CDATA #REQUIRED>
<!ELEMENT UNDERLINE
    EMPTY>
<!ATTLIST UNDERLINE
    value CDATA #REQUIRED>
<!ELEMENT VERTALIGN
    EMPTY>
<!ATTLIST VERTALIGN
    value CDATA #REQUIRED>
<!ELEMENT LAYOUT
    (NAME|FOLLOWING|FLOW|OFFSETS|INDENTS|COUNTER|LINESPACING|LEFTBORDER|
        RIGHTBORDER|TOPBORDER|BOTTOMBORDER|FORMAT|TABULATOR)*>
<!ELEMENT NAME
    EMPTY>
<!ATTLIST NAME
    value CDATA #REQUIRED>
<!ELEMENT FOLLOWING
    EMPTY>
<!ATTLIST FOLLOWING
    name CDATA #REQUIRED>
<!ELEMENT FLOW
    EMPTY>
<!ATTLIST FLOW
    value CDATA #REQUIRED>
<!ELEMENT OFFSETS
    EMPTY>
<!ATTLIST OFFSETS
    head CDATA #REQUIRED
    foot CDATA #REQUIRED>
<!ELEMENT INDENTS
    EMPTY>
<!ATTLIST INDENTS
    first CDATA #REQUIRED
    left CDATA #REQUIRED>
<!ELEMENT COUNTER
    EMPTY>
<!ATTLIST COUNTER
    type CDATA #REQUIRED
    depth CDATA #REQUIRED
    bullet CDATA #REQUIRED
    start CDATA #REQUIRED
    numberingtype CDATA #REQUIRED
    lefttext CDATA #IMPLIED
    righttext CDATA #IMPLIED
    bulletfont CDATA #REQUIRED>
<!ELEMENT LINESPACING
    EMPTY>
<!ATTLIST LINESPACING
    value CDATA #REQUIRED>
<!ELEMENT LEFTBORDER
    EMPTY>
<!ATTLIST LEFTBORDER
    red CDATA #REQUIRED
    green CDATA #REQUIRED
    blue CDATA #REQUIRED
    style CDATA #REQUIRED
    width CDATA #REQUIRED>
<!ELEMENT RIGHTBORDER
    EMPTY>
<!ATTLIST RIGHTBORDER
    red CDATA #REQUIRED
    green CDATA #REQUIRED
    blue CDATA #REQUIRED
    style CDATA #REQUIRED
    width CDATA #REQUIRED>
<!ELEMENT TOPBORDER
    EMPTY>
<!ATTLIST TOPBORDER
    red CDATA #REQUIRED
    green CDATA #REQUIRED
    blue CDATA #REQUIRED
    style CDATA #REQUIRED
    width CDATA #REQUIRED>
<!ELEMENT BOTTOMBORDER
    EMPTY>
<!ATTLIST BOTTOMBORDER
    red CDATA #REQUIRED
    green CDATA #REQUIRED
    blue CDATA #REQUIRED
    style CDATA #REQUIRED
    width CDATA #REQUIRED>
<!ELEMENT TABULATOR
    EMPTY>
<!ATTLIST TABULATOR
    mmpos CDATA #REQUIRED
    ptpos CDATA #REQUIRED
    type CDATA #REQUIRED>
<!ELEMENT STYLES
    (STYLE*)>
<!ELEMENT STYLE
    (NAME|FOLLOWING|FLOW|OFFSETS|INDENTS|COUNTER|LINESPACING|LEFTBORDER|
        RIGHTBORDER|TOPBORDER|BOTTOMBORDER|FORMAT)*>

