Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

What's New for Developers in OneNote 2007 (Part 2 of 2)

Office 2007

Saul Candib, Microsoft Corporation

May 2006

Applies to: 2007 Microsoft Office Suites, Microsoft Office OneNote 2007

Summary: This article is part two of a two-part series introducing and explaining the new features of interest to developers in Microsoft Office OneNote 2007. Developer-related features include a new COM API that offers new import, export, selection, and search functionality. For information about OneNote 2007 methods and enumerations, see What's New for Developers in OneNote 2007 (Part 1 of 2). (22 printed pages)

Contents

The Microsoft Office OneNote 2007 XML Schema describes content exported from or imported into OneNote 2007. The OneNote 2007 XML Schema represents both notebook hierarchy (notebook, section group, section, and page structure) and page content.

Listed below are some of the most important elements from the OneNote 2007 XML Schema. To see the entire schema, see the 2007 Office System: XML Schema Reference.

In the OneNote 2007 XML Schema, these are valid root nodes:

  • <Notebooks> element

  • <Notebook> element

  • <OtherNotes>element

  • <UnfiledNotes> element

  • <LiveSharedSections> element

  • <Folder> element

  • <Section> element

  • <Page> element

You can use the same XML schema to represent the entire OneNote 2007 notebook hierarchy structure (including all of its content), or just that of a single notebook, section, or page. You can also use the schema to describe partial content. For example, you might want to specify the hierarchy from the Notebooks root downward to a particular page of content, or you might want to specify the hierarchy downward to the section level, without listing any particular pages.

Notebook Hierarchy Elements

The elements in this section represent various elements of the OneNote 2007 notebook hierarchy structure.

<Notebooks> Element

The <Notebooks> element is the root node in the OneNote 2007 XML hierarchy, and therefore is the parent to all other nodes. It represents the collection of all the notebooks in OneNote 2007.

<xsd:complexType name="Notebooks"> 

   <xsd:complexType name="Notebooks"> 
      <xsd:sequence> 
         <xsd:element name="Notebook" type="Notebook" minOccurs="0" maxOccurs="unbounded"/> 
         <xsd:element name="UnfiledNotes" type="UnfiledNotes" minOccurs="0" maxOccurs="1"/> 
         <xsd:element name="OtherNotes" type="OtherNotes" minOccurs="0" maxOccurs="1"/> 
         <xsd:element name="LiveSharedSections" type="LiveSharedSections" minOccurs="0" maxOccurs="1"/> 
      </xsd:sequence> 
   </xsd:complexType> 

Attributes

None

Table 1. Child elements of the <Notebooks> element

Element

Occurrences

<Notebook>

Zero or more

<UnfiledNotes>

Zero or one

<OtherNotes>

Zero or one

<LiveSharedSections>

Zero or one

<Notebook> Element

The <Notebook> element represents a single notebook in OneNote 2007.

<xsd:complexType name="Notebook"> 
   <xsd:sequence> 
      <xsd:element name="Section" type="Section" minOccurs="0"
      maxOccurs="unbounded" /> 
     <xsd:element name="Folder" type="Folder" minOccurs="0"
      maxOccurs="unbounded" /> 
   </xsd:sequence> 
   <xsd:attribute name="nickname" type="xsd:string" /> 
   <xsd:attribute name="color" type="COLOR" default="automatic" /> 
   <xsd:attributeGroup ref="HierarchyObjectAttributes" /> 
   <xsd:attributeGroup ref="FileObjectAttributes" /> 
</xsd:complexType> 

Attributes

When you import XML code into OneNote 2007, the following attributes are optional. OneNote 2007 selects suitable defaults.

  • nickname   The display name of the notebook that the user sees in the user interface (UI). By default, the display name is the same as the notebook section group name when OneNote 2007 creates it, but users can change the display name.

  • color   The color of the notebook icon. For acceptable formats, see the Color Attribute Type section.

  • HierarchyObjectAttributes   Common attributes for all hierarchy objects. For more information about this attribute, see the HierarchyObjectAttributes Attribute Group section.

  • FileObjectAttributes   Common attributes for all hierarchy objects that are also file objects, that is, notebooks, section groups, and sections, but not pages. For more information about this attribute, see the FileObjectAttributes Attribute Group section.

