This class exists as a common place for putting static methods for the Sfm2Xml namespace.
コード例 #1
0
        /// <summary>
        /// Read a 'Field' node from the controled xml file that contains the ImportFields
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public bool ReadNode(System.Xml.XmlNode node)
        {
            bool success = true;

            m_node = node;
            foreach (System.Xml.XmlAttribute Attribute in node.Attributes)
            {
                switch (Attribute.Name)
                {
                case "id":
                    m_name = ReadRequiredString(Attribute.Value, ref success);
                    break;

                case "uiname":
                    m_uiName = ReadRequiredString(Attribute.Value, ref success);
                    break;

                case "property":
                    m_property = ReadRequiredString(Attribute.Value, ref success);
                    break;

                case "signature":
                    m_signature = ReadRequiredString(Attribute.Value, ref success);
                    break;

                case "list":
                    m_isList = ReadBoolValue(Attribute.Value, false);
                    break;

                case "multi":
                    m_isMulti = ReadBoolValue(Attribute.Value, false);
                    break;

                case "ref":
                    m_isRef = ReadBoolValue(Attribute.Value, false);
                    break;

                case "autofield":
                    m_isAutoField = ReadBoolValue(Attribute.Value, false);
                    break;

                case "type":
                    m_dataType = ReadRequiredString(Attribute.Value, ref success);
                    break;

                case "unique":
                    m_isUnique = ReadBoolValue(Attribute.Value, false);
                    break;

                case "MDF":
                    STATICS.SplitString(Attribute.Value, ref m_mdfMarkers);
                    break;

                default:
                    break;
                }
            }
            return(success);
        }
コード例 #2
0
        public bool ReadXmlNode(XmlNode optDef)
        {
            bool success = true;

            foreach (XmlAttribute Attribute in optDef.Attributes)
            {
                switch (Attribute.Name)
                {
                case "id":
                    if (Attribute.Value == "")
                    {
                        success = false;
                    }
                    else
                    {
                        m_id = Attribute.Value;
                    }
                    break;

                case "type":
                    if (Attribute.Value == "")
                    {
                        success = false;
                    }
                    else
                    {
                        m_type = Attribute.Value;
                    }
                    break;

                case "checked":
                    if (Attribute.Value == "")
                    {
                        success = false;
                    }
                    else
                    {
                        m_isChecked = STATICS.IsBoolString(Attribute.Value, false);
                    }
                    break;

                default:
                    Converter.Log.AddWarning(String.Format(Sfm2XmlStrings.UnknownAttribute0InTheOptions, Attribute.Name));
                    break;
                }
            }

            if (!string.IsNullOrEmpty(Id))
            {
                return(success);
            }

            Converter.Log.AddError(Sfm2XmlStrings.IdNotDefinedInAnOption);
            return(false);
        }
コード例 #3
0
        new public bool ReadXmlNode(System.Xml.XmlNode customfieldNode, Hashtable languages, string topAnalysisWS)
        {
            // Iterate through all the attributes of the "field" sub-element of this custom field:
            System.Xml.XmlNode fieldNode = customfieldNode.SelectSingleNode("field");
            if (fieldNode == null)
            {
                Converter.Log.AddError(String.Format(Sfm2XmlStrings.NoFieldNodeInTheCustomField, m_Sfm));
                return(false);
            }
            else
            {
                if (!base.ReadXmlNode(fieldNode, languages, "en"))
                {
                    return(false);
                }
            }

            foreach (System.Xml.XmlAttribute Attribute in customfieldNode.Attributes)
            {
                // Create new attribute details, which may be altered later on:
                string NewName  = Attribute.Name;
                string NewValue = Attribute.Value;
                switch (Attribute.Name)
                {
//					case "guid":
//						m_guid = Attribute.Value;
//						break;
                case "wsSelector":
                    m_wsSelector = Convert.ToInt32(Attribute.Value);
                    break;

                case "big":
                    m_big = STATICS.IsBoolString(Attribute.Value, false);
                    break;

                case "flid":
                    m_flid = Convert.ToInt32(Attribute.Value);
                    break;

                case "class":
                    m_class = NewValue;
                    break;

                case "uiclass":
                    m_uiClass = NewValue;
                    break;

                default:
                    throw new Exception("Invalid attribute on Custom Field Element.");
                }
            }

            return(true);
        }
