Пример #1
0
        /// <summary>
        /// Returns the list of all elements mentioned in the Children
        /// </summary>
        private IEnumerable <string> GetDtdElementNamesFromChildElements(DtdChildElements children)
        {
            switch (children.ElementType)
            {
            case DtdChildElements.DtdChildElementTypes.SingleChild:
                // is a single ChildElement
                yield return(children.ElementName);

                break;

            case DtdChildElements.DtdChildElementTypes.ChildList:
                for (int i = 0; i < children.ChildrenCount; i++)
                {
                    foreach (string childElementName in this.GetDtdElementNamesFromChildElements(children.Child(i)))
                    {
                        yield return(childElementName);
                    }
                }
                break;

            case DtdChildElements.DtdChildElementTypes.Empty:
                break;

            default:
                throw new ApplicationException($"unknown DTDChildElementType {children.ElementType}");
            }

            yield return("#COMMENT");     //Add the comment tag, as this is always allowed
        }
        /// <summary>
        /// Lines up a child element in the list
        /// </summary>
        private void SaveChildElement(string code)
        {
            code = code.Trim();
            var child = new DtdChildElements(code); // Create new child or child list from the code

            //if (child.Art ==DTDChildElementArten.EinzelChild)
            //{
            //	Trace.WriteLine(code + child._defAnzahl.ToString());
            //}
            this.children.Add(child); // Save child to list
        }
Пример #3
0
        /// <summary>
        /// Searches the child block for new elements
        /// </summary>
        private void Search(DtdChildElements childBlock)
        {
            switch (childBlock.ElementType)
            {
            case DtdChildElements.DtdChildElementTypes.Empty:
                break;

            case DtdChildElements.DtdChildElementTypes.SingleChild:
                if (!Elements.Contains(childBlock.ElementName))
                {
                    Elements.Add(childBlock.ElementName);
                }
                break;

            case DtdChildElements.DtdChildElementTypes.ChildList:
                for (int iChild = 0; iChild < childBlock.ChildrenCount; iChild++)
                {
                    this.Search(childBlock.Child(iChild));
                }
                break;
            }
        }
Пример #4
0
 public AllPossibleElementsOfAChildBlock(DtdChildElements childBlock)
 {
     this.Elements = new HashSet <string>();
     this.Search(childBlock);
 }