private string Demote(string original, XPathExpression expr) { if (expr != null) { SchemaMetaDataProperty metaDataProperty = m_schemaMetaData.Properties[expr.XPath]; var ret_value = m_context.Read(metaDataProperty.Name, metaDataProperty.Namespace); if (ret_value != null) return (string)ret_value; } return original; }
private static SchemaMetaData CreateSchemaMetaData(XmlSchema xmlSchema, Schema Schema) { SchemaMetaData _propSchema = null; if (xmlSchema != null) { _propSchema = new SchemaMetaData(); _propSchema.FullName = Schema.AssemblyQualifiedName; XmlQualifiedName[] namespaces = xmlSchema.Namespaces.ToArray(); IEnumerator enumerator = (IEnumerator)xmlSchema.Items.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Current is XmlSchemaElement) { XmlSchemaElement elm = (XmlSchemaElement)enumerator.Current; if (elm.Name != Schema.RootName) { continue; } XmlNode appInfo = GetAppInfoXmlNode(elm); if (appInfo == null) { return((SchemaMetaData)null); } foreach (XmlNode property in appInfo.ChildNodes) { XmlNode name = property.Attributes.GetNamedItem("name"); XmlNode xpath = property.Attributes.GetNamedItem("xpath"); string[] _name = name.InnerText.Split(new char[] { ':' }); for (int i = 0; i < namespaces.Length; i++) { XmlQualifiedName qn = namespaces[i]; if (qn.Name == _name[0]) { if (_propSchema.Properties.ContainsKey(xpath.InnerText) == false) { SchemaMetaDataProperty dataProperty = new SchemaMetaDataProperty(); dataProperty.Name = _name[1]; dataProperty.Namespace = qn.Namespace; _propSchema.Properties.Add(xpath.InnerText, dataProperty); } break; } } } } } } return(_propSchema); }