internal static void AddConformanceClaims(XmlElement documentation, WsiProfiles claims)
 {
     claims &= WsiProfiles.BasicProfile1_1;
     if (claims != WsiProfiles.None)
     {
         WsiProfiles conformanceClaims = GetConformanceClaims(documentation);
         claims &= ~conformanceClaims;
         if (claims != WsiProfiles.None)
         {
             XmlDocument ownerDocument = documentation.OwnerDocument;
             if ((claims & WsiProfiles.BasicProfile1_1) != WsiProfiles.None)
             {
                 XmlElement newChild = ownerDocument.CreateElement("wsi", "Claim", "http://ws-i.org/schemas/conformanceClaim/");
                 newChild.SetAttribute("conformsTo", "http://ws-i.org/profiles/basic/1.1");
                 documentation.InsertBefore(newChild, null);
             }
         }
     }
 }
コード例 #2
0
        internal static void AddConformanceClaims(XmlElement documentation, WsiProfiles claims) {
            //
            claims &= SupportedClaims;
            if (claims == WsiProfiles.None)
                return;

            // check already presend claims
            WsiProfiles existingClaims = GetConformanceClaims(documentation);
            claims &= ~existingClaims;
            if (claims == WsiProfiles.None)
                return;

            XmlDocument d = documentation.OwnerDocument;
            if ((claims & WsiProfiles.BasicProfile1_1) != 0) {
                XmlElement claim = d.CreateElement(Soap.ClaimPrefix, Soap.Element.Claim, Soap.ConformanceClaim);
                claim.SetAttribute(Soap.Attribute.ConformsTo, Soap.BasicProfile1_1);
                documentation.InsertBefore(claim, null);
            }
        }
コード例 #3
0
ファイル: Request.cs プロジェクト: svn2github/ehi
        private void AddSignature(XmlElement parent)
        {
            body.Normalize();

            SignedXml signed = new SamlSignedXml(body);
            signed.SigningKey = sessionCert.PrivateKey;
            signed.SignedInfo.CanonicalizationMethod = SignedXml.XmlDsigExcC14NTransformUrl;
            signed.KeyInfo = new KeyInfo();
            signed.KeyInfo.AddClause(new KeyInfoX509Data(sessionCert, X509IncludeOption.EndCertOnly));

            Reference requestRef = new Reference("#" + requestId);
            requestRef.AddTransform(new XmlDsigEnvelopedSignatureTransform());
            requestRef.AddTransform(new XmlDsigExcC14NTransform());
            signed.AddReference(requestRef);
            signed.ComputeSignature();
            parent.InsertBefore(signed.GetXml(), parent.FirstChild);
        }
コード例 #4
0
		protected void WriteActionGroups (ObjectWriter writer, XmlElement elem)
		{
			if (writer.Format == FileFormat.Native) {
				if (actionGroups != null) {
					foreach (ActionGroup actionGroup in actionGroups)
						elem.InsertBefore (actionGroup.Write (writer), elem.FirstChild);
				}
			}
		}
