I hope everyone had a great new year. Sorry I've taken so much time off from blogging. I was pretty busy last week just getting caught up on e-mail. For those of you who posted comments, or sent comments to me directly, I'll try to get to them all (sorry it's taking so long). Last month was such a busy month with all the traveling for our work in Ecma and family time for the holidays that I quickly fell behind. Beta 1 of Office has been out for a couple months now, and I haven't posted much content to help people use some of the new XML functionality in Office 12. Today, I want to post an example Word document that leverages the new storage we provide for custom XML and the integration of that XML store with a new feature called content controls. Anyone who has Beta 1 should be able to try this out.
There were are large number of scenarios we looked at when we first started our move towards strong custom XML support back towards the end of Office XP. Some of them were around making document generation much easier and more reliable. Other scenarios were around making the Office documents integrate in richer ways with business processes. There were a number of different exciting scenarios here, but this first example I'm going to show is really more around document generation. We often see people use the mail merge functionality in Word for more than just creating letters. It allows you to import data to create a document driven by that data. We've also seen people do this in Word 2003 using the XML file format in combination with XSLTs. We had been a bit naive in thinking that there would be a lot of folks out there building XSLTs for transforming their data into a rich Word document. There are plenty of people willing to do this, but it's a lot of work, and often too advanced for the majority of people trying to build a solution.
I have an example I've demo'd at a number of conferences that I wanted everyone to get a chance to play around with. If you grab this ZIP file: http://jonesxml.com/resources/xmlMapping1.zip you'll see a Word document and an XML file called "item1.xml". Go ahead and open the Word document in Beta 1 and take a look. I have a couple things I'd like you to try:
This is new functionality that leverages a couple new features. Content controls, the custom XML store, and the ability to map the content controls to nodes in the custom XML store all combined to give you this powerful data view separation.
Even without the XML mapping, the new set of features in Word called content controls make it much easier to structure a rich Word solution. Go ahead and open the original document you'd downloaded again. Notice that in the 2nd paragraph, you can only edit within specific regions. In that 2nd paragraph, there are a number of "content controls", and then the entire paragraph has been "grouped". By grouping the 2nd paragraph when I created the document, I made it so that the look and boilerplate text couldn't be changed, and instead only the content of the controls could be edited. Some of the controls are just plain text, but notice that there are other types of controls as well. The date for example, has a calendar control that will drop down:
There are a number of available content controls:
These new controls, and the new "grouping" functionality make it really easy to design a template where you have some structured islands of information you want the user to fill out. Each control has it's own independent settings as to whether it's editable and whether or not it can be deleted. You can also specify placeholder text to be displayed when the contents of the control is empty.
If you are building a solution, the controls are also really helpful because they can be given unique names that you can use to easily address them in the Object Model. That also makes it really easy to get at them in the file format, since each control will be marked with XML structure. The part that I find most exciting about the controls though, is that you can map these controls to XML nodes in your own schema as we saw in this example.
While I'll need to cover this in more detail later, I did want to quickly explain how you can insert your own content controls. The first thing you'll need to to is make sure that you have the "developer" tab showing in the ribbon. You can do this by going to File -> Word Options, and under the view settings choose "Developer Tools":
Now, click on the "Developer" tab, and you'll see a chunk called "content controls"
With this, you can insert new content controls, as well as modify the properties of existing ones. Go ahead and play around with that a bit, and I'll post some more information later on ways to work with the controls. Some of the other topics I'll try to cover in the future in this area are:
-Brian
(I almost forgot... go Seahawks!)