Exemple #1
0
        /// <summary>
        /// Populates a Composite type by looping through it's children, finding corresponding Elements
        /// among the children of the given Element, and calling parse(Type, Element) for each.
        /// </summary>
        ///
        /// <param name="datatypeObject">   The datatype object. </param>
        /// <param name="datatypeElement">  Element describing the datatype. </param>

        private void ParseComposite(IComposite datatypeObject, System.Xml.XmlElement datatypeElement)
        {
            if (datatypeObject is GenericComposite)
            {
                //elements won't be named GenericComposite.x
                System.Xml.XmlNodeList children = datatypeElement.ChildNodes;
                int compNum = 0;
                for (int i = 0; i < children.Count; i++)
                {
                    if (System.Convert.ToInt16(children.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element)
                    {
                        Parse(datatypeObject[compNum], (System.Xml.XmlElement)children.Item(i));
                        compNum++;
                    }
                }
            }
            else
            {
                IType[] children = datatypeObject.Components;
                for (int i = 0; i < children.Length; i++)
                {
                    System.Xml.XmlNodeList matchingElements =
                        datatypeElement.GetElementsByTagName(MakeElementName(datatypeObject, i + 1));
                    if (matchingElements.Count > 0)
                    {
                        Parse(children[i], (System.Xml.XmlElement)matchingElements.Item(0));
                        //components don't repeat - use 1st
                    }
                }
            }
        }
Exemple #2
0
        public virtual void  parseElement(System.Xml.XmlNode oldEl, System.Xml.XmlNode newEl)
        {
            System.Xml.XmlNamedNodeMap nl = (System.Xml.XmlAttributeCollection)oldEl.Attributes;

            if (nl != null)
            {
                for (int i = 0; i < nl.Count; i++)
                {
                    if (((System.Xml.XmlAttributeCollection)newEl.Attributes).GetNamedItem(nl.Item(i).Name) == null)
                    {
                        //System.out.println(nl.item(i).getNodeName()+" attribute not present, adding the attribute");
                        //UPGRADE_TODO: Method 'org.w3c.dom.Element.setAttribute' was converted to 'System.Xml.XmlElement.SetAttribute' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_orgw3cdomElementsetAttribute_javalangString_javalangString'"
                        ((System.Xml.XmlElement)newEl).SetAttribute(nl.Item(i).Name, nl.Item(i).Value);
                    }
                }
            }
            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.Xml.XmlNodeList oldNodes = oldEl.ChildNodes;
            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.Xml.XmlNodeList newNodes = newEl.ChildNodes;

            int i2 = 0;
            int j  = 0;

            while (oldNodes.Item(i2) != null)
            {
                if (newNodes.Item(j) == null)
                {
                    //System.out.println(oldNodes.item(i)+" not present, adding the whole element");
                    if (!ignoreList.Contains(oldNodes.Item(i2).Name))
                    {
                        System.Xml.XmlNode n = newEl.OwnerDocument.ImportNode(oldNodes.Item(i2), true);
                        newEl.AppendChild(n);
                    }
                    i2++; j++;
                }
                else
                {
                    if ((System.Object)oldNodes.Item(i2).Name != (System.Object)newNodes.Item(j).Name)
                    {
                        if (!ignoreList.Contains(oldNodes.Item(i2).Name))
                        {
                            //System.out.println(oldNodes.item(i)+" not present, adding the whole element");
                            System.Xml.XmlNode n = newEl.OwnerDocument.ImportNode(oldNodes.Item(i2), true);
                            newEl.AppendChild(n);
                        }
                        i2++;
                    }
                    else
                    {
                        parseElement(oldNodes.Item(i2), newNodes.Item(j));
                        i2++; j++;
                    }
                }
            }
        }
Exemple #3
0
        private String[,] GetRssData(string channel)
        {
            System.Net.WebRequest  webRequest  = System.Net.WebRequest.Create(channel);
            System.Net.WebResponse webResponse = webRequest.GetResponse();

            System.IO.Stream       stream      = webResponse.GetResponseStream();
            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();

            xmlDocument.Load(stream);

            System.Xml.XmlNodeList xmlNodeList = xmlDocument.SelectNodes("rss/channel/item");

            String[,] tempRssData = new String[100, 3];

            for (int i = 0; i < xmlNodeList.Count; i++)
            {
                System.Xml.XmlNode rssNode;

                rssNode = xmlNodeList.Item(i).SelectSingleNode("title");

                if (rssNode != null)
                {
                    tempRssData[i, 0] = rssNode.InnerText;
                }
                else
                {
                    tempRssData[i, 0] = "";
                }
                rssNode = xmlNodeList.Item(i).SelectSingleNode("description");

                if (rssNode != null)
                {
                    tempRssData[i, 1] = rssNode.InnerText;
                }
                else
                {
                    tempRssData[i, 1] = "";
                }

                rssNode = xmlNodeList.Item(i).SelectSingleNode("link");

                if (rssNode != null)
                {
                    tempRssData[i, 2] = rssNode.InnerText;
                }
                else
                {
                    tempRssData[i, 2] = "";
                }
            }

            return(tempRssData);
        }
Exemple #4
0
        public static string ProcessRSSItem(string rssurl)
        {
            System.Net.WebRequest  myRequest  = System.Net.WebRequest.Create(rssurl);
            System.Net.WebResponse myResponse = myRequest.GetResponse();

            System.IO.Stream       rssStream = myResponse.GetResponseStream();
            System.Xml.XmlDocument rssDoc    = new System.Xml.XmlDocument();
            rssDoc.Load(rssStream);

            System.Xml.XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item");
            string title       = string.Empty;
            string link        = string.Empty;
            string description = string.Empty;
            string content     = string.Empty;

            for (int i = 0; i < rssItems.Count; i++)
            {
                System.Xml.XmlNode rssDetail;

                rssDetail = rssItems.Item(i).SelectSingleNode("title");
                if (rssDetail != null)
                {
                    title = rssDetail.InnerText;
                }
                else
                {
                    title = string.Empty;
                }

                rssDetail = rssItems.Item(i).SelectSingleNode("link");
                if (rssDetail != null)
                {
                    link = rssDetail.InnerText;
                }
                else
                {
                    link = string.Empty;
                }

                rssDetail = rssItems.Item(i).SelectSingleNode("description");
                if (rssDetail != null)
                {
                    description = rssDetail.InnerText;
                }
                else
                {
                    description = string.Empty;
                }
                content += "<p><b><a href='" + link + "' target='new'>" + title + "</a></b><br/>" + description + "</p>";
            }
            return(content);
        }
        private String[,] getRssPodatke(String channel)
        {
            String[] metaData = new String[] { "title", "description", "link" };

            System.Net.WebRequest  mojZahtjev = System.Net.WebRequest.Create(channel);
            System.Net.WebResponse mojOdgovor = mojZahtjev.GetResponse();

            System.IO.Stream       rssStream = mojOdgovor.GetResponseStream();
            System.Xml.XmlDocument rssDoc    = new System.Xml.XmlDocument();

            rssDoc.Load(rssStream);

            System.Xml.XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item");
            String[,] tempRssData = new String[100, 3];

            for (int i = 0; i < rssItems.Count; ++i)
            {
                String             cleaned = null;
                System.Xml.XmlNode rssNode;
                for (int j = 0; j < metaData.Length; ++j)
                {
                    rssNode = rssItems.Item(i).SelectSingleNode(metaData[j]);
                    if (rssNode != null)
                    {
                        cleaned           = Regex.Replace(rssNode.InnerText, @"<[^>]*>", String.Empty, RegexOptions.IgnoreCase).Trim();
                        tempRssData[i, j] = cleaned;
                    }
                    else
                    {
                        tempRssData[i, j] = "";
                    }
                }
            }
            return(tempRssData);
        }
Exemple #6
0
        protected internal static Field[] ParseFields(System.Xml.XmlElement template, ParsingContext context)
        {
            System.Xml.XmlNodeList childNodes = template.ChildNodes;
            var fields = new List <Field>();

            for (int i = 0; i < childNodes.Count; i++)
            {
                System.Xml.XmlNode item = childNodes.Item(i);

                if (IsElement(item))
                {
                    if ("typeRef".Equals(item.Name) || "length".Equals(item.Name))
                    {
                        continue;
                    }
                    var         element     = (System.Xml.XmlElement)item;
                    FieldParser fieldParser = context.GetFieldParser(element);
                    if (fieldParser == null)
                    {
                        context.ErrorHandler.Error(Error.FastConstants.PARSE_ERROR, "No parser registered for " + element.Name);
                    }
                    if (fieldParser != null)
                    {
                        fields.Add(fieldParser.Parse(element, context));
                    }
                }
            }

            return(fields.ToArray());
        }
        private void RenameSelectedFeed()
        {
            if (lstFeeds.SelectedIndex < 0)
            {
                return;
            }

            string newName = Microsoft.VisualBasic.Interaction.InputBox("Enter a new name for the feed:", Application.ProductName, lstFeeds.Text);

            if (newName.Length > 0)
            {
                System.Xml.XmlNode outlineNode = this._Library.MyFeedsOPMLDocument.DocumentElement.SelectNodes("body/outline")[lstFeeds.SelectedIndex];
                outlineNode.Attributes.GetNamedItem("text").Value  = newName;
                outlineNode.Attributes.GetNamedItem("title").Value = newName;
                string url = outlineNode.Attributes.GetNamedItem("xmlUrl").Value;
                this._Library.SortFeeds();
                DisplayFeeds();

                // Set focus back to this newly-renamed feed
                System.Xml.XmlNodeList feedList = this._Library.MyFeedsOPMLDocument.DocumentElement.SelectNodes("body/outline");
                for (int i = 0; i < feedList.Count; i++)
                {
                    if (feedList.Item(i).Attributes.GetNamedItem("xmlUrl").Value == url)
                    {
                        // This is the one!
                        lstFeeds.SelectedIndex = i;
                        break;
                    }
                }
            }
        }
Exemple #8
0
        /// <summary>Parses a primitive type by filling it with text child, if any </summary>
        private void  parsePrimitive(Primitive datatypeObject, System.Xml.XmlElement datatypeElement)
        {
            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.Xml.XmlNodeList children = datatypeElement.ChildNodes;
            int  c    = 0;
            bool full = false;

            while (c < children.Count && !full)
            {
                System.Xml.XmlNode child = children.Item(c++);
                if (System.Convert.ToInt16(child.NodeType) == (short)System.Xml.XmlNodeType.Text)
                {
                    try
                    {
                        if (child.Value != null && !child.Value.Equals(""))
                        {
                            if (keepAsOriginal(child.ParentNode))
                            {
                                datatypeObject.Value = child.Value;
                            }
                            else
                            {
                                datatypeObject.Value = removeWhitespace(child.Value);
                            }
                        }
                    }
                    //UPGRADE_TODO: Class 'org.w3c.dom.DOMException' was converted to 'System.Exceptiont' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    catch (System.Exception e)
                    {
                        log.error("Error parsing primitive value from TEXT_NODE", e);
                    }
                    full = true;
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// 获取更新文件列表
        /// </summary>
        /// <param name="isAll"></param>
        /// <returns></returns>
        public List <string> GetUpdateFileList(bool isAll)
        {
            List <string> lstFiles = new List <string>();

            System.Xml.XmlDocument doc      = this.GetDoc();
            System.Xml.XmlNodeList nodelist = doc["Main"]["FileList"].GetElementsByTagName("File");
            if (nodelist == null || nodelist.Count == 0)
            {
                return(lstFiles);
            }

            System.Xml.XmlNode node = null;
            for (int i = 0; i < nodelist.Count; i++)
            {
                node = nodelist.Item(i);
                if (isAll)
                {
                    lstFiles.Add(node.Attributes["name"].Value.Trim());
                }
                else
                {
                    if (node.Attributes["status"].Value.Trim() == "1")
                    {
                        lstFiles.Add(node.Attributes["name"].Value.Trim());
                    }
                }
            }
            doc  = null;
            node = null;

            return(lstFiles);
        }
Exemple #10
0
        /// <summary>   Parses a primitive type by filling it with text child, if any. </summary>
        ///
        /// <param name="datatypeObject">   The datatype object. </param>
        /// <param name="datatypeElement">  Element describing the datatype. </param>

        private void ParsePrimitive(IPrimitive datatypeObject, System.Xml.XmlElement datatypeElement)
        {
            System.Xml.XmlNodeList children = datatypeElement.ChildNodes;
            int  c    = 0;
            bool full = false;

            while (c < children.Count && !full)
            {
                System.Xml.XmlNode child = children.Item(c++);
                if (System.Convert.ToInt16(child.NodeType) == (short)System.Xml.XmlNodeType.Text)
                {
                    try
                    {
                        if (child.Value != null && !child.Value.Equals(""))
                        {
                            if (this.KeepAsOriginal(child.ParentNode))
                            {
                                datatypeObject.Value = child.Value;
                            }
                            else
                            {
                                datatypeObject.Value = this.RemoveWhitespace(child.Value);
                            }
                        }
                    }
                    catch (System.Exception e)
                    {
                        log.Error("Error parsing primitive value from TEXT_NODE", e);
                    }
                    full = true;
                }
            }
        }
        /// <summary> Populates the given group object with data from the given group element, ignoring
        /// any unrecognized nodes.
        /// </summary>
        private void  parse(Genetibase.NuGenHL7.model.Group groupObject, System.Xml.XmlElement groupElement)
        {
            System.String[] childNames  = groupObject.Names;
            System.String   messageName = groupObject.Message.getName();

            System.Xml.XmlNodeList       allChildNodes       = groupElement.ChildNodes;
            System.Collections.ArrayList unparsedElementList = new System.Collections.ArrayList();
            for (int i = 0; i < allChildNodes.Count; i++)
            {
                System.Xml.XmlNode node = allChildNodes.Item(i);
                System.String      name = node.Name;
                if (System.Convert.ToInt16(node.NodeType) == (short)System.Xml.XmlNodeType.Element && !unparsedElementList.Contains(name))
                {
                    unparsedElementList.Add(name);
                }
            }

            //we're not too fussy about order here (all occurances get parsed as repetitions) ...
            for (int i = 0; i < childNames.Length; i++)
            {
                SupportClass.ICollectionSupport.Remove(unparsedElementList, childNames[i]);
                parseReps(groupElement, groupObject, messageName, childNames[i], childNames[i]);
            }

            for (int i = 0; i < unparsedElementList.Count; i++)
            {
                System.String segName      = (System.String)unparsedElementList[i];
                System.String segIndexName = groupObject.addNonstandardSegment(segName);
                parseReps(groupElement, groupObject, messageName, segName, segIndexName);
            }
        }
Exemple #12
0
        public String serealizarGAA(Dictionary <string, object> dict)
        {
            StringBuilder builder = new StringBuilder();

            foreach (KeyValuePair <string, object> pair in dict)
            {
                if (pair.Key.Equals("Payload"))
                {
                    StringBuilder builderPayload = new StringBuilder();
                    builder.Append(pair.Key).Append("[");
                    System.Xml.XmlNode[] aux = (System.Xml.XmlNode[])pair.Value;
                    if (aux != null)
                    {
                        {
                            for (int i = 0; i < aux.Count(); i++)
                            {
                                System.Xml.XmlNodeList inner = aux[i].ChildNodes;
                                for (int j = 0; j < inner.Count; j++)
                                {
                                    builderPayload.Append(inner.Item(j).Name + " : " + inner.Item(j).InnerText + ",");
                                }
                            }
                        }
                    }
                    builder.Append(builderPayload.ToString().TrimEnd(','));
                    builder.Append("]");
                }
                else
                {
                    builder.Append(pair.Key).Append(":").Append(pair.Value).Append(',');
                }
            }

            return(builder.ToString().TrimEnd(','));
        }
        /// <summary> Populates the given group object with data from the given group element, ignoring
        /// any unrecognized nodes.
        /// </summary>
        private void  parse(ca.uhn.hl7v2.model.Group groupObject, System.Xml.XmlElement groupElement)
        {
            System.String[] childNames  = groupObject.Names;
            System.String   messageName = groupObject.Message.getStructureName();

            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.Xml.XmlNodeList       allChildNodes       = groupElement.ChildNodes;
            System.Collections.ArrayList unparsedElementList = new System.Collections.ArrayList();
            for (int i = 0; i < allChildNodes.Count; i++)
            {
                System.Xml.XmlNode node = allChildNodes.Item(i);
                System.String      name = node.Name;
                if (System.Convert.ToInt16(node.NodeType) == (short)System.Xml.XmlNodeType.Element && !unparsedElementList.Contains(name))
                {
                    unparsedElementList.Add(name);
                }
            }

            //we're not too fussy about order here (all occurances get parsed as repetitions) ...
            for (int i = 0; i < childNames.Length; i++)
            {
                SupportClass.ICollectionSupport.Remove(unparsedElementList, childNames[i]);
                parseReps(groupElement, groupObject, messageName, childNames[i], childNames[i]);
            }

            for (int i = 0; i < unparsedElementList.Count; i++)
            {
                System.String segName      = (System.String)unparsedElementList[i];
                System.String segIndexName = groupObject.addNonstandardSegment(segName);
                parseReps(groupElement, groupObject, messageName, segName, segIndexName);
            }
        }
Exemple #14
0
 private void  parseReps(Segment segmentObject, System.Xml.XmlElement segmentElement, System.String fieldName, int fieldNum)
 {
     System.Xml.XmlNodeList reps = segmentElement.GetElementsByTagName(fieldName);
     for (int i = 0; i < reps.Count; i++)
     {
         parse(segmentObject.getField(fieldNum, i), (System.Xml.XmlElement)reps.Item(i));
     }
 }
Exemple #15
0
        private String[,] getRssData(String chanel)
        {
            System.Net.WebRequest  myRequest  = System.Net.WebRequest.Create(chanel);
            System.Net.WebResponse myResponse = myRequest.GetResponse();

            System.IO.Stream       rssStream = myResponse.GetResponseStream();
            System.Xml.XmlDocument rssDoc    = new System.Xml.XmlDocument();

            rssDoc.Load(rssStream);
            System.Xml.XmlNodeList rssItem = rssDoc.SelectNodes("rss/channel/item");

            String[,] tempRssData = new String[100, 3];

            for (int i = 0; i < 5; i++)
            {
                System.Xml.XmlNode rssNode;
                rssNode = rssItem.Item(i).SelectSingleNode("title");
                if (rssNode != null)
                {
                    tempRssData[i, 0] = rssNode.InnerText;
                }
                else
                {
                    tempRssData[i, 0] = "";
                }
                rssNode = rssItem.Item(i).SelectSingleNode("description");
                if (rssNode != null)
                {
                    tempRssData[i, 1] = rssNode.InnerText;
                }
                else
                {
                    tempRssData[i, 1] = "";
                }
                rssNode = rssItem.Item(i).SelectSingleNode("link");
                if (rssNode != null)
                {
                    tempRssData[i, 2] = rssNode.InnerText;
                }
                else
                {
                    tempRssData[i, 2] = "";
                }
            }
            return(tempRssData);
        }
Exemple #16
0
        public static GradientStopCollection ToGradientStops(System.Xml.XmlNodeList stops)
        {
            int itemCount = stops.Count;
            GradientStopCollection gradientStops = new GradientStopCollection(itemCount);

            double lastOffset = 0;

            for (int i = 0; i < itemCount; i++)
            {
                SvgStopElement stop  = (SvgStopElement)stops.Item(i);
                string         prop  = stop.GetAttribute("stop-color");
                string         style = stop.GetAttribute("style");
                Color          color = Colors.Transparent; // no auto-inherited...
                if (!string.IsNullOrWhiteSpace(prop) || !string.IsNullOrWhiteSpace(style))
                {
                    SvgColor svgColor = new SvgColor(stop.GetComputedStyle(string.Empty).GetPropertyValue("stop-color"));
                    if (svgColor.ColorType == SvgColorType.CurrentColor)
                    {
                        string sCurColor = stop.GetComputedStyle(string.Empty).GetPropertyValue(CssConstants.PropColor);
                        svgColor = new SvgColor(sCurColor);
                    }
                    TryConvertColor(svgColor.RgbColor, out color);
                }
                else
                {
                    color = Colors.Black; // the default color...
                }

                double alpha = 255;
                string opacity;

                opacity = stop.GetAttribute("stop-opacity"); // no auto-inherit
                if (opacity == "inherit")                    // if explicitly defined...
                {
                    opacity = stop.GetPropertyValue("stop-opacity");
                }
                if (!string.IsNullOrWhiteSpace(opacity))
                {
                    alpha *= SvgNumber.ParseNumber(opacity);
                }

                alpha = Math.Min(alpha, 255);
                alpha = Math.Max(alpha, 0);

                color = Color.FromArgb((byte)Convert.ToInt32(alpha),
                                       color.R, color.G, color.B);

                double offset = stop.Offset.AnimVal;

                offset /= 100;
                offset  = Math.Max(lastOffset, offset);

                gradientStops.Add(new GradientStop(color, offset));
                lastOffset = offset;
            }

            return(gradientStops);
        }
Exemple #17
0
 /// <summary>
 /// Build edges
 /// In this dblp model, if more than one author co-authored an article
 /// then there is an edge between these authors.
 /// </summary>
 public void buildEdges()
 {
     System.Xml.XmlNodeList n = p.GetElementsByTagName("article");
     this.articleNumber = n.Count;
     foreach (System.Xml.XmlElement element in n)
     {
         if (GetQuantityOfTag(element, "author") > 1)
         {
             System.Xml.XmlNodeList e = element.GetElementsByTagName("author");
             for (int i = 0; i < e.Count; i++)
             {
                 for (int j = i + 1; j < e.Count; j++)
                 {
                     base.AddEdge(base.nodes[e.Item(i).InnerText], base.nodes[e.Item(j).InnerText]);
                 }
             }
         }
     }
 }
Exemple #18
0
 internal static string getResponseElementAsString(System.Xml.XmlDocument doc, string path)
 {
     System.Xml.XmlNodeList nodeList = doc.SelectNodes(stringHelper.AppendUrl("/methodCallResult/", path, false));
     System.Xml.XmlNode     node     = nodeList.Item(0);
     if (node != null)
     {
         return(node.InnerText);
     }
     return(null);
 }
Exemple #19
0
        public override Field Parse(System.Xml.XmlElement fieldNode, bool optional, ParsingContext context)
        {
            System.Xml.XmlNodeList fieldChildren = fieldNode.ChildNodes;
            System.Xml.XmlNode     mantissaNode  = null;
            System.Xml.XmlNode     exponentNode  = null;

            for (int i = 0; i < fieldChildren.Count; i++)
            {
                if ("mantissa".Equals(fieldChildren.Item(i).Name))
                {
                    mantissaNode = fieldChildren.Item(i);
                }
                else if ("exponent".Equals(fieldChildren.Item(i).Name))
                {
                    exponentNode = fieldChildren.Item(i);
                }
            }
            return(createComposedDecimal(fieldNode, context.GetName(), optional, mantissaNode, exponentNode, context));
        }
Exemple #20
0
        /// <summary>   Populates the given Segment object with data from the given XML Element. </summary>
        /// <summary>   for the given Segment, or if there is an error while setting individual field
        ///             values. </summary>
        ///
        /// <param name="segmentObject">    The segment object. </param>
        /// <param name="segmentElement">   Element describing the segment. </param>

        public virtual void Parse(ISegment segmentObject, System.Xml.XmlElement segmentElement)
        {
            SupportClass.HashSetSupport done = new SupportClass.HashSetSupport();

            //        for (int i = 1; i <= segmentObject.NumFields(); i++) {
            //            String elementName = makeElementName(segmentObject, i);
            //            done.add(elementName);
            //            parseReps(segmentObject, segmentElement, elementName, i);
            //        }

            System.Xml.XmlNodeList all = segmentElement.ChildNodes;
            for (int i = 0; i < all.Count; i++)
            {
                System.String elementName = all.Item(i).Name;
                if (System.Convert.ToInt16(all.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element &&
                    !done.Contains(elementName))
                {
                    done.Add(elementName);

                    int index = elementName.IndexOf('.');
                    if (index >= 0 && elementName.Length > index)
                    {
                        //properly formatted element
                        System.String fieldNumString = elementName.Substring(index + 1);
                        int           fieldNum       = System.Int32.Parse(fieldNumString);
                        this.ParseReps(segmentObject, segmentElement, elementName, fieldNum);
                    }
                    else
                    {
                        log.Debug(
                            "Child of segment " + segmentObject.GetStructureName() + " doesn't look like a field: "
                            + elementName);
                    }
                }
            }

            //set data type of OBX-5
            if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
            {
                Varies.fixOBX5(segmentObject, this.Factory);
            }
        }
Exemple #21
0
        /// <summary> Populates the given Segment object with data from the given XML Element.</summary>
        /// <throws>  HL7Exception if the XML Element does not have the correct name and structure </throws>
        /// <summary>      for the given Segment, or if there is an error while setting individual field values.
        /// </summary>
        public virtual void  parse(Segment segmentObject, System.Xml.XmlElement segmentElement)
        {
            //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
            SupportClass.HashSetSupport done = new SupportClass.HashSetSupport();

            //        for (int i = 1; i <= segmentObject.numFields(); i++) {
            //            String elementName = makeElementName(segmentObject, i);
            //            done.add(elementName);
            //            parseReps(segmentObject, segmentElement, elementName, i);
            //        }

            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.Xml.XmlNodeList all = segmentElement.ChildNodes;
            for (int i = 0; i < all.Count; i++)
            {
                System.String elementName = all.Item(i).Name;
                if (System.Convert.ToInt16(all.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element && !done.Contains(elementName))
                {
                    done.Add(elementName);

                    int index = elementName.IndexOf('.');
                    if (index >= 0 && elementName.Length > index)
                    {
                        //properly formatted element
                        System.String fieldNumString = elementName.Substring(index + 1);
                        int           fieldNum       = System.Int32.Parse(fieldNumString);
                        parseReps(segmentObject, segmentElement, elementName, fieldNum);
                    }
                    else
                    {
                        log.debug("Child of segment " + segmentObject.getStructureName() + " doesn't look like a field: " + elementName);
                    }
                }
            }

            //set data type of OBX-5
            if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
            {
                Varies.fixOBX5(segmentObject, Factory);
            }
        }
Exemple #22
0
        internal static string getParmAsString(System.Xml.XmlDocument doc, string szName)
        {
            string path = stringHelper.AppendUrl("/methodCallResult/params/", szName, false);

            System.Xml.XmlNodeList nodeList = doc.SelectNodes(path);
            System.Xml.XmlNode     node     = nodeList.Item(0);
            if (node != null)
            {
                return(node.InnerText);
            }
            return(null);
        }
Exemple #23
0
 public override bool CanParse(System.Xml.XmlElement element, ParsingContext context)
 {
     System.Xml.XmlNodeList children = element.ChildNodes;
     for (int i = 0; i < children.Count; i++)
     {
         string nodeName = children.Item(i).Name;
         if (nodeName.Equals("mantissa") || nodeName.Equals("exponent"))
         {
             return(true);
         }
     }
     return(false);
 }
        private System.Xml.XmlNode GetSheetsRootNodeAndRemoveChildrens(System.Xml.XmlDocument contentXml, System.Xml.XmlNamespaceManager nmsManager)
        {
            System.Xml.XmlNodeList tableNodes = this.GetTableNodes(contentXml, nmsManager);

            System.Xml.XmlNode sheetsRootNode = tableNodes.Item(0).ParentNode;
            // remove sheets from template file
            foreach (System.Xml.XmlNode tableNode in tableNodes)
            {
                sheetsRootNode.RemoveChild(tableNode);
            }

            return(sheetsRootNode);
        }
Exemple #25
0
        internal static List <string> getParmAsStringArray(System.Xml.XmlDocument doc, String szName)
        {
            System.Xml.XmlNodeList nodeList = doc.SelectNodes(stringHelper.AppendUrl("/methodCallResult/params/", szName, false));
            List <String>          list     = new List <String>();

            for (int i = 0; i < nodeList.Count; i++)
            {
                System.Xml.XmlNode childNode = nodeList.Item(i);
                if (childNode.Value != null)
                {
                    list.Add(childNode.Value);
                }
            }
            return(list);
        }
Exemple #26
0
            public void sendGetAuthorizeAnswer()
            {
                string output = "";

                try
                {
                    var res = connector.GetAuthorizeAnswer(getAuthorizeAnswerParams);

                    foreach (var key in res.Keys)
                    {
                        Console.WriteLine("- " + key + ": " + res[key]);

                        if (key.Equals("Payload"))
                        {
                            System.Xml.XmlNode[] aux = (System.Xml.XmlNode[])res["Payload"];
                            if (aux != null)
                            {
                                for (int i = 0; i < aux.Count(); i++)
                                {
                                    System.Xml.XmlNodeList inner = aux[i].ChildNodes;
                                    for (int j = 0; j < inner.Count; j++)
                                    {
                                        Console.WriteLine("     " + inner.Item(j).Name + " : " + inner.Item(j).InnerText);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (WebException ex)
                {
                    if (ex.Status == WebExceptionStatus.ProtocolError)
                    {
                        WebResponse resp = ex.Response;
                        using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
                        {
                            output += "\r\n" + sr.ReadToEnd() + "\r\n" + ex.Message;
                            //Response.Write(sr.ReadToEnd());
                        }
                    }
                }
                catch (Exception ex)
                {
                    output += "\r\n" + ex.Message + "\r\n" + ex.InnerException.Message + "\r\n" + ex.HelpLink;
                }

                Console.WriteLine(output);
            }
Exemple #27
0
        private Net.Vpc.Upa.Impl.Config.PersistenceUnitElement ParsePersistenceUnit(System.Xml.XmlElement e, Net.Vpc.Upa.Impl.Config.PersistenceGroupElement persistenceGroupElement)
        {
            System.Collections.Generic.IDictionary <string, string> attrs = Net.Vpc.Upa.Impl.Util.XMLUtils.GetAttributes(e, persistenceUnitElementFilter);
            string name = Nullify(Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, string>(attrs, "name"));

            Net.Vpc.Upa.Impl.Config.PersistenceUnitElement s = persistenceGroupElement.GetOrAddPersistenceUnitElement(name);
            s.start    = ParseBoolean(Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, string>(attrs, "start"), s.start);
            s.autoScan = ParseBoolean(Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, string>(attrs, "autoScan"), s.autoScan);
            System.Xml.XmlNodeList nl = (e).ChildNodes;
            if (nl != null && (nl).Count > 0)
            {
                for (int i = 0; i < (nl).Count; i++)
                {
                    System.Xml.XmlNode item = nl.Item(i);
                    if (item is System.Xml.XmlElement)
                    {
                        System.Xml.XmlElement el = (System.Xml.XmlElement)item;
                        //add it to list
                        string tagName = (el).Name;
                        if (Net.Vpc.Upa.Impl.Util.XMLUtils.EqualsUniform(tagName, "connection"))
                        {
                            s.connectionElements.Add(ParseConnection(el));
                        }
                        else if (Net.Vpc.Upa.Impl.Util.XMLUtils.EqualsUniform(tagName, "rootConnection"))
                        {
                            s.rootConnectionElements.Add(ParseConnection(el));
                        }
                        else if (Net.Vpc.Upa.Impl.Util.XMLUtils.EqualsUniform(tagName, "property"))
                        {
                            s.properties.Add(ParseProperty(el));
                        }
                        else if (Net.Vpc.Upa.Impl.Util.XMLUtils.EqualsUniform(tagName, "scan"))
                        {
                            s.scanElements.Add(ParseScan(el));
                        }
                        else
                        {
                            throw new System.ArgumentException("Unsupported tag " + tagName + " for PersistenceUnit. " + "valid tags are connection, rootConnection, property, scan");
                        }
                    }
                    else
                    {
                    }
                }
            }
            //                    System.out.println(item);
            return(s);
        }
Exemple #28
0
        /// <summary>
        /// Build a new instance using  XML data
        /// </summary>
        /// <param name="enumeratedDataElement"></param>
        public HLAEnumeratedData(System.Xml.XmlElement enumeratedDataElement)
            : base(enumeratedDataElement)
        {
            Representation      = enumeratedDataElement.GetAttribute("representation");
            RepresentationNotes = enumeratedDataElement.GetAttribute("representationNotes");
            Semantics           = ReplaceNewLines(enumeratedDataElement.GetAttribute("semantics"));
            SemanticsNotes      = enumeratedDataElement.GetAttribute("semanticsNotes");

            System.Xml.XmlNodeList nl = enumeratedDataElement.GetElementsByTagName("enumerator");
            for (int i = 0; i < nl.Count; i++)
            {
                System.Xml.XmlElement enumeratorElement = (System.Xml.XmlElement)nl.Item(i);
                HLAEnumerator         enumerator        = new HLAEnumerator(enumeratorElement);
                enumerators.Add(enumerator);
            }
        }
Exemple #29
0
        /// <summary>   Returns true if any of the given element's children are elements. </summary>
        ///
        /// <param name="e">    Element describing the e. </param>
        ///
        /// <returns>   true if child element, false if not. </returns>

        private bool HasChildElement(System.Xml.XmlElement e)
        {
            System.Xml.XmlNodeList children = e.ChildNodes;
            bool hasElement = false;
            int  c          = 0;

            while (c < children.Count && !hasElement)
            {
                if (System.Convert.ToInt16(children.Item(c).NodeType) == (short)System.Xml.XmlNodeType.Element)
                {
                    hasElement = true;
                }
                c++;
            }
            return(hasElement);
        }