コード例 #5
0
ファイル: XmlProcessor.cs プロジェクト: hazzik/Rhino.Net
		private void BeautifyElement(XmlElement e, int indent)
		{
			StringBuilder s = new StringBuilder();
			s.Append('\n');
			for (int i = 0; i < indent; i++)
			{
				s.Append(' ');
			}
			string afterContent = s.ToString();
			for (int i_1 = 0; i_1 < prettyIndent; i_1++)
			{
				s.Append(' ');
			}
			string beforeContent = s.ToString();
			//    We "mark" all the nodes first; if we tried to do this loop otherwise, it would behave unexpectedly (the inserted nodes
			//    would contribute to the length and it might never terminate).
			List<System.Xml.XmlNode> toIndent = new List<System.Xml.XmlNode>();
			bool indentChildren = false;
			for (int i_2 = 0; i_2 < e.ChildNodes.Count; i_2++)
			{
				if (i_2 == 1)
				{
					indentChildren = true;
				}
				if (e.ChildNodes.Item(i_2) is XmlText)
				{
					toIndent.Add(e.ChildNodes.Item(i_2));
				}
				else
				{
					indentChildren = true;
					toIndent.Add(e.ChildNodes.Item(i_2));
				}
			}
			if (indentChildren)
			{
				for (int i_3 = 0; i_3 < toIndent.Count; i_3++)
				{
					e.InsertBefore(e.OwnerDocument.CreateTextNode(beforeContent), toIndent[i_3]);
				}
			}
			XmlNodeList nodes = e.ChildNodes;
			List<XmlElement> list = new List<XmlElement>();
			for (int i_4 = 0; i_4 < nodes.Count; i_4++)
			{
				if (nodes.Item(i_4) is XmlElement)
				{
					list.Add((XmlElement)nodes.Item(i_4));
				}
			}
			foreach (XmlElement elem in list)
			{
				BeautifyElement(elem, indent + prettyIndent);
			}
			if (indentChildren)
			{
				e.AppendChild(e.OwnerDocument.CreateTextNode(afterContent));
			}
		}
コード例 #6
0
ファイル: ActionModelSettings.cs プロジェクト: nhannd/Xian
        /// <summary>
        /// Appends the specified action to the specified XML action model.  The "group-hint"
		/// attribute of the action to be inserted is compared with the "group-hint" of the
		/// actions in the xml model and an appropriate place to insert the action is determined
		/// based on the MatchScore method of the <see cref="GroupHint"/>.
        /// </summary>
        /// <param name="xmlActionModel">the "action-model" node to insert an action into</param>
        /// <param name="action">the action to be inserted</param>
		/// <returns>a boolean indicating whether anything was added/removed/modified</returns>
        private static bool AppendActionToXmlModel(XmlDocument document, XmlElement xmlActionModel, IAction action)
        {
            if (null != FindXmlAction(xmlActionModel, action))
				return false;
			
			XmlNode insertionPoint = null;
            bool insertBefore = false;
			int currentGroupScore = 0;

			foreach (XmlElement xmlAction in xmlActionModel.GetElementsByTagName("action"))
			{
				string hint = xmlAction.GetAttribute("group-hint");
				var groupHint = new GroupHint(hint);

				int groupScore = action.GroupHint.MatchScore(groupHint);
                if (groupScore > 0 && groupScore >= Math.Abs(currentGroupScore))
                {
                    //"greater than" current score
                    insertionPoint = xmlAction;
                    currentGroupScore = groupScore;
                    insertBefore = false;
                }
                else if (groupScore < 0 && Math.Abs(groupScore) > Math.Abs(currentGroupScore))
                {
                    //"less than"
                    insertionPoint = xmlAction;
                    currentGroupScore = groupScore;
                    insertBefore = true;
                }
			}
						
			XmlElement newXmlAction = CreateXmlAction(document, action);
			
			if (insertionPoint != null)
			{
			    if (insertBefore)
                    xmlActionModel.InsertBefore(newXmlAction, insertionPoint);
                else 
                    xmlActionModel.InsertAfter(newXmlAction, insertionPoint);
			}
			else
				xmlActionModel.AppendChild(newXmlAction);

			return true;
		}
コード例 #7
0
ファイル: BuildItemGroupXml.cs プロジェクト: nikson/msbuild
 internal void InsertBefore(XmlElement parent, XmlElement child, XmlElement reference)
 {
     parent.InsertBefore(child, reference);
 }
コード例 #8
0
 protected override void InsertTransformElement(XmlElement targetElement, XmlElement transformElement)
 {
     targetElement.InsertBefore(transformElement, targetElement.ChildNodes.OfType<XmlNode>().FirstOrDefault());
 }
