13
Document Assembly Deep Dive Part 2: XPathGenerator DEV 213 John Holliday SharePoint Architects

SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

Embed Size (px)

DESCRIPTION

This session picks up from part 1 by extending the development strategy to include using XPath expressions embedded within a MS Word document template.

Citation preview

Page 1: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

Document Assembly Deep DivePart 2: XPathGenerator

DEV 213

John HollidaySharePoint Architects

Page 2: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

John Holliday CTO, SharePoint Architects, Inc. www.SharePointArchitects.us [email protected] 5 year SharePoint Server MVP

SharePoint Author, Instructor, DeveloperInformation Architecture ConsultantRecords Management Specialist

Page 3: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

Building Open XML Solutions

Observations The markup languages are unique to

each document type. Must anticipate the need to repurpose

data across all types. The rendering mechanisms are unique

to each type.

Strategy Shift the burden to the rendering

application to handle styling and layout. Create a custom API to handle the

business logic and data resolution.

Requirements•Define a consistent architecture•Enable declarative templating•Enable code reuse

Available Tools•Open Packaging API•Microsoft Open XML SDK

Page 4: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

Typical Requirements Insert individual data field values Insert tables with cells containing field

values from a list of objects Insert repeating content sections where

each section may include data supplied by one of a list of objects

Conditionally exclude sections based on the result of comparing a value with a data field value

Page 5: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

Solution Strategy

Basic Approach:1. Create a custom schema for the data

2. Convert the schema to an object model

3. Create a document template in Word

4. Pull data from the object model to the template

5. Test with sample data based on the schema

6. Call the custom API from the client or server

Page 6: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

Solution Architecture

XSD•Data Types•Data Structure

MS Word•Styles•Presentation Layout

POCO•Logic•Data Source(s)•Data Serialization

XML•Data Dictionary

MS WORD

POCO

CONTENT CONTROL

XPATH XML

XSD

Page 7: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

More Strategy

Additional Steps… Insert placeholders in the template Manage ALL data manipulation in the API Manage ALL styling & layout in the template

…and one key innovation Use XPATH to pull data from the model

Page 8: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

Basic Processing UnitMSWord Content Control

Advantages•Easily identifiable in WordProcessingML•Easy to substitute for generated content•Can be nested within other content controls•“Tag” field allows us to declare custom processing

Disadvantages• Limited number of characters• No support for custom properties• No support for custom schemas

RICH TEXT CONTENT CONTROL

Title

TAG

Page 9: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

Key PatternsHandles Most Scenarios

Placeholders

Pulling specific data fields and calculated values

Tables

Displaying lists and external data

May include placeholders

Tricky to deal with nested tables

Repeating Sections

Very common requirement

Images

Very common requirement

SIMPLE TEXT

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore

TABLE

TABLE

reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat

REPEATINGSECTION

Page 10: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

TablesStructured Content Control

Issues

Needs a “template” for table styling

Table Content Control

Data Source

Table Layout Template

Page 11: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

Repeating SectionsStructured Content Control

Issues•Can be tricky to layout•Good candidate for plugin

Repeating Section Control

CONTENT TEMPLATE

reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat

Data Source

Page 12: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

SharePointConfigurationAssembly Job (Content Type)

Data Capture Fields

ECB Action for Assembly

Assembly Jobs (List)

Columns Hold Assembly Data

Lookup to Assembly Template

Custom Action to Build Document

Assembly Templates (Library)

MSWord Assembly Templates

Builder Page (Code Behind)

Loads Assembly Spec

Loads Assembly Template

Builds Document

Finished Documents (Library)

BUILDER.ASPX

FinishedDocuments

Templates

Assembly Jobs

Assembly Job

Lookup

Content Type

Page 13: SPEVO13 - Dev213 - Document Assembly Deep Dive Part 2

Thank you for attending!