C# Класс SIL.Utils.XmlUtils

Summary description for XmlUtils.
Показать файл Открыть проект

Открытые методы

Метод Описание
AppendAttribute ( XmlNode parent, string attrName, string attrVal ) : void

Append an attribute with the specified name and value to parent.

AppendElement ( XmlNode parent, string elementName ) : XmlElement

Append an attribute with the specified name and value to parent.

CloneNodeWithDocument ( XmlNode node ) : XmlNode

return the deep clone of the given node, in a clone of its document context.

CreateTransform ( string xslName, string assemblyName ) : XslCompiledTransform
DecodeXml ( string sInput ) : string

Convert an encoded string (safe XML) into plain text.

DecodeXmlAttribute ( string sInput ) : string

Convert an encoded attribute string into plain text.

FindIndexOfMatchingNode ( IEnumerable nodes, XmlNode target ) : int

Find the index of the node in nodes that 'matches' the target node. Return -1 if not found.

FindNode ( XmlNode node, string name ) : XmlNode

Return the node that has the desired 'name', either the input node or a decendent.

GetAttributeValue ( XmlNode node, string attrName ) : string

Get an optional attribute value from an XmlNode.

GetAttributeValue ( XmlNode node, string attrName, string defaultValue ) : string

Deprecated: use GetOptionalAttributeValue instead.

GetBooleanAttributeValue ( XmlNode node, string attrName ) : bool

Returns true if value of attrName is 'true' or 'yes' (case ignored)

GetBooleanAttributeValue ( string sValue ) : bool

Returns true if sValue is 'true' or 'yes' (case ignored)

GetFirstNonCommentChild ( XmlNode node ) : XmlNode

Return the first child of the node that is not a comment (or null).

GetLocalizedAttributeValue ( SIL.Utils.StringTable tbl, XmlNode node, string attrName, string defaultString ) : string

Get an optional attribute value from an XmlNode, and look up its localized value in the given StringTable.

GetMandatoryIntegerAttributeValue ( XmlNode node, string attrName ) : int

Returns a integer obtained from the (mandatory) attribute named.

GetMandatoryIntegerListAttributeValue ( XmlNode node, string attrName ) : int[]

Retrieve an array, given an attribute consisting of a comma-separated list of integers

GetMandatoryUIntegerListAttributeValue ( XmlNode node, string attrName ) : uint[]

Retrieve an array, given an attribute consisting of a comma-separated list of integers

GetManditoryAttributeValue ( XmlNode node, string attrName ) : string

Get an obligatory attribute value.

GetOptionalAttributeValue ( XmlNode node, string attrName ) : string

Get an optional attribute value from an XmlNode.

GetOptionalAttributeValue ( XmlNode node, string attrName, string defaultString ) : string

Get an optional attribute value from an XmlNode.

GetOptionalBooleanAttributeValue ( XmlNode node, string attrName, bool defaultValue ) : bool

Get an optional attribute value from an XmlNode.

GetOptionalIntegerValue ( XmlNode node, string attrName, int defaultVal ) : int

Return an optional integer attribute value, or if not found, the default value.

GetStaticMethod ( XmlNode node, string sAssemblyAttr, string sClassAttr, string sMethodName, Type &typeFound ) : MethodInfo

Utility function to find a methodInfo for the named method. It is a static method of the class specified in the EditRowClass of the EditRowAssembly.

GetXPathInDocument ( XmlNode node ) : string

build an xpath to the given node in its document.

MakeIntegerListValue ( int vals ) : string

Make a value suitable for GetMandatoryIntegerListAttributeValue to parse.

MakeListValue ( List vals ) : string

Make a comma-separated list of the ToStrings of the values in the list.

MakeListValue ( List vals ) : string

Make a comma-separated list of the ToStrings of the values in the list.

MakeSafeXml ( string sInput ) : string

Fix the string to be safe in a text region of XML.

MakeSafeXmlAttribute ( string sInput ) : string

Fix the string to be safe in an attribute value of XML.

NodesMatch ( XmlNode node1, XmlNode node2 ) : bool

Return true if the two nodes match. Corresponding children should match, and corresponding attributes (though not necessarily in the same order). The nodes are expected to be actually XmlElements; not tested for other cases. Comments do not affect equality.

SerializeObjectToXmlString ( object objToSerialize ) : string

Try to serialize the given object into an xml string

SetAttribute ( XmlNode parent, string attrName, string attrVal ) : void

Change the value of the specified attribute, appending it if not already present.

VisitAttributes ( XmlNode input, IAttributeVisitor visitor ) : bool

Allow the visitor to 'visit' each attribute in the input XmlNode.

Защищенные методы

Метод Описание
MakeGetStaticMethodErrorMessage ( string sMainMsg, string sContext ) : string

