OfficeOpenXML.com
 

DrawingML Overview

DrawingML is the language for defining graphical objects such as pictures, shapes, charts, and diagrams within ooxml documents. DrawingML是在ooxml文档中定义图形对象(如图片、形状、图表和图表)的语言。It also specifies package-wide appearance characteristics, i.e., the package's theme. 它还指定了包范围的外观特征,即包的主题。DrawingML is not a standalone markup language; it supports and appears within wordprocessingML, spreadsheetML, and presentationML documents. DrawingML不是一种独立的标记语言;它支持并出现在wordprocessingML、spreadsheetML和presentationML文档中。DrawingML is distinct from SVG and VML. DrawingML不同于SVG和VML。SVG (scaleable vector graphics) is a graphics file format for two-dimensional graphics in XML. SVG(可缩放矢量图形)是一种XML格式的二维图形文件格式。It is used mostly on the web and in desktop publishing. 它主要用于网络和桌面出版。VML is a competing language for vector graphic files. VML是矢量图形文件的竞争语言。It is now largely deprecated in favor of SVG. 现在,SVG在很大程度上被弃用。According to the ECMA OOXML specification, "The DrawingML format is a newer and richer format created with the goal of eventually replacing any uses of VML in the Office Open XML formats. 根据ECMA OOXML规范,“DrawingML格式是一种更新、更丰富的格式,旨在最终取代VML在Office开放XML格式中的任何用途。VML is a transitional format; it is included in Office Open XML for legacy reasons only." VML是一种过渡格式;它包含在Office Open XML中只是出于遗留原因。”VML is still used extensively within Microsoft Word for certain graphic comnponents, in particular for things as shapes and text boxes.VML仍然在MicrosoftWord中广泛用于某些图形组件,特别是形状和文本框。

DrawingML is a sprawling, confusing set of specifications for a number of different visual components within office documents. DrawingML是一套杂乱无章、令人困惑的规范,适用于office文档中的许多不同视觉组件。It is composed of a number of different namespaces, and care must be taken to be sure you have the correct namespace and namespace prefix for a given element within a particular document type. 它由许多不同的名称空间组成,必须注意确保在特定文档类型中为给定元素提供了正确的名称空间和名称空间前缀。One must also be mindful of the differences between specification of the object and placement of the object within the document. 还必须注意对象的说明和对象在文档中的位置之间的差异。Sometimes the definition (and namespace) of the object is the same throughout the three document types and only the specification of placement varies from document type to document type. 有时,在三种文档类型中,对象的定义(和名称空间)是相同的,只有不同文档类型的放置规范不同。In other cases, both the object and placement are unique to each document type. 在其他情况下,对象和位置对于每种文档类型都是唯一的。

Below is a brief summary of the various object types within the three document types and their corresponding namespaces. 下面是三种文档类型中的各种对象类型及其相应名称空间的简要总结。DrawingML objects such as charts and diagrams in any document type are all placed within a <a:graphic> element, which in turn contains a <a:graphicData> element. DrawingML对象(如任何文档类型中的图表)都放置在<a:graphic>元素中,该元素又包含一个<a:graphicData>元素。These elements are part of the main drawingML namespace: xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main". 这些元素是drawingML主命名空间的一部分:xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"。The <a:graphicData> element is essentially undefined, so applications can support or not support the particular object that is defined within it. 这个<a:graphicData>元素本质上是未定义的,因此应用程序可以支持或不支持在其中定义的特定对象。The element has a uri attribute which is used to specify the type of data and/or "server" that can process the contents of the element. 元素有一个uri属性,用于指定可以处理元素内容的数据类型和/或“服务器”。For example, the uri for a picture within Word is "http://schemas.openxmlformats.org/drawingml/2006/picture". 例如,Word中图片的uri为“http://schemas.openxmlformats.org/drawingml/2006/picture”。Microsoft Office supports a set of objects, including charts, diagrams, locked canvas, table, ole, etc. Other applications will have their own set of supported object types.Microsoft Office支持一组对象,包括图表、图表、锁定画布、表、ole等。其他应用程序将有自己的一组受支持的对象类型。

  WordProcessing文字处理