Table 2. Child elements of the <Notebook> element

Element

Occurrences

<Section>

Zero or more

<Folder>

Zero or more

<Folder> Element

The <Folder> element represents a section group in OneNote 2007. Section groups are child nodes of notebooks and contain sections or additional section groups.

<xsd:complexType name="Folder"> 
      <xsd:sequence> 
         <xsd:element name="Section" type="Section" minOccurs="0"
         maxOccurs="unbounded" /> 
         <xsd:element name="Folder" type="Folder" minOccurs="0"
         maxOccurs="unbounded" /> 
      </xsd:sequence> 
      <xsd:attributeGroup ref="HierarchyObjectAttributes" /> 
      <xsd:attributeGroup ref="FileObjectAttributes" /> 
</xsd:complexType> 

Attributes

When you import XML code into OneNote 2007, all of the following attributes are optional. OneNote 2007 selects suitable defaults.

  • HierarchyObjectAttributes   Common attributes for all hierarchy objects. For more information about this attribute, see the HierarchyObjectAttributes Attribute Group section.

  • FileObjectAttributes   Common attributes for all hierarchy objects that are also file objects, that is, notebooks, section groups, and sections, but not pages. For more information about this attribute, see FileObjectAttributes Attribute Group section.

Table 3. Child elements of the <Section group> element

Element

Occurrences

<Section>

Zero or more

<Folder>

Zero or more

Remarks

Sections and section groups are listed in the order in which they are displayed.

<Section> Element

The <Section> element represents a section in OneNote 2007. Sections contain pages.

<xsd:complexType name="Section"> 
   <xsd:sequence> 
      <xsd:element name="Page" type="Page" minOccurs="0"
      maxOccurs="unbounded" /> 
   </xsd:sequence> 
   <xsd:attribute name="color" type="COLOR" default="automatic" /> 
   <xsd:attribute name="encrypted" type="xsd:boolean" default="false" /> 
   <xsd:attribute name="locked" type="xsd:boolean" default="false"/> 
   <xsd:attribute name="readOnly" type="xsd:boolean" default="false" /> 
   <xsd:attributeGroup ref="HierarchyObjectAttributes" /> 
   <xsd:attributeGroup ref="FileObjectAttributes" /> 
</xsd:complexType> 

Attributes

When you import XML code into OneNote 2007, all of the following attributes are optional. OneNote 2007 selects suitable defaults.

  • color   The color of the section tab and background. For accepted formats, see the Color Attribute Type section.

  • encrypted   true, if the section is password-protected by OneNote 2007. Valid only for export. You cannot set encryption on a section file programmatically; it must be done by the user in the UI.

  • locked   true, if the section is locked.

  • readOnly   true, if the section is read-only in OneNote 2007 and if users cannot edit it.

  • HierarchyObjectAttributes   Common attributes for all hierarchy objects. For more information about this attribute, see the HierarchyObjectAttributes Attribute Group section.

  • FileObjectAttributes   Common attributes for all hierarchy objects that are also file objects, that is, notebooks, section groups, and sections, but not pages. For more information about this attribute, see the FileObjectAttributes Attribute Group section.

Table 4. Child elements of the <Section> element

Element

Occurrences

<Page>

Zero or more

Remarks

Pages are listed in the order in which they are displayed.

<Page> Element

The <Page> element represents a page in OneNote 2007.

