View
520
Download
1
Category
Tags:
Preview:
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
Document Assembly Deep DivePart 2: XPathGenerator
DEV 213
John HollidaySharePoint Architects
John Holliday CTO, SharePoint Architects, Inc. www.SharePointArchitects.us john@johnholliday.net 5 year SharePoint Server MVP
SharePoint Author, Instructor, DeveloperInformation Architecture ConsultantRecords Management Specialist
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
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
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
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
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
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
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
TablesStructured Content Control
Issues
Needs a “template” for table styling
Table Content Control
Data Source
Table Layout Template
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
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
Thank you for attending!
Recommended