Pictures图片

The picture object is defined with other content in the content part, document.xml, within the <pic:pic> element. 图片对象定义在document.xml的<pic:pic>元素中,与其它内容一起定义在其内容部分中。This is wrapped within a <w:drawing> element within the regular wordprocessing namespace: xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main".这被包装在一个 <w:drawing>元素中,在 正规wordprocessing命名空间:xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"中。

The namespace for the picture definition is 图片定义的命名空间为xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture".

The XML for placement of the picture (e.g., whether it is inline [<wp:inline>] or anchored [<wp:anchor>]) is within the wordprocessing drawingML namespace: 用于放置图片的XML(例如,它是内联的[<wp:inline>]还是锚定的[<wp:anchor>])位于wordprocessing drawingML命名空间内:xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing".

Shapes形状 See textboxes below.请参阅下面的文本框。
Charts图表 A diagram is defined outside of the regular content (document.xml) part and is instead defined in a separate part (one for each chart), chart1.xml (or chart2.xml, etc.).图表是在常规内容(document.xml)部分之外定义的,而是在单独的部分(每个图表一个)、chart1.xml(或chart2.xml等)中定义的。

The chart is placed in the document.xml within a <a:graphicData> element, as noted above, by placing a reference to the chart part in an attribute of <a:graphicData>. 如上所述,通过在属性<a:graphicData>中放置对图表部分的引用,图表被放置在元素<a:graphicData>中的document.xml中。The namespace (and uri attribute value of <a:graphicData>) for the diagram specification is xmlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/chart".图表规范的名称空间(以及<a:graphicData>uri属性值)为xmlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/chart"

The XML for placement of the chart (e.g., whether it is inline [<wp:inline>] or anchored [<wp:anchor>]) is within the wordprocessing drawingML namespace: 用于放置图表的XML(例如,它是内联的[<wp:inline>]还是锚定的[<wp:anchor>])位于wordprocessing drawingML命名空间内:xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing".

Diagrams图表 A diagram is defined outside of the regular content (document.xml) part and is instead defined in a group of four separate parts (one group for each diagram): colors#.xml, data#.xml, layout#.xml, and quickStyle#.xml. 图是在常规内容(documentxml)部分之外定义的,而是在一组四个单独的部分中定义的(每个图一组):colors#.xml、data#.xml、layout#.xml和quickStyle#.xml。There is also a fifth part, drawing#.xml, which Microsoft added as an extension for persisting diagram layout information.还有第五部分,drawing#.xml,Microsoft将其添加为持久化图布局信息的扩展。

The diagram is placed in the document.xml within a <a:graphicData> element, as noted above, by placing references to the diagram parts using a <dgm:relIds> element. 如上所述,通过使用<dgm:relIds>元素放置对图部分的引用,将图放置在<a:graphicData>元素内的document.xml中。The namespace (and uri attribute value of <a:graphicData>) for the diagram specification is 图规范的名称空间(和<a:graphicData>uri属性值)为xmlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/diagram".

The XML for placement of the diagram (e.g., whether it is inline [<wp:inline>] or anchored [<wp:anchor>]) is within the wordprocessing drawingML namespace: 用于放置图的XML(例如,它是内联的[<wp:inline>]还是锚定的[<wp:anchor>])位于wordprocessing drawingML命名空间内:xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing".

Textboxes文本框 Shapes and textboxes in Microsoft Word 2003 and 2007 are implemented with VML, which has been largely deprecated and is not covered on this site. Microsoft Word 2003和2007中的形状和文本框是用VML实现的,VML在很大程度上已被弃用,本网站未对此进行介绍。With Word 2010, Microsoft has moved toward using the same data structures that are used for diagrams and charts. 随着Word 2010的推出,微软开始使用与图表相同的数据结构。Word 2010 includes both VML and drawingML in the XML for the document, using <mc:AlternateContent> with a pair of child elements: <mc:Choice Requires="wps">, which contains the drawingML xml, and <mc:Fallback>, which contains the VML. Word 2010在文档的XML中同时包含VML和drawingML,使用带有一对子元素的<mc:AlternateContent><mc:Choice Requires="wps">,其中包含drawingML XML,以及<mc:Fallback>,其中包含VML。The wps for the Requires attribute refers to the new namespace word wordprocessing shapes (as well as to the uri attribute value of <a:graphicData>): xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape".Requires属性的wps引用了新的名称空间文字处理形状(以及uri属性值:xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"

