private static XmlFormatter GetFormatter(MemberInfo member)
 {
     if (member.DataType.Formatter != null)
         return (XmlFormatter) member.DataType.Formatter;
     else
         return (XmlFormatter) Xs.AnySimpleTypeFormatter;
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 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;
 }
Exemple #4
0
 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);
			}
		}
Exemple #9
0
 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;
     }
 }
Exemple #10
0
 public static string CastToString( XmlNode node, MemberInfo member)
 {
     return Altova.CoreTypes.CastToString(node.InnerText);
 }
Exemple #11
0
        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);
        }
Exemple #12
0
 public static int CastToInt( XmlNode node, MemberInfo member)
 {
     return Altova.CoreTypes.CastToInt(node.InnerText);
 }
Exemple #13
0
		public Attribute(Altova.TypeInfo.MemberInfo info)
		{
			this.memberInfo = info;
		}
Exemple #14
0
 public Enumerator(AllIterator list, MemberInfo info)
 {
     this.iterator = list.GetEnumerator();
     this.info = info;
 }
Exemple #15
0
        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);
        }
Exemple #16
0
 public static void SetValue(XmlNode node, MemberInfo member, byte[] b)
 {
     SetValue(node, member, GetFormatter(member).Format(b));
 }
Exemple #17
0
        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);
        }
Exemple #18
0
 public static MemberIterator GetElements( XmlNode node,  MemberInfo member)
 {
     return new MemberIterator(node.ChildNodes, member);
 }
Exemple #19
0
 public static ulong CastToUInt64( XmlNode node, MemberInfo member)
 {
     return Altova.CoreTypes.CastToUInt64(node.InnerText);
 }
Exemple #20
0
        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;
        }
Exemple #21
0
 public static XmlNode FindAttribute( XmlNode node,  MemberInfo member)
 {
     XmlElement el = (XmlElement) node;
     XmlAttributeCollection attrs = el.Attributes;
     return attrs.GetNamedItem(member.LocalName, member.NamespaceURI);
 }
Exemple #22
0
 public static byte[] CastToBinary(XmlNode node, MemberInfo member)
 {
     return GetFormatter(member).ParseBinary(node.InnerText);
 }
Exemple #23
0
        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;
        }
Exemple #24
0
 public static bool CastToBool( XmlNode node, MemberInfo member)
 {
     return Altova.CoreTypes.CastToBool(node.InnerText);
 }
Exemple #25
0
 public static void SetValue(XmlNode node, MemberInfo member, Altova.Types.Duration b)
 {
     SetValue(node, member, GetFormatter(member).Format(b));
 }
Exemple #26
0
 public static Altova.Types.DateTime CastToDateTime(XmlNode node, MemberInfo member)
 {
     return Altova.CoreTypes.CastToDateTime(node.InnerText);
 }
Exemple #27
0
 public static void SetValue(XmlNode node,  MemberInfo member, decimal d)
 {
     SetValue(node, member, GetFormatter(member).Format(d));
 }
Exemple #28
0
 public static decimal CastToDecimal(XmlNode node, MemberInfo member)
 {
     return Altova.CoreTypes.CastToDecimal(node.InnerText);
 }
Exemple #29
0
 public MemberIterator(XmlNodeList list, MemberInfo info)
 {
     iterator = new AllIterator(list);
     memberInfo = info;
 }
Exemple #30
0
 public static double CastToDouble( XmlNode node, MemberInfo member)
 {
     return Altova.CoreTypes.CastToDouble(node.InnerText);
 }
Exemple #31
0
 public static Altova.Types.Duration CastToDuration(XmlNode node, MemberInfo member)
 {
     return Altova.CoreTypes.CastToDuration(node.InnerText);
 }
Exemple #32
0
		/// <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;
		}