Office Open XML Developer Workshop Custom XML Integrating data and documents.
-
Upload
albert-blair -
Category
Documents
-
view
223 -
download
0
Transcript of Office Open XML Developer Workshop Custom XML Integrating data and documents.
![Page 1: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/1.jpg)
Office Open XML Developer Workshop
Custom XMLCustom XMLIntegrating data and documents
![Page 2: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/2.jpg)
Office Open XML Developer Workshop
DisclaimerDisclaimerThe 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, e-mail addresses, logos, people, places and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, email 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.
![Page 3: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/3.jpg)
Office Open XML Developer Workshop
Why Custom XML?Why Custom XML?
Enables interoperability with other systemsDocuments can provide a rich view of back-end data sourcesDocuments can update back-end data sources
Exposes business data in Open XML documentsHeterogenous systems can easily read data from documentsBusiness-specific semantics can be applied to document data
Separates presentation and dataSimplified 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.
![Page 4: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/4.jpg)
Office Open XML Developer Workshop
Custom XML: Developer OptionsCustom XML: Developer Options
![Page 5: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/5.jpg)
Office Open XML Developer Workshop
CUSTOM XML PARTSCUSTOM XML PARTS
![Page 6: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/6.jpg)
Office Open XML Developer Workshop
Custom XML PartsCustom XML Parts
Pure custom data: only your tags appear in the part
Format-agnosticWordprocessingML: relationship from main documentSpreadsheetML: relationship from workbookPresentationML: relationship from presentation or slide
Explicit relationship from a shape on a slide
No content restrictions: any schema (or none), any number of partsSyntactical restriction: must contain well-formed XML
![Page 7: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/7.jpg)
Office Open XML Developer Workshop
Custom XML Part: Properties/MetadataCustom XML Part: Properties/Metadata
Information about a custom XML part is stored in a custom XML properties partStored via an implicit customXmlProps relationship from the custom XML part
Contains two types of information:Part ID
Uniquely identifies a part within a documentMaintained through editing sessionsOffice uses GUIDs, you can use any type of unique identifier
XML Schema references DEMO
![Page 8: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/8.jpg)
Office Open XML Developer Workshop
STRUCTURED DOCUMENT TAGSSTRUCTURED DOCUMENT TAGS
![Page 9: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/9.jpg)
Office Open XML Developer Workshop
Structured Document TagsStructured Document Tags
Smart tags and custom XML markup add semantics, but do not have any effect on presentationSometimes you want to affect presentation
Custom UI behaviors: data-entry restrictions, multi-select, etc.
The solution: the structured document tag <sdt>
![Page 10: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/10.jpg)
Office Open XML Developer Workshop
Structured Document TagsStructured Document Tags
A structured document tag has two sections:
SDT properties
SDT content
![Page 11: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/11.jpg)
Office Open XML Developer Workshop
Structured Document Tag Properties <sdtPr>Structured Document Tag Properties <sdtPr>
Generic properties: Type, Title, ID, placholder textType-specific properties
Example: values for populating a dropdown list
Runtime behaviors (locking properties)Whether region is editableWhether region is deletable
<w:sdtPr> <w:id w:val="865823534" /> <w:placeholder> <w:docPart w:val="DefaultPlaceholder_22675703" /> </w:placeholder> <w:showingPlcHdr /> <w:dataBinding w:prefixMappings="xmlns:ns0='http://myschemas/thisone'" w:xpath="/ns0:Customer[1]/ns0:Name" w:storeItemID="myCustomXmlDataIdentifier" /> <w:text /> </w:sdtPr>
<w:sdtPr> <w:id w:val="865823534" /> <w:placeholder> <w:docPart w:val="DefaultPlaceholder_22675703" /> </w:placeholder> <w:showingPlcHdr /> <w:dataBinding w:prefixMappings="xmlns:ns0='http://myschemas/thisone'" w:xpath="/ns0:Customer[1]/ns0:Name" w:storeItemID="myCustomXmlDataIdentifier" /> <w:text /> </w:sdtPr>
![Page 12: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/12.jpg)
Office Open XML Developer Workshop
Other Control TypesOther Control Types
In addition to plain text:Rich TextDate PickerPictureComboboxDropdown ListDocument Building Block
![Page 13: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/13.jpg)
Office Open XML Developer Workshop
DATA BINDINGDATA BINDING
![Page 14: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/14.jpg)
Office Open XML Developer Workshop
Data Binding: Bringing It All TogetherData Binding: Bringing It All Together
2-way synchronization between:
Content controls (data in structured document tags)Custom XML nodes (data in your schema)
![Page 15: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/15.jpg)
Office Open XML Developer Workshop
Data Binding SyntaxData Binding Syntax
<dataBinding> element inside <sdtPr>
<w:dataBinding w:prefixMappings="xmlns:ns0='http://myschemas/thisone'" w:xpath="/ns0:Customer[1]/ns0:Name" w:storeItemID="myCustomXmlDataIdentifier"/><w:dataBinding w:prefixMappings="xmlns:ns0='http://myschemas/thisone'" w:xpath="/ns0:Customer[1]/ns0:Name" w:storeItemID="myCustomXmlDataIdentifier"/>
![Page 16: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/16.jpg)
Office Open XML Developer Workshop
Data Binding BasicsData Binding Basics
To bind a custom Xml node to a structured document tag:Add a <dataBinding> element to the structured document tag properties <sdtPr><dataBinding> 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 partImplicit relationship in customXmlPart.xml.relsThe properties part specifies a Custom XML Data Identifier
DEMO
![Page 17: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/17.jpg)
Office Open XML Developer Workshop
Content Control ToolkitContent Control Toolkit
Open-source developer toolhttp://www.codeplex.com/Wiki/View.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 programmingUse as a learning tool, to generate markup for use in custom solutions
DEMO
![Page 18: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/18.jpg)
Office Open XML Developer Workshop
CUSTOM XML MARKUPCUSTOM XML MARKUP
![Page 19: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/19.jpg)
Office Open XML Developer Workshop
Custom XML Markup BasicsCustom XML Markup Basics
Allows embedding the structure from any XML schema into a WordprocessingML document
You don’t have to have a schemaYour XML doesn’t have to validate against your schema
Custom XML elements may have custom attributesWhatever is required within your schemaOpen XML consumers/producers preserve your attributes
![Page 20: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/20.jpg)
Office Open XML Developer Workshop
Where can Custom Xml Markup appear?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 nestedComplex multi-level data semantics may be used
![Page 21: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/21.jpg)
Office Open XML Developer Workshop
Custom XML Markup ExampleCustom XML Markup Example
DEMO
![Page 22: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/22.jpg)
Office Open XML Developer Workshop
Custom XML Markup: Why <customXml>?Custom XML Markup: Why <customXml>?
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
![Page 23: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/23.jpg)
Office Open XML Developer Workshop
CUSTOM XML MAPPINGCUSTOM XML MAPPING
![Page 24: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/24.jpg)
Office Open XML Developer Workshop
XML Mapping OverviewXML 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
Top level map object
Custom properties on each cell or column
![Page 25: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/25.jpg)
Office Open XML Developer Workshop
ExampleExample
![Page 26: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/26.jpg)
Office Open XML Developer Workshop
How It All Ties TogetherHow It All Ties Together
Map Object
Table1
Schema
Cell 1
Table 2 Cell 2
SchemaId
mapId
mapIdmapId
mapId
![Page 27: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/27.jpg)
Office Open XML Developer Workshop
Custom XML SourceCustom 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)
![Page 28: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/28.jpg)
Office Open XML Developer Workshop
xmlMaps.xmlxmlMaps.xml
………
…
![Page 29: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/29.jpg)
Office Open XML Developer Workshop
Table1.xmlTable1.xml
![Page 30: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/30.jpg)
Office Open XML Developer Workshop
tableSingleCells.xmltableSingleCells.xml
![Page 31: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/31.jpg)
Office Open XML Developer Workshop
Custom XML Mapping ExampleCustom XML Mapping Example
Save this XML to a file on your desktop:
<?xml version="1.0"?>
<p:PhoneBook xmlns:p="urn:somePhoneBook">
<p:Entry>
<p:FirstName>Brian</p:FirstName>
<p:LastName>Jones</p:LastName>
<p:Number>(425) 123-4567</p:Number>
</p:Entry>
<p:Entry>
<p:FirstName>Chad</p:FirstName>
<p:LastName>Rothschiller</p:LastName>
<p:Number>(425) 123-4567</p:Number>
</p:Entry>
</p:PhoneBook>
![Page 32: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/32.jpg)
Office Open XML Developer Workshop
Custom XML Mapping ExampleCustom 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 ResultsRight-click the list under the XML flyout and choose Export…
![Page 33: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/33.jpg)
Office Open XML Developer Workshop
SMART TAGSSMART TAGS
![Page 34: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/34.jpg)
Office Open XML Developer Workshop
Smart TagsSmart Tags
Semantics may be added to a run or set of runsProvides information about the type of information
• May have application-specific implementation (e.g., purple underline)• Semantics are application-independent
![Page 35: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/35.jpg)
Office Open XML Developer Workshop
Smart Tag Property BagSmart Tag Property Bag
You may want to store additional properties for your smart-tag element
These can be added to <smartTagPr>Any number of custom namespace/element/value settings
Once embedded, consumers can ignore the semantics without affecting the presentation of the documentProducers must preserve the semantic informationOptionally, a producer may use smart tag data to provide context-sensitive functionality
![Page 36: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/36.jpg)
Office Open XML Developer Workshop
Converting Office 2003 smart-tag syntaxConverting Office 2003 smart-tag syntaxIn Office 2003, smart tags used this syntax:<wordDocument>
<body>
<p>
<r><t>Name:</t></r>
<ns0:FirstName><r><t>Brian</r></t></ns0:FirstName>
</p>
</body>
</wordDocument>
In Office Open XML, it works like this:<document> <body> <p> <r><t>Name:</t></r> <customXml uri=“mySchema” element="ns0:FirstName"> <r><t>Brian</r></t> </customXml> </p> </body></document>
![Page 37: Office Open XML Developer Workshop Custom XML Integrating data and documents.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f355503460f94c53e34/html5/thumbnails/37.jpg)
Office Open XML Developer Workshop