Textboxes and shapes are inserted within the <a:graphicData> element, using a <wps:wsp> element. 文本框和形状使用<wps:wsp>元素插入到<a:graphicData>元素中。The extensions by Microsoft of drawingML for Word are not covered in detail here. 这里不详细介绍Microsoft对Word的drawingML的扩展。Finally, note that text frames are similar to text boxes in many ways, but their underlying XML is very different. They are not part of drawingML. 最后,请注意,文本框架在许多方面类似于文本框,但它们的底层XML非常不同。它们不是drawingML的一部分。它们不是drawingML的一部分。Instead they are within wordprocessingML and their specification is part of the specification of a paragraph. 相反,它们在wordprocessingML中,它们的规范是段落规范的一部分。See WordprocessingML - Text Frames.请参阅WordprocessingML-文本框架

Themes主题 Themes enable common styling across document types and are defined within the main drawingML namespace: 主题支持跨文档类型的通用样式,并在主drawingML命名空间中定义:xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main". They are defined in a separate theme1.xml part.。它们在单独的theme1.xml部分中定义。

 

Spreadsheet电子表格
Pictures图片 A picture is placed within a worksheet by a <drawing> element, which merely references a separate drawing1.xml (or drawing2.xml, etc.) part. 图片由一个<drawing>元素放置在工作表中,该元素仅引用单独的drawing1.xml(或drawing2.xml等)部分。Placement or anchoring of the picture is specified with within the drawing part using the desired anchor (e.g., <xdr:twoCellAnchor> element). 图片的放置或锚定使用所需的锚定(例如,<xdr:twoCellAnchor>元素)在绘图部分内指定。The drawing part contains the <xdr:pic> element, which defines the picture.绘图部分包含定义图片的<xdr:pic>元素。

The namespace is 命名空间为xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing". Note that it is is not within a <a:graphicData> element.。注意,它不在<a:graphicData>元素中。

Shapes形状 A shape is placed within a worksheet by a <drawing> element, which merely references a separate drawing1.xml (or drawing2.xml, etc.) part. Placement or anchoring of the chart is specified with the desired anchor (e.g., <xdr:twoCellAnchor> element) within the drawing part using the xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/speadsheetDrawing" namespace. The drawing part in turn contains an <xdr:sp> element which defines the shape. Note that it is is not within a <a:graphicData> element.
Charts图表 A chart is placed within a worksheet by a <drawing> element, which merely references a separate drawing1.xml (or drawing2.xml, etc.) part. Placement or anchoring of the chart is specified with the desired anchor (e.g., <xdr:twoCellAnchor> element) within the drawing part using the xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/speadsheetDrawing" namespace.

The drawing part in turn contains the typical <a:graphicData> element noted above, which contains a <c:chart> element. That element references a separate part chart1.xml (or chart2.xml, etc) which defines the chart.

The namespace (and uri attribute value of <a:graphicData>) for the chart specification is xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart".

Diagrams图表 A diagram is placed within a worksheet by a <drawing> element, which merely references a separate drawing1.xml (or drawing2.xml, etc.) part. Placement or anchoring of the diagram is specified with the desired anchor (e.g., <xdr:twoCellAnchor> element) within the drawing part using the xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/speadsheetDrawing" namespace.

The drawing part in turn contains the typical <a:graphicData> element noted above, which contains a <dgm:relIds> element. That element references a group of four separate parts (one group for each diagram): colors#.xml, data#.xml, layout#.xml, and quickStyle#.xml which together define the diagram. There is also a fifth part, drawing#.xml, which Microsoft added as an extension for persisting diagram layout information.还有第五部分,drawing#.xml,Microsoft将其添加为持久化图布局信息的扩展。