コード例 #9
0
        private void ExtractSharedValues(XmlElement arrayNode)
        {
            var childs = GetChild(arrayNode);
            if (childs.Count < 2) return;//No defaults for less than two item in the array
            if (arrayNode.SelectNodes("Item[@ElementDataType]").Count > 0)//Dont make default for different Data types
                return;
            Dictionary<string, int> dic = new Dictionary<string, int>();
            Dictionary<string, string> propertyValue = new Dictionary<string, string>();
            foreach (XmlNode property in arrayNode.SelectNodes("Item/Property"))
            {
                string key = property.Attributes["PropertyName"].Value;
                if (propertyValue.ContainsKey(key) && propertyValue[key] != property.InnerXml)
                    dic.Remove(key);
                else
                {
                    propertyValue[key] = property.InnerXml;
                    if (dic.ContainsKey(key)) dic[key]++;
                    else dic[key] = 1;
                }
            }
            var defaultItem = xmlDoc.CreateElement("ItemDefaults");

            foreach (var item in dic)
            {
                if (item.Value < childs.Count) continue;
                var nodes = arrayNode.SelectNodes(string.Format("Item/Property[@PropertyName=\"{0}\"]", item.Key));
                foreach (XmlNode node in nodes)
                    node.ParentNode.RemoveChild(node);
                defaultItem.AppendChild(nodes[0]);
            }
            if (GetChild(defaultItem).Count > 0)
                arrayNode.InsertBefore(defaultItem, childs[0]);
        }
コード例 #10
0
ファイル: AddNode.cs プロジェクト: rh/mix
        protected override void ExecuteCore(XmlElement element)
        {
            var child = CreateNode(element);

            if (!string.IsNullOrEmpty(After))
            {
                try
                {
                    if (After == "self")
                    {
                        element.ParentNode.InsertAfter(child, element);

                        return;
                    }

                    var node = element.SelectSingleNode(After);

                    if (node != null)
                    {
                        element.InsertAfter(child, node);

                        return;
                    }
                }
                catch (XPathException e)
                {
                    var message = string.Format("'{0}' is not a valid XPath expression.", After);
                    throw new TaskExecutionException(message, e);
                }
                catch (ArgumentException)
                {
                    // The XPath expression is not valid IN THIS CONTEXT, e.g. an attribute was selected
                }
            }

            if (!string.IsNullOrEmpty(Before))
            {
                try
                {
                    if (Before == "self")
                    {
                        element.ParentNode.InsertBefore(child, element);

                        return;
                    }

                    var node = element.SelectSingleNode(Before);

                    if (node != null)
                    {
                        element.InsertBefore(child, node);

                        return;
                    }
                }
                catch (XPathException e)
                {
                    var message = string.Format("'{0}' is not a valid XPath expression.", Before);
                    throw new TaskExecutionException(message, e);
                }
                catch (ArgumentException)
                {
                    // The XPath expression is not valid IN THIS CONTEXT, e.g. an attribute was selected
                }
            }

            element.AppendChild(child);
        }
コード例 #11
0
        private void CollectAntCodeCoverageForNode(string reportDirectory, string include, string exclude, XmlElement node, XmlDocument buildXml, XmlNode instrumentNode, string instrumentedClassesDirectory, string dataFile)
        {
            // add instrument node befor the test node.            
            var parentNode = node.ParentNode;
            parentNode.InsertBefore(instrumentNode, node);

            node.SetAttribute("fork", "true");
            _executionContext.Debug(StringUtil.Format(CodeCoverageConstants.SettingAttributeTemplate, "fork", "true", "test"));

            RemoveSysNodes(node);

            var coberturaCoverageElement = buildXml.CreateElement("sysproperty");
            coberturaCoverageElement.SetAttribute("key", "net.sourceforge.cobertura.datafile");
            coberturaCoverageElement.SetAttribute("file", dataFile);
            node.InsertBefore(coberturaCoverageElement, node.FirstChild);

            var instrumentElement = buildXml.CreateElement("classpath");
            instrumentElement.SetAttribute("location", instrumentedClassesDirectory);
            node.InsertAfter(instrumentElement, node.FirstChild);

            var classPathElement = buildXml.CreateElement("classpath");
            classPathElement.SetAttribute("refid", CodeCoverageConstants.CoberturaClassPathString);
            node.InsertAfter(classPathElement, node.LastChild);
        }
