Open darkranjha opened 10 months ago
Here is some additional info after doing some preliminary debugging:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
System.Xml.Linq.XContainer.Element(...) returned null.
code that is getting the error is bolded below (first line under // xs:sequence):
private static (XElement, XElement, string, XElement, List<XElement>) GetTable(XElement elem, string tableParameterName)
{
XNamespace nsXs = "http://www.w3.org/2001/XMLSchema";
XNamespace nsMsdata = "urn:schemas-microsoft-com:xml-msdata";
var el = elem.Element(tableParameterName);
var elel = el.Element(nsXs + "schema").Element(nsXs + "element");
// table name
var rowName = elel.Attribute("name").Value;
if (rowName == "NewDataSet")
{
rowName = elel.Attribute(nsMsdata + "MainDataTable")?.Value;
}
// xs:sequence
### This is the code that it chokes on **_var seq = elel.Element(nsXs + "complexType").Element(nsXs + "choice").Element(nsXs + "element").Element(nsXs + "complexType").Element(nsXs + "sequence");_**
// table, diffgram
XNamespace nsDiffgram = "urn:schemas-microsoft-com:xml-diffgram-v1";
var baseElem = el.Element(nsDiffgram + "diffgram");
return (
baseElem.Element("DocumentElement"),
baseElem.Element(nsDiffgram + "before"),
rowName,
baseElem,
seq.Elements()?.ToList() ?? new List<XElement>()
);
}
Whenever I create actions and run, things work fine. But if I want to change the find element by id to something else and then click save and run, I get an error immediately. Object not set to an instance of an object. If I do the same thing by editing the original xml without using the tool, then the script will load fine.