Presentation is loading. Please wait.

Presentation is loading. Please wait.

Open XML Developer Workshop Custom XML Integrating data and documents.

Similar presentations


Presentation on theme: "Open XML Developer Workshop Custom XML Integrating data and documents."— Presentation transcript:

1 Open XML Developer Workshop Custom XML Integrating data and documents

2 Open XML Developer Workshop Disclaimer The information contained in this slide deck represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This slide deck is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this slide deck may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this slide deck. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this slide deck does not give you any license to these patents, trademarks, copyrights, or other intellectual property. Unless otherwise noted, the example companies, organizations, products, domain names, addresses, logos, people, places and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, address, logo, person, place or event is intended or should be inferred. © 2006 Microsoft Corporation. All rights reserved. Microsoft, 2007 Microsoft Office System,.NET Framework 3.0, Visual Studio, and Windows Vista are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

3 Open XML Developer Workshop Why Custom XML? Enables interoperability with other systems Documents can provide a rich view of back-end data sources Documents can update back-end data sources Exposes business data in Open XML documents Heterogenous systems can easily read data from documents Business-specific semantics can be applied to document data Separates presentation and data Simplified programming model for all of the above Custom XML schema support was a key design objective for Open XML: any schema can be used in Open XML documents.

4 Open XML Developer Workshop Custom XML: Developer Options TechnologyWMLSMLPML Custom XML Parts Format-agnostic, very clean (only your tags) May be non-visible YES Structured Document Tags (Content Controls) Bound to custom XML parts or metadata YES CustomXML Markup Tag block-level content with custom schema Also available in Word 2003 YES Custom XML Mapping WordprocessingML: map content controls to custom Xml parts SpreadsheetML: map cells to nodes in an external XML file YES Smart Tags Simple, familiar, was available in Word 2003 YES

5 Open XML Developer Workshop CUSTOM XML PARTS

6 Open XML Developer Workshop Custom XML Parts Pure custom data: only your tags appear in the part Format-agnostic WordprocessingML: relationship from main document SpreadsheetML: relationship from workbook PresentationML: relationship from presentation or slide Explicit relationship from a shape on a slide No content restrictions: any schema (or none) Syntactical restriction: must contain well-formed XML Open XML Document Document body – Open XMLCustom XML parts – your schemas

7 Open XML Developer Workshop Custom XML Part: Properties/Metadata Information about a custom XML part is stored in a custom XML properties part Stored via an implicit customXmlProps relationship from the custom XML part Contains two types of information: Part ID Uniquely identifies a part within a document Maintained through editing sessions Office uses GUIDs, you can use any type of unique identifier XML Schema references DEMO

8 Open XML Developer Workshop DEMO