コード例 #4
0
        private bool ReadSignatureNode(System.Xml.XmlNode node)
        {
            System.Xml.XmlAttribute nameAttr = node.Attributes["names"];
            if (nameAttr == null)
            {
                return(false);
            }
            string sigNames = nameAttr.Value;

            string [] sigs = STATICS.SplitString(sigNames);
            m_AbbrSignatures = new List <string>(sigs);
            return(true);
        }
コード例 #5
0
 public LexImportField(string name, string uiDest, string prop, string sig, bool list, bool multi, bool unique, string mdf)
 {
     m_name       = name;
     m_uiName     = uiDest;
     m_property   = prop;
     m_dataType   = "string";            // default if not given
     m_signature  = sig;
     m_isList     = list;
     m_isMulti    = multi;
     m_isUnique   = unique;
     m_mdfMarkers = new Hashtable();
     STATICS.SplitString(mdf, ref m_mdfMarkers);
 }
コード例 #6
0
 public ClsInFieldMarker(string begin, string endList,
                         bool fEndWithWord, bool fEndWithField, string lang, string xmlLang, string style, bool ignore)
 {
     m_EndList = new ArrayList();
     m_Begin   = begin;
     // change from a delimited string to an arraylist
     STATICS.SplitString(endList, delim, ref m_EndList);
     m_fEndWithWord    = fEndWithWord;
     m_fEndWithField   = fEndWithField;
     m_Language        = lang;
     m_xmlLang         = xmlLang;        // string to use for the ws (writing System)
     m_style           = style;
     m_ignore          = ignore;
     m_UseXmlLangValue = false;
 }
コード例 #7
0
        public bool ReadXmlNode(System.Xml.XmlNode node, Hashtable languages)
        {
            bool Success = true;

            m_fEndWithField = false;
            m_fEndWithWord  = false;
            foreach (System.Xml.XmlAttribute Attribute in node.Attributes)
            {
                // Create new attribute details, which may be altered later on:
                string newValue = Attribute.Value;
                switch (Attribute.Name)
                {
                case "element":
                    m_XmlElementName = Attribute.Value;
                    break;

                case "begin":
                    m_Begin = Attribute.Value;
                    break;

                case "end":
                case "endList":
                    STATICS.SplitString(newValue, delim, ref m_EndList);
                    break;

                case "endWithField":
                    m_fEndWithField = IsTrue(Attribute.Value);
                    break;

                case "endWithWord":
                    m_fEndWithWord = IsTrue(Attribute.Value);
                    break;

                /*
                 * case "lang":
                 * // Look up replacement language name:
                 * ClsLanguage language = languages[Attribute.Value] as ClsLanguage;
                 * if (language == null)
                 * {
                 *      Converter.Log.AddError("Error in Mapping File: Unknown 'lang' value '" + Attribute.Value + "' in the 'fieldDescriptions' section.");
                 *      m_xmlLanguage = newValue;
                 * }
                 * else
                 *      m_xmlLanguage = language.XmlLang;
                 *
                 * m_Language = newValue;
                 * break;
                 * */
                case "lang":
                    newValue = null;
                    // Look up replacement language name:
                    ClsLanguage language = languages[Attribute.Value] as ClsLanguage;
                    if (language != null)
                    {
                        newValue   = language.XmlLang;
                        m_Language = language.KEY;
                        m_xmlLang  = language.XmlLang;
                    }
                    else
                    {
                        Converter.Log.AddError(String.Format(Sfm2XmlStrings.UnknownLangValue0InTheInFieldMarkers, Attribute.Value));
                        newValue = Attribute.Value;
                    }
                    break;

                case "style":
                    m_style = Attribute.Value;
                    break;

                case "ignore":
                    m_ignore = STATICS.IsBoolString(Attribute.Value, false);
                    break;

                default:
                    Converter.Log.AddWarning(String.Format(Sfm2XmlStrings.UnknownAttribute0InTheInFieldMarkers, Attribute.Name));
                    Success = false;
                    break;
                }
            }

            if (m_Begin == null)
            {
                Converter.Log.AddError(Sfm2XmlStrings.BeginNotDefinedInAnInFieldMarker);
                Success = false;
            }
            if (m_EndList.Count == 0 && !m_fEndWithWord && !m_fEndWithField)
            {
                Converter.Log.AddError(String.Format(Sfm2XmlStrings.InFieldMarker0HasNoEndAttribute, m_Begin));
                Success = false;
            }
            if (m_XmlElementName == null)
            {
                Converter.Log.AddError(String.Format(Sfm2XmlStrings.InFieldMarker0HasNoElementNameAttribute, m_Begin));
                Success = false;
            }

            return(Success);
        }
