Xml Class
Assembly: CodeEffects.Rule.Editor.dll
Namespace: CodeEffects.Rule.Editor.Utils
Summary
Provides helper methods and the schema namespaces for processing and managing Rule XML, Source XML and source labels. The class is static.
Syntax
public static partial class Xml
Fields
The namespaces below are constants. Rule XML and Source XML of the current version use schema version 7. The Rule Editor still loads Rule XML written in the namespaces of earlier versions, and always writes the current one.
RuleNamespace
Type: System.String (constant). Value: https://codeeffects.com/schemas/rule/7
The location of the Rule XML schema. It defines the rule namespace used by the current version of Code Effects.
SourceNamespace
Type: System.String (constant). Value: https://codeeffects.com/schemas/source/7
The location of the Source XML schema. It defines the source namespace used by the current version of Code Effects.
LabelsNamespace
Type: System.String (constant). Value: https://codeeffects.com/schemas/labels/7
The namespace of the source labels document, which gives a source's members their display names and descriptions in another language.
UiNamespace
Type: System.String (constant). Value: https://codeeffects.com/schemas/ui/7
The namespace and location of the XML schema for supporting attributes used by the rule schema in the current version of Code Effects. The empty rule document declares it with the ui prefix.
Methods
ApplySourceLabels
Returns: System.Xml.XmlDocument
Returns a copy of a Source XML document with the display names and descriptions of a source labels document written over the source's own. The original document is not changed. Use it to show a source's members in another language outside the Rule Editor, for example in your own lists of fields.
Parameters
- sourceXml (
System.Xml.XmlDocument) - A Source XML document.
- labels (
System.Xml.XmlDocument) - A source labels document.
GetEmptyRuleDocument
Returns: System.Xml.XmlDocument
Returns an empty XmlDocument containing an XML declaration and the root <codeeffects> element, which declares the RuleNamespace and the ui prefix of the UiNamespace. This document can serve as the starting point for a Rule XML when you generate XML files dynamically.
Parameters
GetEmptySourceDocument
Returns: System.Xml.XmlDocument
Returns an empty XmlDocument containing an XML declaration and the root <codeeffects> element, which declares the SourceNamespace. This document can serve as the starting point for a Source XML when you generate XML files dynamically.
Parameters
GetSourceLabelsDocument
Returns: System.Xml.XmlDocument
Returns a source labels document for a source: every source, field, in-rule method, action, parameter, reference property and enumeration value with its current display name and description as plain text. Save it, translate the values of the displayName, description and itemName attributes and of each parameter's description, and give the result to the Rule Editor's SourceLabelsXml or to the Rule Repository's Configuration.SourceLabelsXml. Keep the name, parameters, index, class and value attributes as they are: they identify the member each label belongs to. An empty value keeps the source's own text.
Overloads
GetSourceLabelsDocument(XmlDocument sourceXml) - For a Source XML document, such as the one Control.GetSourceXml() returns.
GetSourceLabelsDocument(Type sourceType, GetTypeDelegate typeResolver = null) - For a .NET class used as a source object.
GetSourceLabelsDocument(ISourceProvider sourceProvider) - For an Adaptive Source, from the Source XML its provider describes.
IsRuleValid
Returns: System.Boolean
Validates a Rule XML document against the schema of the current version and the validation logic of Code Effects. Returns true if the document is valid and false if it is not.
Parameters
- ruleXml (
System.Xml.XmlDocument) - A Rule XML document.
Example
using CodeEffects.Rule.Editor.Utils;
var doc = Xml.GetEmptyRuleDocument();
var root = doc.DocumentElement; // <codeeffects xmlns="https://codeeffects.com/schemas/rule/7" ...>
bool valid = Xml.IsRuleValid(doc);
// A source labels document to translate, from a source class
XmlDocument labels = Xml.GetSourceLabelsDocument(typeof(LoanApplication));
labels.Save(@"C:\Translations\labels.xml");