Checking Namespaces
In line with my last post, if you have multiple custom XML stores in your DOCX package, you'll need to ensure you are pulling the right part. This little function checks the Namespace on the Document Element and returns true or false.
private bool CheckNamespace(PackagePart thisPart, string matchNameSpace){
Stream outputStream = thisPart.GetStream(FileMode.Open, FileAccess.ReadWrite);StreamReader readStream = new StreamReader(outputStream);XmlDocument thisDoc = new XmlDocument();thisDoc.LoadXml(readStream.ReadToEnd());
if (thisDoc.DocumentElement.NamespaceURI == matchNameSpace){
return true;}
else{
return false;}
}
I still think there should be an easier way than reading in the stream to get the namespace on an xml part though I understand the reasons why this was not provided. In the end, this code isn't too expensive and does the basic job. I finally got Office Server 2007 installed on a dev deployment box and am working on using Forms Server to generate UI for a document assembly application using InfoPath forms hosted in an ASPX page. What I can't understand is the requirement that you must develop with XmlFormViewer on the same box as the Forms Server:
" · Development in Visual Studio must occur on the same machine on which Office Forms Server 2007 is installed. "
This is an odd requirement since most of us developers don't keep a copy of our dev engine on our servers. It also doesn't address the likely follow-up question: If I have to dev off the same machine as my server, does this mean I can install the dev engine on a development or lab server and then deploy it to a production server without issues? Do you really mean this is going to be a permanent requirement -- I hope this changes between now and Beta 2 if not RTM.
In a previous comment, a reader asked about code for building new custom xml data stores. I had this code but eliminated it when I chose to use pre-bound controls in the docx file and therefore overwriting the custom XML instead of creating a new one. I'll see if I can dig that code out of my hat and post it soon.