コード例 #8
0
        public bool ReadXmlNode(System.Xml.XmlNode fieldNode, Hashtable languages, string topAnalysisWS)
        {
            m_OtherAttributes = "";
////			string allAttributes = "<field ";

            foreach (System.Xml.XmlAttribute Attribute in fieldNode.Attributes)
            {
                // Create new attribute details, which may be altered later on:
                string NewName  = Attribute.Name;
                string NewValue = Attribute.Value;
                switch (Attribute.Name)
                {
                case "sfm":
                    m_Sfm = Attribute.Value;
                    break;

                case "name":
                    m_Name = Attribute.Value;
                    break;

                case "type":
                    m_Type = Attribute.Value;
                    break;

                case "lang":
////						NewName = "xml:lang";
////						NewValue = Attribute.Value;
                    // Look up replacement language name:
                    ClsLanguage language = languages[Attribute.Value] as ClsLanguage;
                    if (language == null)
                    {
                        Converter.Log.AddError(String.Format(Sfm2XmlStrings.UnknownLangValue0InFieldDescs, Attribute.Value));
                        m_xmlLanguage = NewValue;
                    }
                    else
                    {
                        m_xmlLanguage = language.XmlLang;
                    }

                    m_Language = NewValue;
                    break;

                case "abbr":
                    IsAbbr = STATICS.IsBoolString(Attribute.Value, true);
                    break;

                case "exclude":
                    IsExcluded = STATICS.IsBoolString(Attribute.Value, false);
                    break;

                case "autoImport":
                    IsAutoImportField = STATICS.IsBoolString(Attribute.Value, false);
                    break;

                case "autoSfm":                         // just ignore for now and re-assign
                    break;

                default:
                    m_OtherAttributes += " " + NewName + "=\"" + NewValue + "\"";
                    break;
                }
////				allAttributes += " " + NewName + "=\"" + NewValue + "\"";
            }

////			allAttributes += ">";

            // Iterate through all the attributes of the "meaning" sub-element of this field:
            System.Xml.XmlNode Meaning = fieldNode.SelectSingleNode("meaning");
            if (Meaning == null)
            {
                Converter.Log.AddError(String.Format(Sfm2XmlStrings.MissingMeaningElementInField0InFieldDescs, m_Sfm));
            }
            else
            {
                m_Meaning = "<meaning ";

                foreach (System.Xml.XmlAttribute Attribute in Meaning.Attributes)
                {
                    m_Meaning += Attribute.Name + "=\"" + Attribute.Value + "\" ";
                    if (Attribute.Name == "app")
                    {
                        m_meaningApp = Attribute.Value;
                    }
                    else if (Attribute.Name == "id")
                    {
                        m_meaningId = MakeValidFwId(Attribute.Value);
                    }
                    else if (Attribute.Name == "func")
                    {
                        m_RefFunc = Attribute.Value;
                    }
                    else if (Attribute.Name == "funcWS")
                    {
                        m_RefFuncWS = Attribute.Value;
                    }
                }
                m_Meaning += " />";

                RebuildMeaningEntry(null, topAnalysisWS);
            }

//			xmlOutput.WriteRaw(System.Environment.NewLine + "</field>" + System.Environment.NewLine);

            SetAutoSfm();
            if (m_Sfm == null)
            {
                Converter.Log.AddError(Sfm2XmlStrings.FieldDefinedWithNoSfmAttributeInTheFieldDescs);
            }
            else if (m_Language == null)
            {
                Converter.Log.AddError(String.Format(Sfm2XmlStrings.FieldDescWithSFMOf0HasNoLangAttribute, m_Sfm));
            }
            if (m_Type == null)
            {
                Converter.Log.AddWarning(String.Format(Sfm2XmlStrings.FieldDescWithSFMOf0HasNoTypeAttribute, m_Sfm));
            }
            else
            {
                return(true);
            }

            return(false);
        }