Ejemplo n.º 1
0
        private T CreateAndAppend <T>(
            FObj parent,
            FObj.Maker <T> maker,
            string uri,
            string localName,
            Attributes attlist)
            where T : FObj
        {
            PropertyListBuilder currentListBuilder =
                (PropertyListBuilder)this.propertylistTable[uri];
            PropertyList list = null;

            if (currentListBuilder != null)
            {
                list = currentListBuilder.MakeList(uri, localName, attlist, currentFObj);
            }
            T result = maker.Make(parent, list);

            if (parent != null)
            {
                parent.AddChild(result);
            }
            return(result);
        }
Ejemplo n.º 2
0
        private void StartElement(
            string uri,
            string localName,
            Attributes attlist)
        {
            FObj fobj;

            FObj.Maker fobjMaker = GetFObjMaker(uri, localName);

            PropertyListBuilder currentListBuilder =
                (PropertyListBuilder)this.propertylistTable[uri];

            bool foreignXML = false;

            if (fobjMaker == null)
            {
                string fullName = uri + "^" + localName;
                if (!this.unknownFOs.ContainsKey(fullName))
                {
                    this.unknownFOs.Add(fullName, "");
                    FonetDriver.ActiveDriver.FireFonetError("Unknown formatting object " + fullName);
                }
                if (namespaces.Contains(String.Intern(uri)))
                {
                    fobjMaker = new Unknown.Maker();
                }
                else
                {
                    fobjMaker  = new UnknownXMLObj.Maker(uri, localName);
                    foreignXML = true;
                }
            }

            PropertyList list = null;

            if (currentListBuilder != null)
            {
                list = currentListBuilder.MakeList(uri, localName, attlist, currentFObj);
            }
            else if (foreignXML)
            {
                list = null;
            }
            else
            {
                if (currentFObj == null)
                {
                    throw new FonetException("Invalid XML or missing namespace");
                }
                list = currentFObj.properties;
            }
            fobj = fobjMaker.Make(currentFObj, list);

            if (rootFObj == null)
            {
                rootFObj = fobj;
                if (!fobj.GetName().Equals("fo:root"))
                {
                    throw new FonetException("Root element must" + " be root, not " + fobj.GetName());
                }
            }
            else if (!(fobj is PageSequence))
            {
                currentFObj.AddChild(fobj);
            }

            currentFObj = fobj;
        }