9 Open XML Developer Workshop Adding a custom XML part (using the SDK) public void XLInsertCustomXml(string fileName, string customXML) { using (SpreadsheetDocument xlPackage = SpreadsheetDocument.Open(fileName, true)) { // Add a new custom XML part. WorkbookPart workbookPart = xlPackage.WorkbookPart; CustomXmlPart xmlPart = workbookPart.AddNewPart (); // Copy the XML into the new part... using (Stream outputStream = xmlPart.GetStream()) { using (StreamWriter ts = new StreamWriter(outputStream)) { ts.Write(customXML); } xlPackage.Save(); }

10 Open XML Developer Workshop STRUCTURED DOCUMENT TAGS

11 Open XML Developer Workshop Structured Document Tags Smart tags and custom XML markup add semantics, but do not have any effect on presentation Sometimes you want to affect presentation Custom UI behaviors: data-entry restrictions, multi-select, etc. The solution: the structured document tag

12 Open XML Developer Workshop Structured Document Tags A structured document tag has two sections: SDT properties SDT content

13 Open XML Developer Workshop Structured Document Tag Properties Generic properties: Type, Title, ID, placholder text Type-specific properties Example: values for populating a dropdown list Runtime behaviors (locking properties) Whether region is editable Whether region is deletable

14 Open XML Developer Workshop Other Control Types In addition to plain text: Rich Text Date Picker Picture Combobox Dropdown List Document Building Block

15 Open XML Developer Workshop DATA BINDING

16 Open XML Developer Workshop DEMO

17 Open XML Developer Workshop Data Binding: Bringing It All Together 2-way synchronization between: Content controls (data in structured document tags) Custom XML nodes (data in your schema)

18 Open XML Developer Workshop Data Binding Basics To bind a custom Xml node to a structured document tag: Add a element to the structured document tag properties specifices a custom Xml part (by Custom XML Data Identifier) and an Xpath to a specific node within that part Custom XML Data Identifier? What’s that? The custom XML part has a properties part Implicit relationship in customXmlPart.xml.rels The properties part specifies a Custom XML Data Identifier DEMO

19 Open XML Developer Workshop DEMO

20 Open XML Developer Workshop Data Binding Syntax element inside

21 Open XML Developer Workshop Content Control Toolkit Open-source developer tool aspx?ProjectName=dbe Automatically generates parts, relationships, and markup to bind custom XML parts to content controls Use to create data-bound documents with no programming Use as a learning tool, to generate markup for use in custom solutions DEMO

22 Open XML Developer Workshop Macros and custom XML Office 2007 has strong object-model support for custom XML parts VBA macros can be used to enable additional types of data binding beyond built-in capabilities DEMO

23 Open XML Developer Workshop DEMO

24 Open XML Developer Workshop CUSTOM XML MARKUP

25 Open XML Developer Workshop Custom XML Markup Basics Allows embedding the structure from any XML schema into a WordprocessingML document Custom XML elements may have custom attributes Open XML consumers/producers preserve your attributes Document Body (start part) Unstructured contentTagged contentUnstructured contentTagged contentetc … Open XML Document Sections of content tagged with your custom schema

26 Open XML Developer Workshop Where can Custom Xml Markup appear? Custom XML markup can appear at two levels Block level (around and/or sibling to paragraphs) Inline (around and/or sibling to runs) Custom XML markup may be nested Complex multi-level data semantics may be used

27 Open XML Developer Workshop Custom XML Markup Example DEMO

28 Open XML Developer Workshop DEMO

29 Open XML Developer Workshop Custom XML Markup: Why ? Why not just embed the custom XML directly in the WordprocessingML document? Answer: this way, your custom schema doesn’t need to support WordprocessingML within it This abstraction provides the flexibility to support any schema in custom XML markup

30 Open XML Developer Workshop CUSTOM XML MAPPING

31 Open XML Developer Workshop XML Mapping Overview Your custom schema / XML added to a workbook XML elements & attributes ‘mapped’ to cells & Tables Store a copy of the schema in the workbook SpreadsheetML document Open XML parts Sheet data Tables Embedded schema Mapped to cells Mapped to table columns XML data file Import

32 Open XML Developer Workshop Example

33 Open XML Developer Workshop How It All Ties Together Map Object Table1 Schema Cell 1 Table 2 Cell 2 SchemaId mapId

34 Open XML Developer Workshop Custom XML Source A cache of the user schemas added to the workbook (xmlmaps.xml) Nodes mapped to tables (table1.xml) Nodes mapped to single cells (tableSingleCells1.xml)

35 Open XML Developer Workshop xmlMaps.xml … … … …

36 Open XML Developer Workshop Table1.xml

37 Open XML Developer Workshop tableSingleCells.xml

38 Open XML Developer Workshop DEMO

39 Open XML Developer Workshop Custom XML Mapping Example Map the Schema Open a blank Excel spreadsheet. On the Data ribbon choose From Other Sources / From XML Data Import. Find the XML file you just saved and double-click it. Import your Data Following the prompts to map to the SML schema and import the data to the worksheet. Export the Results Right-click the list under the XML flyout and choose Export…

40 Open XML Developer Workshop

41 LAB: CUSTOM XML


Download ppt "Open XML Developer Workshop Custom XML Integrating data and documents."

Similar presentations


Ads by Google