<xsd:complexType name="Page"> 
   <xsd:sequence> 
      <xsd:element name="NoteFlagDef" type="NoteFlagDef" minOccurs="0"
      maxOccurs="unbounded" /> 
      <xsd:element name="MDIFile" type="MDIFile" minOccurs="0"
      maxOccurs="unbounded" /> 
      <xsd:element name="Meta" type="Meta" minOccurs="0" 
      maxOccurs="unbounded" /> 
      <xsd:element name="MediaPlaylist" type="MediaPlaylist"
      minOccurs="0" /> 
      <xsd:element name="PageSettings" type="PageSettings"
      minOccurs="0" /> 
      <xsd:element name="Title" minOccurs="0"> 
      <xsd:complexType> 
         <xsd:sequence> 
            <xsd:element name="OE" type="OE" /> 
         </xsd:sequence> 
         <xsd:attribute name="selected" type="Selection"
         default="none" /> 
         <xsd:attributeGroup ref="CascadedTextAttributes" /> 
       </xsd:complexType> 
   </xsd:element> 
      <xsd:choice minOccurs="0" maxOccurs="unbounded"> 
         <xsd:element name="Outline" type="Outline"/> 
         <xsd:element name="Image" type="Image"/> 
         <xsd:element name="InkDrawing" type="InkDrawing"/> 
         <xsd:element name="InsertedFile" type="InsertedFile"/> 
         <xsd:element name="MediaFile" type="MediaFile"/> 
       <xsd:choice> 
   </xsd:sequence> 
   <xsd:attribute name="dateTime" type="xsd:dateTime" /> 
      <xsd:attribute name="selected" type="Selection" default="none" /> 
      <xsd:attribute name="isSubPage" type="xsd:boolean" default="false" /> 
   <xsd:attributeGroup ref="HierarchyObjectAttributes" /> 
   <xsd:attributeGroup ref="CascadedTextAttributes" /> 
</xsd:complexType> 

Attributes

When you import XML code into OneNote 2007, all of the following attributes are optional. OneNote 2007 selects suitable defaults.

  • dateTime   The date and time displayed on the page. By default, this is the creation time, but it can be edited by the user. You can import and change this attribute.

  • selected   Whether the user has selected the page or anything on it. For details about the format of this attribute, see the Selection Attribute Type section. If you include this attribute in the XML code that you import, OneNote 2007 ignores it. You must set selection in the UI.

  • isSubPage   true, if the current page is a subpage of another page.

  • HierarchyObjectAttributes   Common attributes for all hierarchy objects. For more information about this attribute, see the HierarchyObjectAttributes Attribute Group section.

  • CascadedTextAttributes   Text-formatting attributes common to all text on the page, unless overridden by text-formatting attributes of an object contained on the page. For more information about this attribute, see the CascadedTextAttributes Attribute Group section.

Table 5. Child elements of the <Page> element

Element

Description

Occurrences

<NoteFlagDef>

Defines one note flag for each type of note flag used on the page. OneNote 2007 requires this element when you import XML code into OneNote for any note flags you use. It always exports this element for all note flag types used on the page.

Zero or more

<MDIFile>

Defines a single Microsoft Document Imaging file. There is one for each file used on the page. OneNote 2007 creates these files when you use the print driver to ";print"; documents into OneNote 2007 as images. OneNote 2007 provides the file details in this element and references the individual pages in the individual <image> tags in the markup on the page.

Zero or more

<Meta>

Specifies custom metadata for the object. The <Meta> element consists of a name-value pair that an add-on application can set to store its own properties on the object. The user cannot see this metadata.

Zero or more

<MediaPlaylist>

Lists the media files (audio or video recordings) on the page, in the order that the OneNote 2007 audio and video recording feature plays them. The list includes only the media-reference GUIDs. OneNote 2007 includes the actual file information where it inserts the files on the page. Path and reference GUIDs are examples of file information that OneNote 2007 includes.

Zero or one.

<PageSettings>

Contains all the page settings for the page, for example, margins.

Zero or one

If you omit this element when you import a new page, OneNote 2007 chooses a suitable default.

<Title>

Contains a single outline element, which is a paragraph of text that is the title of the page.

Zero or one

<InkDrawing>

Contains the ink drawing to be imported. The data is either referenced in a file or is included inline, base 64 encoded.

Zero or more

<InsertedFile>

Specifies a file inserted into a page.

Zero or more

<MediaFile>

Specifies an audio or video file inserted into a page.

Zero or more

<Outline>

Specifies an outline inserted into a page.

Zero or more

<Image>

Specifies an image inserted into a page.

Zero or more

Page Content Elements

The elements in this section represent various elements of the OneNote 2007 page content structure.

<PageObject> Element

