Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script doesn't open when changing webelement action #304

Open
darkranjha opened this issue Sep 6, 2023 · 1 comment
Open

Script doesn't open when changing webelement action #304

darkranjha opened this issue Sep 6, 2023 · 1 comment

Comments

@darkranjha
Copy link

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.

@darkranjha
Copy link
Author

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>()
        );
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant