Exemple #1
0
        public void LoadXml(XmlElement rootNode, XmlNamespaceManager nsmgr)
        {
            string pr = nsmgr.LookupPrefix(XmlSchemaUtil.WORKFLOW_NAMESPACE);

            pr = (pr != null && pr.Length > 0) ? pr + ":" : "";
            foreach (XmlElement el in rootNode.ChildNodes)
            {
                if (el.LocalName == "struct")
                {
                    StructDef sd = new StructDef();
                    sd.LoadFromXml(el, nsmgr);
                    AddType(sd);
                }
                else if (el.LocalName == "enum")
                {
                    EnumDef ed = new EnumDef();
                    ed.LoadFromXml(el, nsmgr);
                    AddType(ed);
                }
                else
                {
                    throw new Exception("Unexpected node: " + el.Name);
                }
            }
        }
Exemple #2
0
 public override TypeDef CloneTypeDef()
 {
     StructDef sd = new StructDef();
     sd.Name = this.Name;
     foreach (MemberDef md in Members)
     {
         sd.Members.Add(md.CloneMemberDef());
     }
     return sd;
 }
Exemple #3
0
        public override TypeDef CloneTypeDef()
        {
            StructDef sd = new StructDef();

            sd.Name = this.Name;
            foreach (MemberDef md in Members)
            {
                sd.Members.Add(md.CloneMemberDef());
            }
            return(sd);
        }
Exemple #4
0
        /// <summary>
        /// Return complete xml data schema for given structDef as a root element
        /// </summary>
        /// <param name="rootElement"></param>
        /// <param name="rootElementName"></param>
        /// <param name="inputNamespace"></param>
        /// <returns></returns>
        public string GetDataSchema(StructDef rootElement, string rootElementName, string inputNamespace)
        {
            StringBuilder     sb = new StringBuilder();
            XmlWriterSettings ws = new XmlWriterSettings();

            ws.OmitXmlDeclaration = true; ws.Indent = true;
            XmlWriter xw = XmlWriter.Create(sb, ws);

            xw.WriteStartDocument();
            WriteXmlSchemaForStruct(rootElement, rootElementName, inputNamespace, xw);
            xw.WriteEndDocument();
            xw.Flush();
            return(sb.ToString());
        }
Exemple #5
0
        private void ImportStruct(StructDef sd)
        {
            foreach (MemberDef md in sd.Members)
            {
                if (!IsTypeDefined(md.TypeName))
                {
                    TypeDef td = sd.ParentTypeSet.GetTypeDef(md.TypeName);
                    if (td == null)
                    {
                        throw new Exception("Undefined type: " + td.Name);
                    }
                    ImportType(td);
                }
            }
            StructDef newStruct = (StructDef)sd.CloneTypeDef();

            AddType(newStruct);
        }
Exemple #6
0
        /// <summary>
        /// Write complete XML schema
        /// </summary>
        /// <param name="rootElement"></param>
        /// <param name="rootElementName"></param>
        /// <param name="inputDataNamespace"></param>
        /// <param name="xw"></param>
        public void WriteXmlSchemaForStruct(StructDef rootElement, string rootElementName, string inputDataNamespace, XmlWriter xw)
        {
            xw.WriteStartElement("xs", "schema", XmlSchemaUtil.SCHEMA_NS);
            if (inputDataNamespace != null && inputDataNamespace.Length > 0)
            {
                xw.WriteAttributeString("xmlns", inputDataNamespace);
            }

            WriteXmlSchema(xw);
            if (rootElement != null)
            {
                xw.WriteStartElement("element", XmlSchemaUtil.SCHEMA_NS);
                xw.WriteAttributeString("name", rootElementName);
                rootElement.WriteXmlSchemaType(xw);
                xw.WriteEndElement();
                xw.WriteEndElement();
            }
        }
Exemple #7
0
 private void ValidateTypeDef(TypeDef td, ValidationCtx ctx)
 {
     if (IsTypeDefined(td.Name))
     {
         return;
     }
     if (ctx.ValidatedTypes.ContainsKey(td.Name))
     {
         return;
     }
     ctx.ValidatedTypes.Add(td.Name, td);
     if (td is SimpleTypeDef)
     {
         return;
     }
     else if (td is StructDef)
     {
         StructDef sd = (StructDef)td;
         foreach (MemberDef md in sd.Members)
         {
             if (!IsTypeDefined(md.TypeName))
             {
                 if (!ctx.NewTypes.ContainsKey(md.TypeName))
                 {
                     throw new ApplicationException(string.Format("Member type ({0}) not defined for {1}.{2}", md.TypeName, sd.Name, md.Name));
                 }
                 TypeDef td2 = ctx.NewTypes[md.TypeName];
                 ValidateTypeDef(td2, ctx);
             }
         }
     }
     else if (td is EnumDef)
     {
         EnumDef ed = (EnumDef)td;
     }
     else
     {
         throw new Exception();
     }
 }
Exemple #8
0
 /// <summary>
 /// Get task input data definition
 /// </summary>
 /// <returns></returns>
 public virtual StructDef GetInputDataSchema()
 {
     if (ParentProcess == null) throw new Exception();
     StructDef sd = new StructDef();
     sd.ParentTypeSet = ParentProcess.DataTypes;
     foreach (VariableDef vd in Variables)
     {
         if (vd.VariableDir == VariableDef.Dir.In || vd.VariableDir == VariableDef.Dir.InOut)
         {
             sd.Members.Add(vd);
         }
     }
     return sd;
 }
Exemple #9
0
 /// <summary>
 /// Get the definition of internal task data structure (all variables)
 /// Warning: there are no required fields in the internal data schema. So any variable, even the required ones, can be skipped
 /// in an xml document.
 /// </summary>
 /// <returns></returns>
 public virtual StructDef GetInternalDataSchema()
 {
     if (ParentProcess == null) throw new Exception();
     StructDef sd = new StructDef();
     sd.ParentTypeSet = ParentProcess.DataTypes;
     foreach (VariableDef vd in Variables)
     {
         VariableDef vd2 = new VariableDef(vd); vd2.IsRequired = false;
         sd.Members.Add(vd2);
     }
     return sd;
 }
Exemple #10
0
 public static void Validate(IDictionary<string, object> data, StructDef recType)
 {
 }
Exemple #11
0
 public void LoadXml(XmlElement rootNode, XmlNamespaceManager nsmgr)
 {
     string pr = nsmgr.LookupPrefix(XmlSchemaUtil.WORKFLOW_NAMESPACE);
     pr = (pr != null && pr.Length > 0) ? pr + ":" : "";
     foreach (XmlElement el in rootNode.ChildNodes)
     {
         if (el.LocalName == "struct")
         {
             StructDef sd = new StructDef();
             sd.LoadFromXml(el, nsmgr);
             AddType(sd);
         }
         else if (el.LocalName == "enum")
         {
             EnumDef ed = new EnumDef();
             ed.LoadFromXml(el, nsmgr);
             AddType(ed);
         }
         else throw new Exception("Unexpected node: " + el.Name);
     }
 }
Exemple #12
0
 private void ImportStruct(StructDef sd)
 {
     foreach (MemberDef md in sd.Members)
     {
         if (!IsTypeDefined(md.TypeName))
         {
             TypeDef td = sd.ParentTypeSet.GetTypeDef(md.TypeName);
             if (td == null) throw new Exception("Undefined type: " + td.Name);
             ImportType(td);
         }
     }
     StructDef newStruct = (StructDef) sd.CloneTypeDef();
     AddType(newStruct);
 }
Exemple #13
0
        /// <summary>
        /// Write complete XML schema 
        /// </summary>
        /// <param name="rootElement"></param>
        /// <param name="rootElementName"></param>
        /// <param name="inputDataNamespace"></param>
        /// <param name="xw"></param>
        public void WriteXmlSchemaForStruct(StructDef rootElement, string rootElementName, string inputDataNamespace, XmlWriter xw)
        {
            xw.WriteStartElement("xs", "schema", XmlSchemaUtil.SCHEMA_NS);
            if (inputDataNamespace != null && inputDataNamespace.Length > 0)
            {
                xw.WriteAttributeString("xmlns", inputDataNamespace);
            }

            WriteXmlSchema(xw);
            if (rootElement != null)
            {
                xw.WriteStartElement("element", XmlSchemaUtil.SCHEMA_NS);
                xw.WriteAttributeString("name", rootElementName);
                rootElement.WriteXmlSchemaType(xw);
                xw.WriteEndElement();
                xw.WriteEndElement();
            }
        }
Exemple #14
0
 /// <summary>
 /// Return complete xml data schema for given structDef as a root element
 /// </summary>
 /// <param name="rootElement"></param>
 /// <param name="rootElementName"></param>
 /// <param name="inputNamespace"></param>
 /// <returns></returns>
 public string GetDataSchema(StructDef rootElement, string rootElementName, string inputNamespace)
 {
     StringBuilder sb = new StringBuilder();
     XmlWriterSettings ws = new XmlWriterSettings();
     ws.OmitXmlDeclaration = true; ws.Indent = true;
     XmlWriter xw = XmlWriter.Create(sb, ws);
     xw.WriteStartDocument();
     WriteXmlSchemaForStruct(rootElement, rootElementName, inputNamespace, xw);
     xw.WriteEndDocument();
     xw.Flush();
     return sb.ToString();
 }
Exemple #15
0
 public static void Validate(IDictionary <string, object> data, StructDef recType)
 {
 }