private static XmlFormatter GetFormatter(MemberInfo member) { if (member.DataType.Formatter != null) return (XmlFormatter) member.DataType.Formatter; else return (XmlFormatter) Xs.AnySimpleTypeFormatter; }
public XmlNode CreateElement(MemberInfo member) { XmlDocument doc = node.OwnerDocument; if (doc == null) doc = (XmlDocument) node; XmlNode child = doc.CreateElement(member.LocalName, member.NamespaceURI); node.AppendChild(child); return child; }
public int CountElement(MemberInfo member) { int count = 0; for (XmlNode child=node.FirstChild; child != null; child = child.NextSibling) { if (MemberEqualsNode(member, child)) ++count; } return count; }
public static int GetEnumerationIndex(MemberInfo member, string sValue, int enumOffset, int enumCount) { for( int i = enumOffset; i < (enumOffset + enumCount); i++) { if( member.DataType.facets[i].facetName == "enumeration" && member.DataType.facets[i].stringValue == sValue) return i - enumOffset; } return -1; }
public XmlNode GetElementAt(MemberInfo member, int index) { for (XmlNode child = node.FirstChild; child != null; child = child.NextSibling) { if (MemberEqualsNode(member, child)) { if (index-- == 0) return child; } } return null; }
public XmlNode GetAttribute(MemberInfo member) { XmlElement element = (XmlElement) node; if (member.LocalName == "") { for (XmlNode child = element.FirstChild; child != null; child = child.NextSibling) { if (child.NodeType == XmlNodeType.Text || child.NodeType == XmlNodeType.CDATA) return child; } return null; } else return element.GetAttributeNode(member.LocalName, member.NamespaceURI); }
public static XmlNode AddElement( XmlNode node, MemberInfo member) { string prefix = ""; if( member.NamespaceURI != null ) { prefix = FindPrefixForNamespace(node, member.NamespaceURI ); if( prefix.Length > 0 ) prefix += ":"; } XmlDocument doc = node.OwnerDocument; if (doc == null) doc = (XmlDocument)node; XmlNode newNode = doc.CreateElement(prefix + member.LocalName, member.NamespaceURI); node.AppendChild(newNode); return newNode; }
public void RemoveAttribute(MemberInfo member) { XmlElement element = (XmlElement) node; if (member.LocalName == "") { for (XmlNode child = element.FirstChild; child != null;) { XmlNode keep = child; child = child.NextSibling; if (keep.NodeType == XmlNodeType.Text || keep.NodeType == XmlNodeType.CDATA) element.RemoveChild(keep); } } else { element.RemoveAttribute(member.LocalName, member.NamespaceURI); } }
public XmlNode CreateAttribute(MemberInfo member) { XmlElement element = (XmlElement) node; if (member.LocalName == "") { XmlNode existing = GetAttribute(member); if (existing == null) { XmlText text = element.OwnerDocument.CreateTextNode(""); element.AppendChild(text); return text; } return existing; } else { XmlAttribute att = element.OwnerDocument.CreateAttribute(member.LocalName, member.NamespaceURI); element.SetAttributeNode(att); return att; } }
public static string CastToString( XmlNode node, MemberInfo member) { return Altova.CoreTypes.CastToString(node.InnerText); }
public static Altova.Types.QName CastToQName(XmlNode node, MemberInfo member) { int i = node.InnerText.IndexOf(":"); if (i == -1) return new Altova.Types.QName(node.GetNamespaceOfPrefix(""), node.InnerText); string prefix = node.InnerText.Substring(0, i); string local = node.InnerText.Substring(i + 1); string uri = node.GetNamespaceOfPrefix(prefix); return new Altova.Types.QName(uri, prefix, local); }
public static int CastToInt( XmlNode node, MemberInfo member) { return Altova.CoreTypes.CastToInt(node.InnerText); }
public Attribute(Altova.TypeInfo.MemberInfo info) { this.memberInfo = info; }
public Enumerator(AllIterator list, MemberInfo info) { this.iterator = list.GetEnumerator(); this.info = info; }
public static void SetValue(XmlNode node, MemberInfo member, Altova.Types.QName qn) { if (qn.Uri == null) { SetValue(node, member, qn.LocalName); return; } string prefix = node.GetPrefixOfNamespace(qn.Uri); if (prefix == null || prefix.Length == 0) { prefix = FindUnusedPrefix(node, qn.Prefix); ((XmlElement)node).SetAttribute("xmlns:" + prefix, qn.Uri); } SetValue(node, member, prefix + ":" + qn.LocalName); }
public static void SetValue(XmlNode node, MemberInfo member, byte[] b) { SetValue(node, member, GetFormatter(member).Format(b)); }
public static void SetValue( XmlNode node, MemberInfo member, string value) { if (member.LocalName != "") { string prefix = ""; if( member.NamespaceURI != "" ) { prefix = FindPrefixForNamespace(node, member.NamespaceURI ); if( prefix.Length > 0 ) prefix += ":"; else prefix = FindUnusedPrefix(node) + ":"; } XmlElement el = (XmlElement) node; XmlAttribute attr = node.OwnerDocument.CreateAttribute(prefix + member.LocalName, member.NamespaceURI); attr.Value = value; el.SetAttributeNode(attr); } else SetTextValue(node, value); }
public static MemberIterator GetElements( XmlNode node, MemberInfo member) { return new MemberIterator(node.ChildNodes, member); }
public static ulong CastToUInt64( XmlNode node, MemberInfo member) { return Altova.CoreTypes.CastToUInt64(node.InnerText); }
internal static bool MemberEqualsNode(MemberInfo member, XmlNode node) { string nodeURI = node.NamespaceURI == null ? "" : node.NamespaceURI; string nodeLocalName = node.LocalName == null ? "" : node.LocalName; string memberURI = member.NamespaceURI == null ? "" : member.NamespaceURI; string memberLocalName = member.LocalName == null ? "" : member.LocalName; if (nodeURI == memberURI && nodeLocalName == memberLocalName) return true; return false; }
public static XmlNode FindAttribute( XmlNode node, MemberInfo member) { XmlElement el = (XmlElement) node; XmlAttributeCollection attrs = el.Attributes; return attrs.GetNamedItem(member.LocalName, member.NamespaceURI); }
public static byte[] CastToBinary(XmlNode node, MemberInfo member) { return GetFormatter(member).ParseBinary(node.InnerText); }
public static bool IsMember( XmlNode node, MemberInfo member) { if (member.LocalName == "") return node.NodeType == XmlNodeType.Text || node.NodeType == XmlNodeType.CDATA; if (node.NodeType != XmlNodeType.Element) return false; string nodeURI = node.NamespaceURI == null ? "" : node.NamespaceURI; string nodeLocalName = node.LocalName == null ? "" : node.LocalName; string memberURI = member.NamespaceURI == null ? "" : member.NamespaceURI; string memberLocalName = member.LocalName == null ? "" : member.LocalName; // soap-array specialty: no-namespace elements are array members. if ((member.Flags & MemberFlags.SpecialName) != 0) return nodeURI == ""; if (nodeURI == memberURI && nodeLocalName == memberLocalName) return true; return false; }
public static bool CastToBool( XmlNode node, MemberInfo member) { return Altova.CoreTypes.CastToBool(node.InnerText); }
public static void SetValue(XmlNode node, MemberInfo member, Altova.Types.Duration b) { SetValue(node, member, GetFormatter(member).Format(b)); }
public static Altova.Types.DateTime CastToDateTime(XmlNode node, MemberInfo member) { return Altova.CoreTypes.CastToDateTime(node.InnerText); }
public static void SetValue(XmlNode node, MemberInfo member, decimal d) { SetValue(node, member, GetFormatter(member).Format(d)); }
public static decimal CastToDecimal(XmlNode node, MemberInfo member) { return Altova.CoreTypes.CastToDecimal(node.InnerText); }
public MemberIterator(XmlNodeList list, MemberInfo info) { iterator = new AllIterator(list); memberInfo = info; }
public static double CastToDouble( XmlNode node, MemberInfo member) { return Altova.CoreTypes.CastToDouble(node.InnerText); }
public static Altova.Types.Duration CastToDuration(XmlNode node, MemberInfo member) { return Altova.CoreTypes.CastToDuration(node.InnerText); }
/// <summary> /// Constructs an instance of this class from the given member information. /// </summary> /// <param name="info">The member information object.</param> public Element(Altova.TypeInfo.MemberInfo info) { this.memberInfo = info; }