InfoPath goes to XML Schemaville
OK, in XML schemaville, when you define an element (<xsd:element></xsd:element>) you define the the type of element it is and what type of children it will contain (text or other xml elements) if you want it to do both (contain text nodes and element nodes) you have to explicitly define it like that typically you define element nodes that contain child element nodes to not contain text nodes as well.
In InfoPath, elements that contain other child elements are called "groups". The IP schema tool does support defining mixed content nodes. So, since your target node is a "group" it is not allowed to contain text. You must either change it to an element (remove group & re-add element by same name) or do not write to it (add a child element to it to write to) .
Thursday, March 29, 2007
Thursday, March 15, 2007
Generate Xpath Statement
Ever want to work out what the Xpath statement would be for a current node of an XML document? Well here you go. This little tid bit will quickly work its way back up the parent-grandparent tree, up to the root node of the document. And when it's done, you'll be returned the Xpath statement.
Code: (generated for InfoPath C# managed code)
private string GenerateMatchPath(IXMLDOMNode sourceNode, string xPath)
{
IXMLDOMNode parentNode = sourceNode.parentNode;
while (parentNode != null && parentNode.nodeName != "#document")
{
xPath = parentNode.nodeName + "/" + xPath;
parentNode = parentNode.parentNode; } return "/" + xPath;
}//GenerateMatchPath
Now, why would this be useful?
Suppose you would like to compare the data of a pair of XML documents (docA and docB).
If you used an Xpath query (xmlDoc.selectNodes("//descendant-or-self::node()")) to generate a nodelist of all elements in docA, you could:
Ever want to work out what the Xpath statement would be for a current node of an XML document? Well here you go. This little tid bit will quickly work its way back up the parent-grandparent tree, up to the root node of the document. And when it's done, you'll be returned the Xpath statement.
Code: (generated for InfoPath C# managed code)
private string GenerateMatchPath(IXMLDOMNode sourceNode, string xPath)
{
IXMLDOMNode parentNode = sourceNode.parentNode;
while (parentNode != null && parentNode.nodeName != "#document")
{
xPath = parentNode.nodeName + "/" + xPath;
parentNode = parentNode.parentNode; } return "/" + xPath;
}//GenerateMatchPath
Now, why would this be useful?
Suppose you would like to compare the data of a pair of XML documents (docA and docB).
If you used an Xpath query (xmlDoc.selectNodes("//descendant-or-self::node()")) to generate a nodelist of all elements in docA, you could:
- loop through each node from docA
- get its value
- generate the xpath
- use the xpath to get the value from docB
- compare values
- take appropriate action (update docA? update docC?)
[Snippet to follow...]
Tuesday, March 13, 2007
Clearing Windows network passwords.
I have recently found problems with my Visual Source Safe 2005 (VSS) solution bindings breaking in Visual Studio .NET 2005 (VS2005). On two occassions in the last week I have encountered "Invalid Handle" errors when trying to check-in my solutions.
The invalid handle error is due to the VSS bindings. The solution has been to restablish the bindings, however, this was hampered by the root problem ;) Somehow a bad password was saved, and the connection to the VSS server could not be established. So, the corrupt credentials must be removed.
To do this, I found James Geurts' Blog on 'Clear saved windows networking passwords' where he supplies the following:
Start>Run>rundll32.exe keymgr.dll, KRShowKeyMgr
The same dialog can be opened via:
Start>Control Panel>User Accounts>Advanced Tab>Manage Passwords
I prefer the latter option as it is easier to remember and find again ;)
(James Geurts' Blog http://biasecurities.com/blogs/jim/archive/2005/12/20/3876.aspx)
I have recently found problems with my Visual Source Safe 2005 (VSS) solution bindings breaking in Visual Studio .NET 2005 (VS2005). On two occassions in the last week I have encountered "Invalid Handle" errors when trying to check-in my solutions.
The invalid handle error is due to the VSS bindings. The solution has been to restablish the bindings, however, this was hampered by the root problem ;) Somehow a bad password was saved, and the connection to the VSS server could not be established. So, the corrupt credentials must be removed.
To do this, I found James Geurts' Blog on 'Clear saved windows networking passwords' where he supplies the following:
Start>Run>rundll32.exe keymgr.dll, KRShowKeyMgr
The same dialog can be opened via:
Start>Control Panel>User Accounts>Advanced Tab>Manage Passwords
I prefer the latter option as it is easier to remember and find again ;)
(James Geurts' Blog http://biasecurities.com/blogs/jim/archive/2005/12/20/3876.aspx)
Saturday, October 21, 2006
Missing nodes from a webservice.
InfoPath is very particular about the type of document it processes - this due to its very stringent implementation of XSD Schemas. InfoPath will complain immediately if it encounters nodes that do not fit the schema design (nodes not defined in schema, nodes out of position, multiple nodes where not defined as repeating)
If a node is missing from the instance document and the schema dictates the optional presence of this node, InfoPath will accept the document as valid. However, if there are any controls being bound to the missing field, InfoPath will disable the field in the UI, as nothing can be written to a missing node.
This became painfully apparent in our early iterations of our InfoPath form. We noticed several fields being locked out in the form only to discover the fields were missing from the XML documents returned by our Webservice. We tracked this down to the Enterprise Library's Database Datatable to XML conversion.
Any null values in a recordset are not converted to empty fields in the resulting XML, but rather they are just omitted. Our solution was to use the schema to build ourselves an empty instance document and populate it with the data from the recordset. This way we are guaranteed to get all required nodes returned from a webservice
Since a schema document is simply another XML document, parse the XSD document and programmatically build the instance document starting from the root node element definition.. TBC
InfoPath is very particular about the type of document it processes - this due to its very stringent implementation of XSD Schemas. InfoPath will complain immediately if it encounters nodes that do not fit the schema design (nodes not defined in schema, nodes out of position, multiple nodes where not defined as repeating)
If a node is missing from the instance document and the schema dictates the optional presence of this node, InfoPath will accept the document as valid. However, if there are any controls being bound to the missing field, InfoPath will disable the field in the UI, as nothing can be written to a missing node.
This became painfully apparent in our early iterations of our InfoPath form. We noticed several fields being locked out in the form only to discover the fields were missing from the XML documents returned by our Webservice. We tracked this down to the Enterprise Library's Database Datatable to XML conversion.
Any null values in a recordset are not converted to empty fields in the resulting XML, but rather they are just omitted. Our solution was to use the schema to build ourselves an empty instance document and populate it with the data from the recordset. This way we are guaranteed to get all required nodes returned from a webservice
Since a schema document is simply another XML document, parse the XSD document and programmatically build the instance document starting from the root node element definition.. TBC
Friday, October 13, 2006
Friday, October 13, 2006
Breaking In A New Horse
One of the growing pains I encountered after migrating to Visual Studio 2005, was an issue I had trying to debug my InfoPath 2003 project. I would get an error message;
"In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project."
While VS 2003 would launch the InfoPath form and Debug it with a fancy-free click of the 'Debu' button, VS 2005 requires you to have the solution selected before it will attempt to launch the form.
However that brought me to an issue I was not previously having. Without having changed any code, the form failed to load in preview or debug mode. Now I am getting the “The format of the file .dll is invalid” error. You would see this error on our dev-test VPCs that did not have the .NET 2.0 framework installed prior to launching the new form.
How is it possible that the DEV workstation compiling the formcode.cs in Visual Studio 2005 .NET 2.0 did not have .Net 2.0 installed?!?
After a quick reinstall of the framework and a restart, the form is debugging and previewing again.
So in recap; select the solution item in the Solution Explorer of Visual Studio 2005 BEFORE attempting to debug (F5).
Ciao for Niao
Thursday, October 12, 2006
The project I'm currently working on finally afforded the time to convert the project from 2003 platforms to 2005 servers and .NET 2.0. While many of my collegues in other companies made the change last year, we are a consulting firm doing work for clients and so we required approval from the customer to proceed.
So far the InfoPath conversion was rather painless as we are not migrating to Office 2007 (yet?). The managed code compiled beautifully in Visual Studio 2005 and after installing the .Net 2.0 Framework on the test workstations, the form opened without flaw. However the webservices needed to be migrated to another machine name to not conflict with Sharepoint Services which are still running 1.1.4.
Our form displays a simple windows form with a rotating graphic scheme as a “Please Wait” message. Initially, a couple of them got stuck on the display and new ones stop showing up. Not sure what the cause was, but it seems to have corrected itself - perhaps the first load of the new form in .NET 2.0?
Other than that things went very well from my end. Next on the migration for me is Notification Services. Another breeze I expect.
Ciao for Niao
So far the InfoPath conversion was rather painless as we are not migrating to Office 2007 (yet?). The managed code compiled beautifully in Visual Studio 2005 and after installing the .Net 2.0 Framework on the test workstations, the form opened without flaw. However the webservices needed to be migrated to another machine name to not conflict with Sharepoint Services which are still running 1.1.4.
Our form displays a simple windows form with a rotating graphic scheme as a “Please Wait” message. Initially, a couple of them got stuck on the display and new ones stop showing up. Not sure what the cause was, but it seems to have corrected itself - perhaps the first load of the new form in .NET 2.0?
Other than that things went very well from my end. Next on the migration for me is Notification Services. Another breeze I expect.
Ciao for Niao
Monday, September 11, 2006
The Great Giveaway continues...
Ever tried to get unique items out of the events table in SQL Notification Services?
Use the greatest EventBatchId with EventCount greater than 0 from the EventBatches table, to identify the latest set of events written to the Events table.
The Current Events table will have the events trapped by the events query at runtime, however the records are temporary and get dumped to the events table. The above method is the best way to locate the latest events.
Ciao for Niao
Ever tried to get unique items out of the events table in SQL Notification Services?
Use the greatest EventBatchId with EventCount greater than 0 from the EventBatches table, to identify the latest set of events written to the Events table.
The Current Events table will have the events trapped by the events query at runtime, however the records are temporary and get dumped to the events table. The above method is the best way to locate the latest events.
Ciao for Niao
Friday, September 08, 2006
Ever tried updating a solution from Source Safe and get a dialog box asking to redeploy a website/virtural directory to another location? (usally the same name suffixed with an underscore and a number)
Well, to redeploy the website to the same URL, go to the directory and delete the project file (*.csproj or *.vbproj...). You may then go back to the dialog box and fix the URL to publish back to the original path. The project will deploy successfully.
Well, to redeploy the website to the same URL, go to the directory and delete the project file (*.csproj or *.vbproj...). You may then go back to the dialog box and fix the URL to publish back to the original path. The project will deploy successfully.
Friday, August 18, 2006
YES/NO/CANCEL
I recently received an issue from our diligent QA department asking to have a dialog box, which presented Yes/No/Cancel as options, shortened down to just Yes/No
I responded with my reason for the existance of this combination of options:
It is a UI decision. Both Yes and No are definitive answers to a question, however, sometimes a user will interact an application and perform actions that they had no intentions of doing.
Definitive answers like Yes and No imply that you are instructing the application to do something (even if you answer no). Because you answered the question, the application is going to take action accordingly.
The Cancel option gives the user peace-of-mind that, if they just cancel, nothing will happen because they have just instructed the application to "cancel" the previous action all together.
Of course wording the question is crucial here. The question could very well imply that clicking No means that the action will be cancelled. However with a very critical action, a user may feel more at ease indicating to the application to completely disregard the previous action, even if No does mean NO!
I recently received an issue from our diligent QA department asking to have a dialog box, which presented Yes/No/Cancel as options, shortened down to just Yes/No
I responded with my reason for the existance of this combination of options:
It is a UI decision. Both Yes and No are definitive answers to a question, however, sometimes a user will interact an application and perform actions that they had no intentions of doing.
Definitive answers like Yes and No imply that you are instructing the application to do something (even if you answer no). Because you answered the question, the application is going to take action accordingly.
The Cancel option gives the user peace-of-mind that, if they just cancel, nothing will happen because they have just instructed the application to "cancel" the previous action all together.
Of course wording the question is crucial here. The question could very well imply that clicking No means that the action will be cancelled. However with a very critical action, a user may feel more at ease indicating to the application to completely disregard the previous action, even if No does mean NO!
Wednesday, August 16, 2006
One of the most useful pieces of code used by the InfoPath Developers here at Visiphor is the SecondaryDataSource Class written by one of our senior developers, Keith Curtis.
This class exposes some simple methods which we use to interact with secondary data sources.
The GetNodeValue and GetValue methods behave more like typical XSLT xsl:value-of calls where xpath queries that result in missing nodes do not cause catastrophic exceptions, but rather return empty strings. Trace messages can be returned if the xpath query does not return a node, but the call will not fail.
We added a winform to the InfoPath form that is called by the query method. The winform displays a progress bar, which runs in a separate thread so while the form is disabled by calls to a datasource/webservice, the progress bar gives the user something to look at. Also, because the winform runs in a separate thread, it displays while the form is initially loading (before the first view is rendered) - NICE!
I'll talk more about the winform and the speed-of-load issues which spawned the need/want of the progress bar in future entries.
If you'd like more info about the class, drop me a line.
Thanks for reading,
Jessel
This class exposes some simple methods which we use to interact with secondary data sources.
- Call the secondary datasource (query()),
- Query data (GetNodeValue(), GetValue())
- Set data (SetNodeValue).
The GetNodeValue and GetValue methods behave more like typical XSLT xsl:value-of calls where xpath queries that result in missing nodes do not cause catastrophic exceptions, but rather return empty strings. Trace messages can be returned if the xpath query does not return a node, but the call will not fail.
We added a winform to the InfoPath form that is called by the query method. The winform displays a progress bar, which runs in a separate thread so while the form is disabled by calls to a datasource/webservice, the progress bar gives the user something to look at. Also, because the winform runs in a separate thread, it displays while the form is initially loading (before the first view is rendered) - NICE!
I'll talk more about the winform and the speed-of-load issues which spawned the need/want of the progress bar in future entries.
If you'd like more info about the class, drop me a line.
Thanks for reading,
Jessel
Sunday, July 23, 2006
It has been (now) 6 days since my first blog entry. A few people have inquired as to when the next entry will be published. Well I haven't formalized the intention of this blog, so let me simply outline the inspiration for it.
As part of the personal brand development at Visiphor, I intend to use this blog to showcase the particular niche I have found myself in and hopefully identify myself as viable resource on the topic(s).
In my time with this group, I have been exposed to a few new technologies (SQL Reporting Services, SQL Notification Services, Microsoft InfoPath). I intend on documenting our experiences and application of (at least) SQL Notification Services and Microsoft InfoPath. I am also very interested in expanding my introduction to K2.NET and its following release "Black Pearl"
The InfoPath form I am currently working is very exciting and full of interesting applications of the technology, which I plan on displaying. I will also provide a few "nice to have" features which we have not implemented and how to implement them.
That's all for now...
Thanks
Jessel Aquing
As part of the personal brand development at Visiphor, I intend to use this blog to showcase the particular niche I have found myself in and hopefully identify myself as viable resource on the topic(s).
In my time with this group, I have been exposed to a few new technologies (SQL Reporting Services, SQL Notification Services, Microsoft InfoPath). I intend on documenting our experiences and application of (at least) SQL Notification Services and Microsoft InfoPath. I am also very interested in expanding my introduction to K2.NET and its following release "Black Pearl"
The InfoPath form I am currently working is very exciting and full of interesting applications of the technology, which I plan on displaying. I will also provide a few "nice to have" features which we have not implemented and how to implement them.
That's all for now...
Thanks
Jessel Aquing
Monday, July 17, 2006
Hello all!
Yes, that does include you.
This constitues my first blog entry - ever. As my first blog entry I choose to focus mainly on the fact that this is my first blog entry. While I have plenty to say, I have never had a problem finding an audience (willing, unwilling, captive or evasive). So this blog will serve as a log of of my adventures in Enterpise Solution Development at Visiphor Consulting Services here in beautiful Vancouver, British Columbia, Canada.
The next entry will document in more detail the intentions of this Blog.
Thanks!
Jessel
Yes, that does include you.
This constitues my first blog entry - ever. As my first blog entry I choose to focus mainly on the fact that this is my first blog entry. While I have plenty to say, I have never had a problem finding an audience (willing, unwilling, captive or evasive). So this blog will serve as a log of of my adventures in Enterpise Solution Development at Visiphor Consulting Services here in beautiful Vancouver, British Columbia, Canada.
The next entry will document in more detail the intentions of this Blog.
Thanks!
Jessel
Subscribe to:
Posts (Atom)