The PageObject element represents a top-level content object on a OneNote 2007 page. Content objects include outlines, images, inserted files, ink drawings, and media files, which are OneNote 2007 audio or video recordings. Handwriting ink is contained within outline objects.

  <xsd:complexType name="PageObject"> 
      <xsd:sequence> 
         <xsd:element name="Position" minOccurs="0"> 
         <xsd:element name="Size" type="Size" minOccurs="0"/> 
         <xsd:element name="Meta" type="Meta" minOccurs="0"
         maxOccurs="unbounded"/> 
          <xsd:complexType> 
      </xsd:sequence> 
      <xsd:attribute name="objectID" type="ObjectID" /> 
      <xsd:attribute name="selected" type="Selection" default="none" /> 
      <xsd:attribute name="lastModifiedTime" type="xsd:DateTime"/> 
  </xsd:complexType> 

Attributes

  • objectID   The OneNote 2007 ID for the page object. For more information about this attribute, see the ObjectID Attribute Type section.

  • selected   Whether the user has selected the page or anything on it. For more information about the format of this attribute, see the Selection Attribute Type section. If you include this attribute in the XML code that you import, OneNote 2007 ignores it. You must set selection in the UI.

  • lastModifiedTime   The last time a modification was made to this hierarchy object or any of its child nodes. This attribute is valid only when OneNote 2007 exports XML code. It is ignored when you import XML code into OneNote, because OneNote 2007 sets the time the object or node was last modified.

Table 6. Child elements of the <PageObject> element

Element

Description

Occurrences

<Position>

Provides the x-coordinate and y-coordinate positions of the page object on the page. The coordinates are in points from the origin. The upper left of the page is 0, 0, and the positive direction runs downward and across the page. For languages written from right to left (RTL), 0, 0 is the upper right. Including the <Position> element is optional when you import changes, but OneNote 2007 always includes it when it exports a page.

Zero or one

<Meta>

Specifies custom metadata for the object. The <Meta> element consists of a name-value pair that an add-on application can set to store its own properties on the object. The user cannot see this metadata.

Zero or more

<Size>

Specifies the size of the page object on the page.

Zero or one

<Outline> Element

The <Outline> element represents an object on a OneNote 2007 page that contains text objects, such as outlined text and ink handwriting, and binary objects, such as images.

<xsd:complexType name="Outline"> 
   <xsd:complexContent> 

      <xsd:extension base="PageObject"> 
         <xsd:sequence> 
            <xsd:element name="Indents" minOccurs="0"> 
                  <xsd:complexType> 
                     <xsd:sequence> 
                        <xsd:element name="Indent" maxOccurs="unbounded"> 
                           <xsd:complexType> 
                              <xsd:attribute name="level" type="xsd:nonNegativeInteger" 
                              use="required" /> 
                              <xsd:attribute name="indent" type="PositiveDecimal" 
                              use="required" /> 
                           </xsd:complexType> 
                        </xsd:element> 
                     </xsd:sequence> 
                  </xsd:complexType> 
               </xsd:element> 
               <xsd:element name="OEChildren" type="OEChildren" maxOccurs="unbounded" /> 
          </xsd:sequence> 
          <xsd:attributeGroup ref="CascadedTextAttributes" /> 
          <xsd:attributeGroup ref="EditedByAttributes" /> 
      </xsd:extension> 
   </xsd:complexContent> 
</xsd:complexType> 

Attributes

  • level   The level of the Outline element.

  • indent   The level of the Outline elements relative to the parent. By default, OneNote 2007 indents Outline elements one level. However, you can specify indentation of two or more levels relative to the parent. This attribute cannot be zero or a negative number.

  • CascadedTextAttributes   Text-formatting attributes common to all text in the outline, unless overridden by text-formatting attributes on objects within the outline. For more information about this attribute, see the CascadedTextAttributes Attribute Group section.

  • EditedByAttributes   A set of properties that identify the user who edited content on the page and when the editing occurred.

Table 7. Child elements of the <Outline> element

Element

Description

Occurrences

<Indents>

Specifies the indent size for each level of the outline structure.

Zero or more

<Meta>

Specifies custom metadata for the object. This is a name-value pair that the add-on application can set to store its properties on the object. The user cannot see these properties.

Zero or more

<OEChildren>

Specifies the collection of Outline elements that are contained at the top level in the outline. Outline elements are specified nodes in the outline structure, for example, paragraphs or images. They can contain other, child Outline elements in a hierarchical structure that corresponds to the indented structure of the outline. For more information about this element, see <OEChildren> Element.

