The problem is with the Empty-Null cases in the xpath expressions.
Is it possible to separate all these cases in Expression shapes of the Orchestration xpath?
For example, we have the record with <name> element, in such flavors:
case: "NonEmpty"
<ns0:People>
<ns0:Name>Name_0</ns0:Name>
<ns0:IsDependent>IsDependent_0</ns0:IsDependent>
..
case: "Empty"
<ns0:People>
<ns0:Name></ns0:Name>
<ns0:IsDependent>IsDependent_0</ns0:IsDependent>
..
case: "OneTag"
<ns0:People>
<ns0:Name/>
<ns0:IsDependent>IsDependent_0</ns0:IsDependent>
..
case: "Null"
<ns0:People>
<!-- NO NODE: <ns0:Name>Name_0</ns0:Name>-->
<ns0:IsDependent>IsDependent_0</ns0:IsDependent>
..
I tried to use the xpath() function in two variants, one with "string(xpath_expression)" second with "xpath_expression"
Expression Shape:
[
System.Diagnostics.Trace.WriteLine("== with string() ====================================================================");
var_xpathString = "string(/*[local-name()='Root' and namespace-uri()='http://MapTest.IncPerson']/*[local-name()='People' and namespace-uri()='http://MapTest.IncPerson']/*[local-name()='Name' and namespace-uri()='http://MapTest.IncPerson'])";
System.Diagnostics.Trace.WriteLine("[" + System.Convert.ToString(xpath (msg_SourceRoot, var_xpathString)) + "]");
if ( xpath (msg_SourceRoot, var_xpathString) == null)
{ System.Diagnostics.Trace.WriteLine("Name == null"); }
else if ( xpath (msg_SourceRoot, var_xpathString) == "")
{ System.Diagnostics.Trace.WriteLine("Name == Empty");}
else
{ System.Diagnostics.Trace.WriteLine("Name != null && Name != Empty"); }
System.Diagnostics.Trace.WriteLine("-- no string() --------------------------------------------------------------------");
var_xpathString = "/*[local-name()='Root' and namespace-uri()='http://MapTest.IncPerson']/*[local-name()='People' and namespace-uri()='http://MapTest.IncPerson']/*[local-name()='Name' and namespace-uri()='http://MapTest.IncPerson']";
System.Diagnostics.Trace.WriteLine("[" + System.Convert.ToString(xpath (msg_SourceRoot, var_xpathString)) + "]");
if ( xpath (msg_SourceRoot, var_xpathString) == null)
{ System.Diagnostics.Trace.WriteLine("Name == null"); }
else if ( xpath (msg_SourceRoot, var_xpathString) == "")
{ System.Diagnostics.Trace.WriteLine("Name == Empty"); }
else
{ System.Diagnostics.Trace.WriteLine("Name != null && Name != Empty");}
]
I.e. the "string(xpath_expression)" expression is used in the firs section, the"xpath_expression" is used in the second.
Result is:
"NonEmpty" == with string() ====================================================================
[Name_0]
Name != null && Name != Empty
-- no string() --------------------------------------------------------------------
[Microsoft.XLANGs.Core.Part+ArrayBasedXmlNodeList]
Name != null && Name != Empty
"Empty"== with string() ====================================================================
[]
Name == Empty
-- no string() --------------------------------------------------------------------
[Microsoft.XLANGs.Core.Part+ArrayBasedXmlNodeList]
Name != null && Name != Empty
"OneTag"== with string() ====================================================================
[]
Name == Empty
-- no string() --------------------------------------------------------------------
[Microsoft.XLANGs.Core.Part+ArrayBasedXmlNodeList]
Name != null && Name != Empty
"Null"== with string() ====================================================================
[]
Name == Empty
-- no string() --------------------------------------------------------------------
[]
Name == null
Conclusion:
* I cannot separate the cases "Empty" and "OneTag"
* I can separate the cases "Empty and "Null" with "xpath_expression", not with "string(xpath_expression)" expression
* "Null" case does not throw an exception.
* xpath expression inside string() works fine to get all three cases ("Empty", "OneTag", "Null") under one "if" statement. And here it returns only "" (Empty string).
Print | posted on Tuesday, November 17, 2009 3:55 PM