The namespace (and uri attribute value of <a:graphicData>) for the diagram specification is xmlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/diagram".

Textboxes文本框 Textboxes are created by inserting text into shapes. 文本框是通过将文本插入形状中创建的。See shapes in spreadsheets, above.请参见上面电子表格中的形状。
Themes主题 Themes enable common styling across document types and are defined within the main drawingML namespace: 主题支持跨文档类型的通用样式,并在主drawingML命名空间中定义:xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main". They are defined in a separate theme1.xml part.。它们在单独的theme1.xml部分中定义。

 

Presentation演示
Pictures图片 The picture object is defined with other content for the slide in slide1.xml (or slide2.xml, etc.), within a <p:pic> element.图片对象是在<p:pic>元素中用slide1.xml(或slide2xml等)中的幻灯片的其他内容定义的。

The namespace is 命名空间为xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main". Note that it is is not within a <a:graphicData> element.。注意,它不在<a:graphicData>元素中。

Shapes形状 A shape is defined with other content for the slide in slide1.xml (or slide2.xml, etc.) in a <p:sp> element. The namespace is xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main". Note that it is is not within a <a:graphicData> element.
Charts图表 A chart is placed within a slide by a <p:graphicFrame> element, which in turn contains the typical <a:graphicData> element noted above, which contains a <c:chart> element. That element references a separate part chart1.xml (or chart2.xml, etc) which defines the chart.

The namespace (and uri attribute value of <a:graphicData>) for the chart specification is xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart".

Diagrams图表 A diagram is placed within a slide by a <p:graphicFrame> element, which in turn contains the typical <a:graphicData> element noted above, which contains a <dgm:relIds> element. That element references a group of four separate parts (one group for each diagram): colors#.xml, data#.xml, layout#.xml, and quickStyle#.xml which together define the diagram. There is also a fifth part, drawing#.xml, which Microsoft added as an extension for persisting diagram layout information.

The namespace (and uri attribute value of <a:graphicData>) for the diagram specification is xmlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/diagram".

Text文本 Text is created by inserting text into shapes. 文本是通过将文本插入形状中创建的。See shapes in presentations, above.请参见上面演示文稿中的形状。
Tables表格 OOXML has three different table models--one for wordprocessing tables, on for spreadsheet tables, and one for presentations. This last one is part of drawingML. A table is placed within a slide by a <p:graphicFrame> element, which in turn contains the typical <a:graphicData> element noted above, which contains an <a:tbl> element. That element contains the data for the table inline--the table is NOT in a separate part.

The uri attribute value of <a:graphicData> is "http://schemas.openxmlformats.org/drawingml/2006/table". The namespace for the table specification is the drawingML main namespace 表规范的命名空间是drawingML主命名空间xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main".

Themes主题 Themes enable common styling across document types and are defined within the main drawingML namespace: xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main". They are defined in a separate theme1.xml part.它们在单独的theme1.xml部分中定义。

The ECMA OOXML specification (3rd edition) for drawingML is broken up into different sections, mostly to reflect the different namespaces.用于drawingML的ECMA OOXML规范(第3版)分为不同的部分,主要是为了反映不同的名称空间。

ECMA Specification TOC for DrawingML

There is a section (20.1) on most of the main features in the namespace xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main", including shapes, non-visual properties, colors, and styles. A different section (201.1) covers the remaining parts of the main drawingML namespace, including text and text formatting, bullets and numbering, and tables, all used mostly within presentation documents. There is a separate section (20.2) on pictures generally; the namespace for a picture varies with the document type. Then there is a section (21.2) for the chart namespace (xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart") and a section (21.4) for the diagram namespace (mlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/diagram"). There is a section (20.4) for placement/positioning of drawingML objects within wordprocessing documents (xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"), and a section (20.5) for placement/positioning of drawingML objects within spreadsheet documents (xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing). Finally, there are separate sections on locked canvases (20.3, not covered here) and on drawings within charts (21.3) 最后,在锁定的画布(20.3,此处未涉及)和图表中的图纸(21.3)上有单独的部分(xmlns:cdr="http://schemas.openxmlformats.org/drawingml/2006/chartDrawing).