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)
Subscribe to:
Posts (Atom)