Приватные методы

Метод Описание
ConvertMultiparagraphToSafeXml ( string sInput ) : string
DeserializeXmlString ( string xml, Type targetType ) : object
GetIndexAmongSiblings ( XmlNode node ) : int
GetStaticMethod ( string sAssemblyName, string sClassName, string sMethodName, string sContext, Type &typeFound ) : MethodInfo

Описание методов

AppendAttribute() публичный статический Метод

Append an attribute with the specified name and value to parent.
public static AppendAttribute ( XmlNode parent, string attrName, string attrVal ) : void
parent System.Xml.XmlNode
attrName string
attrVal string
Результат void

AppendElement() публичный статический Метод

Append an attribute with the specified name and value to parent.
public static AppendElement ( XmlNode parent, string elementName ) : XmlElement
parent System.Xml.XmlNode
elementName string
Результат System.Xml.XmlElement

CloneNodeWithDocument() публичный статический Метод

return the deep clone of the given node, in a clone of its document context.
public static CloneNodeWithDocument ( XmlNode node ) : XmlNode
node System.Xml.XmlNode
Результат System.Xml.XmlNode

CreateTransform() публичный статический Метод

public static CreateTransform ( string xslName, string assemblyName ) : XslCompiledTransform
xslName string
assemblyName string
Результат System.Xml.Xsl.XslCompiledTransform

DecodeXml() публичный статический Метод

Convert an encoded string (safe XML) into plain text.
public static DecodeXml ( string sInput ) : string
sInput string
Результат string

DecodeXmlAttribute() публичный статический Метод

Convert an encoded attribute string into plain text.
public static DecodeXmlAttribute ( string sInput ) : string
sInput string
Результат string

FindIndexOfMatchingNode() публичный статический Метод

Find the index of the node in nodes that 'matches' the target node. Return -1 if not found.
public static FindIndexOfMatchingNode ( IEnumerable nodes, XmlNode target ) : int
nodes IEnumerable The nodes.
target System.Xml.XmlNode The target.
Результат int

FindNode() публичный статический Метод

Return the node that has the desired 'name', either the input node or a decendent.
public static FindNode ( XmlNode node, string name ) : XmlNode
node System.Xml.XmlNode The XmlNode to look in.
name string The XmlNode name to find.
Результат System.Xml.XmlNode

GetAttributeValue() публичный статический Метод

Get an optional attribute value from an XmlNode.
public static GetAttributeValue ( XmlNode node, string attrName ) : string
node System.Xml.XmlNode The XmlNode to look in.
attrName string The attribute to find.
Результат string

GetAttributeValue() публичный статический Метод

Deprecated: use GetOptionalAttributeValue instead.
public static GetAttributeValue ( XmlNode node, string attrName, string defaultValue ) : string
node System.Xml.XmlNode
attrName string
defaultValue string
Результат string

GetBooleanAttributeValue() публичный статический Метод

Returns true if value of attrName is 'true' or 'yes' (case ignored)
public static GetBooleanAttributeValue ( XmlNode node, string attrName ) : bool
node System.Xml.XmlNode The XmlNode to look in.
attrName string The optional attribute to find.
Результат bool

GetBooleanAttributeValue() публичный статический Метод

Returns true if sValue is 'true' or 'yes' (case ignored)
public static GetBooleanAttributeValue ( string sValue ) : bool
sValue string
Результат bool

GetFirstNonCommentChild() публичный статический Метод

Return the first child of the node that is not a comment (or null).
public static GetFirstNonCommentChild ( XmlNode node ) : XmlNode
node System.Xml.XmlNode
Результат System.Xml.XmlNode

GetLocalizedAttributeValue() публичный статический Метод

Get an optional attribute value from an XmlNode, and look up its localized value in the given StringTable.
public static GetLocalizedAttributeValue ( SIL.Utils.StringTable tbl, XmlNode node, string attrName, string defaultString ) : string
tbl SIL.Utils.StringTable
node System.Xml.XmlNode
attrName string
defaultString string
Результат string

GetMandatoryIntegerAttributeValue() публичный статический Метод

Returns a integer obtained from the (mandatory) attribute named.
public static GetMandatoryIntegerAttributeValue ( XmlNode node, string attrName ) : int
node System.Xml.XmlNode The XmlNode to look in.
attrName string The mandatory attribute to find.
Результат int

GetMandatoryIntegerListAttributeValue() публичный статический Метод

Retrieve an array, given an attribute consisting of a comma-separated list of integers
public static GetMandatoryIntegerListAttributeValue ( XmlNode node, string attrName ) : int[]
node System.Xml.XmlNode
attrName string
Результат int[]

GetMandatoryUIntegerListAttributeValue() публичный статический Метод