Zero or more

<OEChildren> Element

The <OEChildren> element represents the collection of Outline elements (nodes in the outline) that are contained within an Outline element or that appear as a set of child nodes under a higher Outline element.

<xsd:complexType name="OEChildren"> 
   <xsd:sequence> 
      <xsd:element name="ChildOELayout" type="ChildOELayout" minOccurs="0" /> 
      <xsd:choice maxOccurs="unbounded"> 
         <xsd:element name="OE" type="OE" /> 
         <xsd:element name="HTMLBlock" type="HtmlContent" /> 
      </xsd:choice> 
   </xsd:sequence> 
   <xsd:attribute name="indent" type="xsd:positiveInteger" default="1" /> 
   <xsd:attribute name="selected" type="Selection" default="none" /> 
   <xsd:attributeGroup ref="CascadedTextAttributes" /> 
</xsd:complexType> 

Attributes

  • indent   The level of the Outline elements relative to the parent. By default, OneNote 2007 indents Outline elements one level. However, you can specify indentation of two or more levels relative to the parent. This attribute cannot be zero or a negative number.

  • selected   Whether the user has selected the page or anything on it. For more information about the format of this attribute, see the Selection Attribute Type section. If you include this attribute in the XML code that you import, OneNote 2007 ignores it. You must set selection in the UI.

  • CascadedTextAttributes   Text-formatting attributes common to all text in the outline, unless overridden by text-formatting attributes on objects within the outline. For more information about this attribute, see CascadedTextAttributes Attribute Group.

Table 8. Child elements of the <OEChildren> element

Element

Description

Occurrences

<ChildOELayout>

Specifies the spacing and alignment properties that apply to all of the child Outline elements. Examples of spacing are spacing before and after paragraphs and line spacing.

Zero or one

<OE>

Specifies a single Outline element, which is one node of the outline. For more information about this element, see the <OE> Element section.

Zero or more

<HTMLBlock>

Specifies a block of HTML text to import. OneNote 2007 uses this attribute only when you import XML code into OneNote, to simplify importing HTML text structures. OneNote 2007 always exports in fully specified OE structures and does not export HTMLBlocks. When you import an HTMLBlock, OneNote 2007 converts the HTML to OneNote 2007 outline structures. For example, it converts <LI> elements to outline elements. The result is the same as if the user had pasted the HTML content into the page in OneNote 2007. You can include the HTMLBlock inline in a CDATA block or specify a path to the HTML file.

Zero or more

<OE> Element

The <OE> element represents a single Outline element or node of the outline.

<xsd:complexType name="OE"> 
   <xsd:sequence> 
      <xsd:element name="MediaIndex" type="MediaIndex" minOccurs="0" maxOccurs="unbounded" /> 
      <xsd:element name="NoteFlag" type="NoteFlag" minOccurs="0" maxOccurs="unbounded" /> 
      <xsd:element name="Meta" type="Meta" minOccurs="0" maxOccurs="unbounded" /> 
      <xsd:element name="List" type="List" minOccurs="0" /> 
      <xsd:choice> 

      <_- One image, one table, an inserted file, or a mix of Ink and Text pieces --> 
         <xsd:element name="Image" type="Image" /> 
         <xsd:element name="Table" type="Table" /> 
         <xsd:element name="InkDrawing" type="InkDrawing" /> 
         <xsd:element name="InsertedFile" type="InsertedFile" /> 
         <xsd:element name="MediaFile" type="MediaFile" /> 
         <xsd:element name="InkParagraph" type="InkParagraph" /> 
         <xsd:sequence maxOccurs="unbounded"> 

         <_- Text elements can be wrapped in a CDATA marker, if needed,
         and can contain basic HTML for input into the outline -->
         <xsd:element name="T" type="TextRange" minOccurs="0"/> 
         <xsd:element name="InkWord" type="InkWord" minOccurs="0"/> 
         </xsd:sequence> 
      </xsd:choice> 
      <xsd:element name="OEChildren" type="OEChildren" minOccurs="0" 
      maxOccurs="unbounded" /> 
   </xsd:sequence> 
   <xsd:attribute name="RTL" type="xsd:boolean" /> 
   <xsd:attribute name="bodyText" type="xsd:boolean" default="false" /> 
   <xsd:attribute name="collapsed" type="xsd:boolean" default="false" /> 
   <xsd:attribute name="collapsedBodyText" type="xsd:boolean" default="false" /> 
   <xsd:attribute name="alignment" type="Alignment" default="left" /> 
   <xsd:attribute name="selected" type="Selection" default="none" /> 
   <xsd:attribute name="objectID" type="ObjectID" /> 
   <xsd:attributeGroup ref="CascadedTextAttributes" /> 
   <xsd:attributeGroup ref="EditedByAttributes" /> 
   <xsd:attribute name="lastModifiedTime" type="xsd:dateTime"/> 
