Esempio n. 1
0
        public override void startElement(System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
        {
            xpath.push(local);
            //if (debug)
            //    logger.debug("<", raw, "> -> ", xpath);
            // Detect CML modules, like CRML and CCML
            if (local.StartsWith("reaction"))
            {
                // e.g. reactionList, reaction -> CRML module
                //logger.info("Detected CRML module");
                conv = new CMLReactionModule(conv);
                conventionStack.push(conventionStack.current());
            }
            else
            {
                // assume CML Core

                // Detect conventions
                System.String convName = "";
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if (atts.GetFullName(i).Equals("convention"))
                    {
                        convName = atts.GetValue(i);
                    }
                }
                if (convName.Length > 0)
                {
                    if (convName.Equals(conventionStack.current()))
                    {
                        //logger.debug("Same convention as parent");
                    }
                    else
                    {
                        //logger.info("New Convention: ", convName);
                        if (convName.Equals("CML"))
                        {
                            /* Don't reset the convention handler to CMLCore,
                             * becuase all handlers should extend this handler,
                             * and use it for any content other then specifically
                             * put into the specific convention */
                        }
                        else if (convName.Equals("PDB"))
                        {
                            conv = new PDBConvention(conv);
                        }
                        else if (convName.Equals("PMP"))
                        {
                            conv = new PMPConvention(conv);
                        }
                        else if (convName.Equals("MDLMol"))
                        {
                            //if (debug)
                            //    logger.debug("MDLMolConvention instantiated...");
                            conv = new MDLMolConvention(conv);
                        }
                        else if (convName.Equals("JMOL-ANIMATION"))
                        {
                            conv = new JMOLANIMATIONConvention(conv);
                        }
                        else if (userConventions.ContainsKey(convName))
                        {
                            //unknown convention. userConvention?
                            ICMLConvention newconv = (ICMLConvention)userConventions[convName];
                            newconv.inherit(conv);
                            conv = newconv;
                        }
                        else
                        {
                            //logger.warn("Detected unknown convention: ", convName);
                        }
                    }
                    conventionStack.push(convName);
                }
                else
                {
                    // no convention set/reset: take convention of parent
                    conventionStack.push(conventionStack.current());
                }
            }
            //if (debug)
            //    logger.debug("ConventionStack: ", conventionStack);
            conv.startElement(xpath, uri, local, raw, atts);
        }
Esempio n. 2
0
 public override void startDocument()
 {
     conv.startDocument();
     conventionStack.push("CML");
 }