コード例 #12
0
ファイル: Instance.cs プロジェクト: plamikcho/xbrlpoc
        /// <summary>
        /// 
        /// </summary>
        /// <param name="fp"></param>
        /// <param name="parentEle"></param>
        protected void AddFootnoteResource( FootnoteProperty fp, XmlElement parentEle )
        {
            XmlElement resource = null;
            resource = this.xDoc.CreateElement(DocumentBase.XBRL_LINKBASE_PREFIX, FOOTNOTE_RESOURCE, DocumentBase.XBRL_LINKBASE_URL);

            XmlAttribute resAttr = xDoc.CreateAttribute( DocumentBase.XLINK_PREFIX, TYPE, DocumentBase.XLINK_URI );
            resAttr.Value = RESOURCE;
            resource.SetAttributeNode( resAttr );

            XmlAttribute resRoleAttr = xDoc.CreateAttribute( DocumentBase.XLINK_PREFIX, ROLE, DocumentBase.XLINK_URI );
            resRoleAttr.Value = FOOTNOTE_RESOURCE_ARCROLE;
            resource.SetAttributeNode( resRoleAttr );

            XmlAttribute labelAttr = xDoc.CreateAttribute( DocumentBase.XLINK_PREFIX, LABEL, DocumentBase.XLINK_URI );
            labelAttr.Value = fp.Id;
            resource.SetAttributeNode( labelAttr );

            XmlAttribute langAttr = xDoc.CreateAttribute(XML, LANG, DocumentBase.XBRL_INSTANCE_URL);
            langAttr.Value = fp.language;
            resource.SetAttributeNode( langAttr );

            try
            {
                resource.InnerXml = fp.markupData;
            }
            catch (Exception)
            {
                resource.InnerText = fp.markupData;
            }

            parentEle.AppendChild(resource);

            if ( writeComments )
            {
                XmlComment locComment = xDoc.CreateComment( TraceUtility.FormatStringResource( "XBRLParser.Info.InstanceDocMarkupAddress", fp.address ) );
                parentEle.InsertBefore(locComment, resource);
            }

            fp.HasBeenWritten = true;
        }
コード例 #13
0
ファイル: Instance.cs プロジェクト: plamikcho/xbrlpoc
        private void AddFootnoteLocator(MarkupProperty mp, XmlElement parentElement)
        {
            XmlElement locator = null;
            locator = xDoc.CreateElement(DocumentBase.XBRL_LINKBASE_PREFIX, LOC, DocumentBase.XBRL_LINKBASE_URL);

            XmlAttribute typeAttr = xDoc.CreateAttribute( DocumentBase.XLINK_PREFIX, TYPE, DocumentBase.XLINK_URI );
            typeAttr.Value = LOCATOR;
            locator.SetAttributeNode( typeAttr );

            XmlAttribute hrefAttr = xDoc.CreateAttribute( DocumentBase.XLINK_PREFIX, HREF, DocumentBase.XLINK_URI );
            hrefAttr.Value = string.Format( HREF_FORMAT, string.Empty, mp.Id );
            locator.SetAttributeNode( hrefAttr );

            XmlAttribute labelAttr = xDoc.CreateAttribute( DocumentBase.XLINK_PREFIX, LABEL, DocumentBase.XLINK_URI );
            labelAttr.Value = string.Format( LABEL_FORMAT, mp.Id );
            locator.SetAttributeNode( labelAttr );

            parentElement.AppendChild(locator);

            if (writeComments && mp.xmlElement != null)
            {
                XmlComment locComment = xDoc.CreateComment( TraceUtility.FormatStringResource( "XBRLParser.Info.InstanceDocFootnoteMarkupAddress", mp.address, mp.xmlElement.Name ) );
                parentElement.InsertBefore(locComment, locator);
            }
        }