</xsd:complexType> 

Attributes

  • RTL   (Optional.) true, if the text in the outline is written right-to-left, for example, in Hebrew or Arabic.

  • bodyText   false, by default.

    NoteNote

    The bodyText attribute is rarely used in OneNote 2007. In general, most nodes are standard outline elements. The bodyText attribute indicates a bottom-level leaf node that cannot have child nodes.

  • collapsed   true, if the current view state of the outline is collapsed, for example, if the user double-clicked the Outline element handle to collapse the child nodes under it.

  • collapsedBodyText   true, if the text has the bodyText attribute, and if the user has collapsed the text by choosing Hide Body Text from the View menu.

  • alignment   Alignment of the text in the OE element. You can set the alignment to left, center, or right. By default, the alignment is left.

  • selected   Whether the user has selected the page or anything on it. For more information about the format of this attribute, see the Selection Attribute Type section. If you include this attribute in the XML code that you import, OneNote 2007 ignores it. You must set selection in the UI.

  • objectID   The OneNote 2007 ID for the Outline Element object. For more information about this attribute, see the ObjectID Attribute Type section.

  • CascadedTextAttributes   Text-formatting attributes common to all text in the outline, unless overridden by text-formatting attributes on objects within the outline. For more information about this attribute, see the CascadedTextAttributes Attribute Group section.

  • EditedByAttributes   A set of properties that identify the user who edited content on the page and when the editing occurred.

  • lastModifiedTime   The last time a modification was made to this hierarchy object or any of its child nodes. This attribute is valid only when OneNote 2007 exports XML code. It is ignored when you import XML code into OneNote, because OneNote 2007 sets the time the object or node was last modified.

Child Elements

An OE element can contain a sequence of the elements in the following table. Many of these elements are optional. However, if you do include them, you must do so in the order specified in the schema. Generally, OE property elements come first, followed by the content of the OE element, and then by the outline child nodes below this OE element.

An OE element can contain one of the following elements: Image, Table, InkDrawing, InsertedFile, MediaFile (audio/video recording insertion), or Text. It cannot contain, for example, both Image and Text elements. The only elements it can combine are Text and InkWord.

Table 9. OE Property child elements of the <OE> element

Element

Description

Occurrences

OE Property Elements

<MediaIndex>

A single instance of a media time stamp.

Zero or more

<NoteFlag>

A single instance of an applied note flag.

Zero or more

<Meta>

Specifies custom metadata for the object. This attribute is a name-value pair that the add-on application can set to store its properties on the object. The metadata is not visible to the user in the UI.

Zero or more

<List>

Either a bulleted or numbered list.

Zero or more

Table 10. Content child elements of the <OE> element

Element

Description

Occurrences

<T>

Specifies a range of typed text. The <T> element can have CascadedTextAttributes attribute formatting. It can also have HTML formatting tags within the string, for example, <B> tags.

The <T> element does not support structured, multi-line HTML, for example, <P>, <UL>, <LI>, or <TABLE> tags. To specify this kind of structure, use OneNote 2007 XML structures, such as Outline elements, or use an HTMLBlock element to import the structured HTML.

Zero or more

<Image>

An image in an outline. The data is either referenced in a file or is included inline, base 64 encoded.

<Table>

Specifies a table included in an outline.

<InkDrawing>

Contains the ink drawing to be imported. The data is either referenced in a file or is included inline, base 64 encoded.

<InsertedFile>

Specifies a file inserted into an outline.

<MediaFile>

Specifies an audio or video file inserted in an outline.