Retrieve an array, given an attribute consisting of a comma-separated list of integers
public static GetMandatoryUIntegerListAttributeValue ( XmlNode node, string attrName ) : uint[]
node System.Xml.XmlNode
attrName string
Результат uint[]

GetManditoryAttributeValue() публичный статический Метод

Get an obligatory attribute value.
/// Thrown when the value is not found in the node. ///
public static GetManditoryAttributeValue ( XmlNode node, string attrName ) : string
node System.Xml.XmlNode The XmlNode to look in.
attrName string The required attribute to find.
Результат string

GetOptionalAttributeValue() публичный статический Метод

Get an optional attribute value from an XmlNode.
public static GetOptionalAttributeValue ( XmlNode node, string attrName ) : string
node System.Xml.XmlNode The XmlNode to look in.
attrName string The attribute to find.
Результат string

GetOptionalAttributeValue() публичный статический Метод

Get an optional attribute value from an XmlNode.
public static GetOptionalAttributeValue ( XmlNode node, string attrName, string defaultString ) : string
node System.Xml.XmlNode The XmlNode to look in.
attrName string The attribute to find.
defaultString string
Результат string

GetOptionalBooleanAttributeValue() публичный статический Метод

Get an optional attribute value from an XmlNode.
public static GetOptionalBooleanAttributeValue ( XmlNode node, string attrName, bool defaultValue ) : bool
node System.Xml.XmlNode The XmlNode to look in.
attrName string The attribute to find.
defaultValue bool
Результат bool

GetOptionalIntegerValue() публичный статический Метод

Return an optional integer attribute value, or if not found, the default value.
public static GetOptionalIntegerValue ( XmlNode node, string attrName, int defaultVal ) : int
node System.Xml.XmlNode
attrName string
defaultVal int
Результат int

GetStaticMethod() публичный статический Метод

Utility function to find a methodInfo for the named method. It is a static method of the class specified in the EditRowClass of the EditRowAssembly.
public static GetStaticMethod ( XmlNode node, string sAssemblyAttr, string sClassAttr, string sMethodName, Type &typeFound ) : MethodInfo
node System.Xml.XmlNode
sAssemblyAttr string
sClassAttr string
sMethodName string
typeFound System.Type
Результат System.Reflection.MethodInfo

GetXPathInDocument() публичный статический Метод

build an xpath to the given node in its document.
public static GetXPathInDocument ( XmlNode node ) : string
node System.Xml.XmlNode
Результат string

MakeGetStaticMethodErrorMessage() статический защищенный Метод

static protected MakeGetStaticMethodErrorMessage ( string sMainMsg, string sContext ) : string
sMainMsg string
sContext string
Результат string

MakeIntegerListValue() публичный статический Метод

Make a value suitable for GetMandatoryIntegerListAttributeValue to parse.
public static MakeIntegerListValue ( int vals ) : string
vals int
Результат string

MakeListValue() публичный статический Метод

Make a comma-separated list of the ToStrings of the values in the list.
public static MakeListValue ( List vals ) : string
vals List
Результат string

MakeListValue() публичный статический Метод

Make a comma-separated list of the ToStrings of the values in the list.
public static MakeListValue ( List vals ) : string
vals List
Результат string

MakeSafeXml() публичный статический Метод

Fix the string to be safe in a text region of XML.
public static MakeSafeXml ( string sInput ) : string
sInput string
Результат string

MakeSafeXmlAttribute() публичный статический Метод

Fix the string to be safe in an attribute value of XML.
public static MakeSafeXmlAttribute ( string sInput ) : string
sInput string
Результат string

NodesMatch() статический публичный Метод

Return true if the two nodes match. Corresponding children should match, and corresponding attributes (though not necessarily in the same order). The nodes are expected to be actually XmlElements; not tested for other cases. Comments do not affect equality.
static public NodesMatch ( XmlNode node1, XmlNode node2 ) : bool
node1 System.Xml.XmlNode
node2 System.Xml.XmlNode
Результат bool

SerializeObjectToXmlString() публичный статический Метод

Try to serialize the given object into an xml string
public static SerializeObjectToXmlString ( object objToSerialize ) : string
objToSerialize object
Результат string

SetAttribute() публичный статический Метод

Change the value of the specified attribute, appending it if not already present.
public static SetAttribute ( XmlNode parent, string attrName, string attrVal ) : void
parent System.Xml.XmlNode
attrName string
attrVal string
Результат void

VisitAttributes() публичный статический Метод

Allow the visitor to 'visit' each attribute in the input XmlNode.
public static VisitAttributes ( XmlNode input, IAttributeVisitor visitor ) : bool
input System.Xml.XmlNode
visitor IAttributeVisitor
Результат bool