Пример #1
0
        public static ExtensionElement ParseExtensionElement(XMLStreamReader xtr)
        {
            ExtensionElement extensionElement = CreateExtensionElement(xtr);

            bool readyWithExtensionElement = false;

            while (!readyWithExtensionElement && xtr.HasNext())
            {
                //xtr.next();

                if (xtr.NodeType == XmlNodeType.Text || xtr.NodeType == XmlNodeType.CDATA)
                {
                    if (!string.IsNullOrWhiteSpace(xtr.Value?.Trim()))
                    {
                        extensionElement.ElementText = xtr.Value?.Trim();
                    }
                }
                else if (xtr.IsStartElement())
                {
                    if (xtr.IsEmptyElement)
                    {
                        ExtensionElement childExtensionElement = CreateExtensionElement(xtr);
                        extensionElement.AddChildElement(childExtensionElement);
                        xtr.isEmpty = xtr.IsStartElement() && xtr.EndElement;
                        xtr.Next();
                        return(childExtensionElement);
                    }
                    else
                    {
                        ExtensionElement childExtensionElement = ParseExtensionElement(xtr);
                        extensionElement.AddChildElement(childExtensionElement);
                    }
                }
                else if (xtr.EndElement && string.Compare(extensionElement.Name, xtr.LocalName, true) == 0)
                {
                    readyWithExtensionElement = true;
                }

                if (xtr.IsEmptyElement && string.Compare(extensionElement.Name, xtr.LocalName, true) == 0)
                {
                    readyWithExtensionElement = true;
                }
            }
            return(extensionElement);
        }
Пример #2
0
        protected internal virtual ExtensionElement ParseExtensionElement(XMLStreamReader xtr)
        {
            ExtensionElement extensionElement = new ExtensionElement
            {
                Name = xtr.LocalName
            };

            if (!string.IsNullOrWhiteSpace(xtr.NamespaceURI))
            {
                extensionElement.Namespace = xtr.NamespaceURI;
            }
            if (!string.IsNullOrWhiteSpace(xtr.Prefix))
            {
                extensionElement.NamespacePrefix = xtr.Prefix;
            }

            BpmnXMLUtil.AddCustomAttributes(xtr, extensionElement, defaultElementAttributes);

            bool readyWithExtensionElement = false;

            while (!readyWithExtensionElement && xtr.HasNext())
            {
                //xtr.next();

                if (xtr.NodeType == XmlNodeType.CDATA)
                {
                    if (!string.IsNullOrWhiteSpace(xtr.Value?.Trim()))
                    {
                        extensionElement.ElementText = xtr.Value?.Trim();
                    }
                }
                else if (xtr.IsStartElement())
                {
                    ExtensionElement childExtensionElement = ParseExtensionElement(xtr);
                    extensionElement.AddChildElement(childExtensionElement);
                }
                else if (xtr.EndElement && string.Compare(extensionElement.Name, xtr.LocalName, true) == 0)
                {
                    readyWithExtensionElement = true;
                }

                if (xtr.IsEmptyElement && string.Compare(extensionElement.Name, xtr.LocalName, true) == 0)
                {
                    readyWithExtensionElement = true;
                }
            }
            return(extensionElement);
        }