<InkWord>

Contains the ink word to be imported. The data is either referenced in a file or is included inline, base 64 encoded.

Zero or more

<InkParagraph>

Contains the ink paragraph to be imported. (This consists of ink that cannot exist within an outline, usually because it is slanted writing).

Table 11. Sub-Outline child elements of the <OE> element

Element

Description

Occurrences

<OEChildren>

Specifies the collection of elements that are contained under the Outline element. OEChildren elements represent specified nodes in the Outline structure, for example, paragraphs or images.

Zero or more. More, if the code includes blocks of child OE elements at different levels of indentation.

Common Attribute Types and Groups

This section describes some of the most common attribute types and groups in the OneNote 2007 XML Schema.

Color Attribute Type

The color attribute type represents the colors of all objects in OneNote 2007 XML. Objects with color include notebooks, section tabs, page backgrounds, and fonts.

<xsd:simpleType name="COLOR"> 
   <xsd:restriction base="xsd:string"> 
      <xsd:pattern value="#[a-fA-F0-9]{6}|none|automatic" /> 
   </xsd:restriction> 
</xsd:simpleType> 

Valid Values

  • #[a-fA-F0-9]{6}   Specifies an RGB value expressed as a 6-digit, hexadecimal value, with each successive pair of digits representing the values for red, green, and blue, in that order.

  • none   Specifies the standard OneNote 2007 color, which is blank and transparent.

  • automatic   Specifies that OneNote 2007 chooses a suitable default color, for example, the default color for fonts or the next available color for section tabs.

HierarchyObjectAttributes Attribute Group

Common attributes for all OneNote 2007 hierarchy elements (notebooks, section groups, sections, and pages). These attributes are always exported by OneNote 2007, but are optional when you import XML code into OneNote.

<xsd:attributeGroup name="HierarchyObjectAttributes"> 
<xsd:attribute name="ID" type="ObjectID" /> 
<xsd:attribute name="name" type="xsd:string" /> 
<xsd:attribute name="lastModifiedTime" type="xsd:dateTime" /> 
<xsd:attribute name="isCurrentlyViewed" type="xsd:boolean" default="false" /> 
</xsd:attributeGroup> 

Attributes

  • ID   The OneNote 2007 object ID for the hierarchy object.

  • name   The name of the hierarchy object. This name is the same as the section group name for notebooks and section groups, the section name for sections, and the page name for pages.

  • lastModifiedTime   The last time a modification was made to this hierarchy object or any of its child nodes. This attribute is valid only when OneNote 2007 exports XML code. It is ignored when you import XML code into OneNote, because OneNote 2007 sets the time the object or node was last modified.

  • isCurrentlyViewed   true, if the user is currently viewing the hierarchy object. For example, this attribute's value is true for the currently viewed page, its parent section, or the current notebook. OneNote 2007 exports this attribute, but it is not required when you import XML code into OneNote, because it is ignored when you import it.

FileObjectAttributes Attribute Group

Common attributes for OneNote 2007 hierarchy elements that are file system objects, such as notebooks, section groups, and sections. Currently, this attribute group includes only the path attribute.

<xsd:attributeGroup name="FileObjectAttributes"> 
<xsd:attribute name="path" type="xsd:string" /> 
</xsd:attributeGroup> 

Attributes

path   The full path string for the file or section group.

CascadedTextAttributes Attribute Group

Each of these attributes applies to a T element. The attribute used for a given T element is the last attribute seen before or on the element. The lang attribute is in ISO 639 format.

Attributes

  • style   The full path string for the file or section group.

  • lang   The full path string for the file or section group.

ObjectID Attribute Type

The representation of an object, to be used for identification of objects on a page.

Selection Attribute Type

The representation of the selection. There are three possible values:

  • none   No selection of this object or any of its children.

  • partial   This object contains at least one selected object.

  • selected   This object is selected (or all of its children are selected).

Sample OneNote 2007 XML File

The following sample shows the contents of a typical XML file that OneNote 2007 exports when you call the GetPageContent method. The sample includes object IDs for every node and specifies all parameters, such as lastModifiedTime and alignment.

When you import content, you do not need to include all of the attributes found in this file, because OneNote 2007 uses defaults for any attributes that you do not include. You must include object IDs only when you overwrite an existing object.

