go to post Purushothaman T · May 24, 2021 Hi Marc, Thanks for your suggestion. I have written the below piece, to remove the individual rule node, as per my requirement.But , after removing, to copy that back to rule class, it's not reflecting , if i save and compile the rule. What am i missing here ? DelIndRule(RuleId) [tXDataID,tMyRuleClassName,SQLCODE] public { set tMyRuleClassName="SJHSOCAL.Rule.TestRule" &SQL(select %id into :tXDataID from %Dictionary.XDataDefinition where parent = :tMyRuleClassName and Name='RuleDefinition') if (SQLCODE > 0) { // Query returned no results. Do some error handling quit } Write "tXDataID : "_tXDataID,! set tRuleDefinition=##class(%Dictionary.XDataDefinition).%OpenId(tXDataID) Write "tRuleDefinition : "_tRuleDefinition,! /* This stream contains the raw XML of the RuleDefinition. It looks like this: <ruleDefinition alias="" context="EnsLib.HL7.MsgRouter.RoutingEngine" production="TESTINGPKG.FoundationProduction"> <ruleSet name="" effectiveBegin="" effectiveEnd=""> <rule name="" disabled ="true"> <when condition="1"> <send transform="" target="HL7.File.Out"/> <return/> </when> </rule> </ruleSet> </ruleDefinition> */ set tRuleDefinitionXMLStream=##class(%Stream.GlobalCharacter).%New() do tRuleDefinitionXMLStream.CopyFrom(tRuleDefinition.Data) set reader=##class(%XML.Reader).%New() set status=reader.OpenStream(tRuleDefinitionXMLStream) if $$$ISERR(status) {do $System.Status.DisplayError(status) quit status} #dim document as %XML.Document #dim node as %XML.Node set document=reader.Document Write document.CountNamespace()_"document : "_document,! Set node = document.GetDocumentElement() Write "NodeDocElement"_node,! Write document.GetDocumentNode(),! //Set node = document.GetNode(i) //Write "node : "_node,! Set nodeName = node.LocalName W "nodeName : "_nodeName,! Do node.MoveToFirstChild(1) Do node.MoveToFirstChild(1) For i=1:1 { Set nodeName = node.LocalName W "nodeName : "_nodeName,! If (nodeName = "rule") { W i_" : inside rule tag : "_node.GetAttributeValue("name"),! //Get Node Attributes, check disable status If (i=RuleId) { If (node.GetAttributeValue("disabled")="true") { //Remove the node W "Inside Remove node",! //If remove successfull , move to child node, since the control will go back to parent node. // 1 childnode Do node.Remove() W "after Remove : "_node.LocalName,! If 1 { Do node.MoveToFirstChild(1) // move i number of sibiling Set i=i-1 For j=1:1:i-1 { Do node.MoveToNextSibling(1) } W "after moving to Rule : "_node.LocalName,! } } } //Write node.MoveToNextSibling(1),! Quit:node.MoveToNextSibling(1)=0 } Else { Quit } } // Ok, done making changes to the stream //Write tRuleDefinitionXMLStream.%Save() // Copy the changed XML back into the RuleDefinition do tRuleDefinition.Data.CopyFrom(tRuleDefinitionXMLStream) // Save the changees to the rule definition XData set tSC=tRuleDefinition.%Save() // Check if tSC indicates an error and do something about it if $$$ISERR(tSC) { // Do some error handling W "Save status"_tSC,! } // Recompile the rule class set tSC=$System.OBJ.Compile(tMyRuleClassName,"cuk",.errorlog,1) // Check if tSC indicates an error and do something about it if $$$ISERR(tSC) { // Do some error handling W "Compile status"_tSC,! } }