Sometimes you need to sort some lines of code in Visual Studio – for instance, if you have a long list of Open XML content types, Open XML relationship types, or elements names, you may want that list to be sorted. Here is a little VB snippet (from stackoverflow) that sorts text.
Sub SortLines() Dim Selection As TextSelection = DTE.ActiveDocument.Selection Dim Lines() As String = Selection.Text.Replace(Environment.NewLine, Chr(13)).Split(Chr(13)) Array.Sort(Lines) DTE.UndoContext.Open("Sort Lines") ' Edit - see comments ' Selection.Text = String.Join(Environment.NewLine, Lines) Selection.Delete() Selection.Insert(String.Join(Environment.NewLine, Lines)) DTE.UndoContext.Close() End Sub
Posting this here so I can find it again easily.
Here is something that is very cool. Windows 8 includes Hyper-V, and it is super painless to run the SharePoint 2010 IW Demo VM under Windows 8:
Further, I was able to connect the wireless adapter to the VM, and activate Windows Server 2008 using WIFI. When using this VM under WS2008, it was necessary to physically connect a wire to the computer to do this activation, since there was no way to connect a WIFI adapter so that a VM could connect to the internet.
And, even while the VM is running you can sleep the computer!!!! How awesome is that! This capability alone makes Windows 8 worth the price of admission.
In a nutshell, here are the steps:
- Make sure that you have enabled hardware virtualization in your BIOS.
- Go to Control Panel, then go to Programs and Features
- Click ‘Turn Windows features on or off’
- Check the Hyper-V node in the tree control, let it install, and then reboot.
- Download and unpack the SharePoint 2010 IW Demo VM in the usual way. The remainder of these steps are basically identical to how you setup this VM when using Hyper-V under Windows Server 2008 R2 (with the minor exception that you can use WIFI to activate WS2008 in the VM).
- Using the Virtual Switch Manager in the Hyper-V Manager, add an internal network adapter (as detailed in Virtual Machine Setup Guide.docx). This guide is available on the same page as the rest of the IW Demo VM. This network should be called ‘Internal’. Set the IP4 address, per the instructions in the Virtual Machine Setup Guide.
- Import the Virtual Machine.
- Configure the memory and/or processors as necessary or desired.
- Boot the VM, and let it stabilize. It will add drivers and need to reboot. After rebooting, and letting the machine do all of its JITting, you can start IE and see SharePoint 2010 running.
- Shut down the VM.
- Using the Virtual Switch Manager in the Hyper-V Manager, add the WIFI network adapter.
- Edit the settings for the 2010-10a VM, and add the WIFI adapter to the Virtual Machine.
- Boot the machine. If you have WIFI connectivity, you will be able to browse the web from inside the VM.
- Click Start -> Right-Click Computer -> Properties. You can activate the VM from this dialog box. You now can use this VM without interruption for 180 days.
- Shut down the VM. Remove the WIFI adapter from the settings for the VM.
- Reboot, enjoy
Update August 26, 2015: I have enhanced this document generation system, and published it as part of Open-Xml-PowerTools, which you can find at https://github.com/OfficeDev/Open-Xml-PowerTools. Going forward, I will be enhancing and maintaining that document generation system. Please feel free to clone / fork that repo, report issues on GitHub, and interact with me there.
I recently received a very good request for an enhancement to this document generation system. The request was for a “Repeat” control that works in a similar way to tables, but instead of putting child records into a table, the document generation system generates a repeating section of content.
To review, here is what the template document looked like in the last iteration of this document generation system. Below, you can see a screen-shot of the template document. Following that screen-shot, there is a listing of the XML file that contains the data that will be used in the document generation process.
- The green oval in the template document contains the XPath expression that selects the XML elements that contain the data for each of the documents. That XPath expression selects the Customer elements in the XML document (also circled with a green oval).
- Then, having selected the records for documents, the XPath expression in the blue oval selects the child records for the rows in the table. The context nodes for that XPath expression are the Customer elements selected by the XPath expression in the green oval. The selected elements in the XML document are encircled by a blue rounded rectangle.
- And then finally, the XPath expressions circled by red select the values to place in the cells in the table. In the XML document, the first set of nodes selected by those XPath expressions are also circled with a red oval.
The Repeat construct is parallel to that of a table. The following template document is similar in structure to the above template document, except that instead of generating a table, it generates repeating content.
When generated with the above XML document, the first document in the generated document looks as follows. I have encircled the repeating content with green rounded rectangles:
Of course, due to the recursive implementation, you can get really elaborate with this setup. You can, for instance have repeating content within repeating content, or conditional content that contains a table within repeating content, and so on.
Over the last few years, I’ve written a fair number of blog posts, MSDN articles, OpenXMLDeveloper.org blog posts, and blog posts on my blog at EricWhite.com/blog. In addition, I’ve recorded over 60 screen-casts. I’ve assembled links to all of the content from all of the web sites, and aggregated them in the Blog TOC on this blog. I’ve done my best to make it navigable, including the ability to collapse the long descriptions, so that you can more easly view just the blog post or video titles. I’ve categorized it by important keywords, so that a developer working with Word Automation Services or with PowerTools for Open XML can find all relevant content. You can get to this table-of-content by clicking the Blog Table of Contents link in the blue bar under the header.
I am just about to embark on some interesting writing and screen-casting projects, so wanted to get this blog TOC under control before I started.
New Paper published by Peter O’Kelly – Revisiting Open Document Format and Office Open XML: The Quiet Revolution Continues
Three years ago Peter O’Kelly wrote a paper titled, “What’s Up, .DOC? Open XML Formats, OpenDocument Format, and the Revolutionary Implications of XML in Productivity Applications.” That paper was a part of an industry-wide debate about Open XML and ODF. He has recently published a new paper that analyzes the current state of document formats.
This new paper, Revisiting Open Document Format and Office Open XML: The Quiet Revolution Continues, discusses:
- The business value of standardized, XML based document formats
- A brief history of Open XML and ODF
- The 2008 Open XML ISO controversy, and the response to Peter’s “What’s Up, .DOC?” Paper
- An assessment of current Open XML and ODF market dynamics
- Current standards activity
- Projections into the future
It is interesting reading for document format wonks.
Bob McClellan and I will be hosting a live web-cast on Sept 7 at 8:00 AM PST. We’ll be demoing some new functionality in DocumentBuilder 2.0, discussing the future of PowerTools for Open XML and DocumentBuilder, and taking questions and comments about it. We’d love to hear your feedback, as well as ideas for enhancements. And if we run out of stuff to talk about with DocumentBuilder, any Open XML topic or question is fair game.
So if, like me, you can’t think of anything more fun than getting online with some other geeks, and discussing interrelated markup, document composability, and the intricacies of Open XML WordprocessingML, please join us!
You can find all the details in this blog post at OpenXMLDeveloper.org.
Fourth and Final Screen-Cast in Series on Adding/Updating the TOC in OpenXML WordprocessingML Documents
Whew! I finished the fourth and final screen-cast. In this screen-cast, I show how to use Word Automation Services to repaginate a document and update the table-of-contents.
You can download the code that I present in this video from OpenXMLDeveloper.org.
Here is the complete list of screen-casts in this series.
Explains the markup of tables-of-contents. TOCs use field markup.
Presents some sample code that shows how to insert TOC markup into a document.
Shows how to use Word Automation to update the TOC.
Shows how to use Word Automation Services to update the TOC.
Shows how to use an AutoOpen macro to update the TOC whenever any document that contains a TOC is opened.
I’ve been posting some new content over at OpenXMLDeveloper.org, and somehow didn’t manage to post the info here.
I’ve posted the third (out of four) screen-casts around inserting / updating tables-of-contents.
My goal is to get the fourth posted before the end of the week.
Update: Here is the complete list of screen-casts in this series.
|Screen-cast #1||Explains the markup of tables-of-contents. TOCs use field markup. See Deep dive into OpenXML Fields for more info.|
|Screen-cast #2||Presents some sample code that shows how to insert TOC markup into a document.|
|Screen-cast #3||Shows how to use Word Automation to update the TOC.|
|Screen-cast #4||Shows how to use Word Automation Services to update the TOC.|
The following screen-cast was in response to a specific query in the forums on OpenXMLDeveloper.org. Even if you don’t care about speaker notes in an Open XML PresentationML document, you might be interested in watching this. It shows my approach to researching Open XML markup.
The following screen-cast re-affirmed the truism: it takes more time to make a shorter screen-cast. The following is 6:40 long.
I’ve had a few questions lately about how the Microsoft Public License works.
The text of the Ms-PL: http://www.microsoft.com/opensource/licenses.mspx
You can find a page on Microsoft.com that explains the Ms-PL in straightforward terms: http://www.microsoft.com/resources/sharedsource/communitysourcelicensing.mspx
Here is a StackOverflow.com question/answer page regarding the Ms-PL: http://stackoverflow.com/questions/1424307/how-does-ms-pl-license-work