<?xml version="1.0"?> 
<one:Page xmlns:one="http://schemas.microsoft.com/office/onenote/12/2004/onenote" 
ID="Insert here a valid page ID, which you can obtain by calling the GetHierarchy or CreateNewPage method"  
name="Sample XML" dateTime="2006-04-26T18:31:37.000Z" lastModifiedTime="2006-04-26T18:50:22.000Z"  
style="font-family:Calibri;font-size:11.0pt" lang="en-US"> 
   <one:PageSettings RTL="false" color="automatic"> 
      <one:PageSize> 
         <one:Automatic/> 
      </one:PageSize> 
      <one:RuleLines visible="false"/> 
   </one:PageSettings> 
   <one:Title style="font-family:Calibri;font-size:17.0pt" lang="en-US"> 
      <one:OE author="User" lastModifiedBy="User" creationTime="2006-04-26T18:31:37.000Z" lastModifiedTime=
      "2006-04-26T18:31:37.000Z" objectID="{5B6AACF0-E7FC-4E37-AA90-4E64DF1C9969}{15}{B0}" 
      alignment="left"> 
         <one:T> 
            <![CDATA[Sample Text]]> 
         </one:T> 
      </one:OE> 
   </one:Title> 
   <one:Outline author="User" lastModifiedBy="User" lastModifiedTime="2006-04-26T18:50:07.000Z" 
   objectID="{9C6B198F-883E-4F3A-9B4D-892E3963105D}{10}{B0}"> 
      <one:Position x="118.7999954223633" y="158.4000091552734"/> 
      <one:Size width="124.4402389526367" height="13.42771339416504"/> 
      <one:OEChildren> 
         <one:OE creationTime="2006-04-26T18:49:52.000Z" lastModifiedTime="2006-04-26T18:50:07.000Z" 
         objectID="{9C6B198F-883E-4F3A-9B4D-892E3963105D}{11}{B0}" alignment="left"> 
            <one:T> 
               <![CDATA[Sample Text]]> 
            </one:T> 
         </one:OE> 
      </one:OEChildren> 
   </one:Outline> 
</one:Page> 

About Last-Modified Times in OneNote

OneNote stores a value for the last time an element was modified in an attribute called lastModifiedTime. This attribute appears in many elements throughout the OneNote XML schema. You can use the lastModifiedTime attribute value to know when content in OneNote has been updated.

Knowing when content has been updated is important when an application exports data from OneNote and then, subsequently, the data that was exported is changed in OneNote. Such changes can happen either when a user edits a page or when content is merged from a shared notebook. In either case, the exported data is different from the current data in OneNote. If that is the case, you can avoid overwriting or deleting content that has been modified by waiting until OneNote has synchronized all versions of the same content.

The lastModifiedTime value is propagated up from a child element to its parents. If you modify an outline in a page, the outline, page, section, and notebook lastModifiedTime values are updated as well. The resulting lastModifiedTime values are not always exactly the same for every element in the hierarchy, but the lastModifiedTime value for a child element is always earlier to or the same as that of the parent element.

New in OneNote 2007 is the ability to add toolbar buttons that run custom add-ins to the standard toolbars. This feature gives developers the means to run custom code within the OneNote UI. As a developer, you can create a toolbar button on any of the OneNote toolbars to run your add-in, and the button can either display a button icon or a text label. You can also assign a Tooltip to the button.

OneNote add-ins do not run in-process with OneNote; instead, OneNote launches add-ins by means of COM. When a user opens OneNote, OneNote uses registry settings to determine which add-ins to load. You can specify whether OneNote launches your code when it starts or when a user clicks a button in the UI that you provide.

For a toolbar button to run your OneNote add-in, you must do the following:

  • Create a COM add-in that implements IOneNoteAddIn.

  • Register the CLSID of your COM add-in with OneNote.

This article, part two of this two-part series, describes the basics of the OneNote 2007 XML Schema. To learn about the new COM object model for OneNote 2007, including how you can use the new model to modify the OneNote 2007 notebook hierarchy and import and export content in the form of XML code, see What's New for Developers in OneNote 2007 (Part 1 of 2).

Show:
© 2014 Microsoft