none
Why is the URI required for GraphicData element? RRS feed

  • Question

  • Hi all,

    I've built a word document using the Open XML SDK 2.0, but I spent a long time trying to figure out why I couldn't get an image to display correctly in the header of a document.

    As it turns out I needed to set the Uri property of the GraphicData element: -

    1 d.GraphicData graphicData = new d.GraphicData { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" }; 

    Not a major inconvenience, but I'm wondering why I need to set it here and not against any other element? All the other elements seem to get their Uri property set automatically.

    Stuart.
    Wednesday, February 25, 2009 9:04 AM

Answers

  • Hi Stuart,

     Though the standard implies that the uri attribute is optional, Office 2007 requires it.

    Office 2007 implements a finite set of servers for processing the contents of the graphicData element. Office 2007 uses the uri attribute to determine the contents of the graphicData element, as described in the following table:

    URI

    Root Element

    Ref

    http://schemas.openxmlformats.org/drawingml/2006/table

    tbl

    "[ECMA-376] Part 4 §5.1.6.11; tbl"

    http://schemas.openxmlformats.org/drawingml/2006/diagram

    relIds

    "[ECMA-376] Part 4 §5.9.2.22; relIds"

    http://schemas.openxmlformats.org/drawingml/2006/chart

    chart

    "[ECMA-376] Part 4 §5.7.2.26; chart"

    http://schemas.openxmlformats.org/drawingml/2006/picture

    pic

    "[ECMA-376] Part 4 §5.2.2.5; pic"

    http://schemas.openxmlformats.org/drawingml/2006/compatibility

    legacyDrawing

    "[ECMA-376] Part 4 §5.3.2.1; legacyDrawing"

    http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas

    lockedCanvas

    "[ECMA-376] Part 4 §5.4.2.1; lockedCanvas"

    http://schemas.openxmlformats.org/presentationml/2006/ole

    oleObj

    "[ECMA-376] Part 4 §4.4.2.4; oleObj"

     In summary, Office 2007 needs explicit uri value to process the contents in graphicData element.

    Thursday, February 26, 2009 8:42 AM