Class Utils
Utility functions for the XMPToolkit implementation.
public sealed class Utils : XMPConst
- Inheritance
-
Utils
- Inherited Members
Fields
UUID_LENGTH
length of a UUID
public const int UUID_LENGTH = 36
Field Value
UUID_SEGMENT_COUNT
segments of a UUID
public const int UUID_SEGMENT_COUNT = 4
Field Value
Methods
EscapeXML(string, bool, bool)
Serializes the node value in XML encoding.
public static string EscapeXML(string value, bool forAttribute, bool escapeWhitespaces)
Parameters
value
stringa string
forAttribute
boolflag if string is attribute value (need to additional escape quotes)
escapeWhitespaces
boolDecides if LF, CR and TAB are escaped.
Returns
- string
Returns the value ready for XML output.
Remarks
Serializes the node value in XML encoding. Its used for tag bodies and
attributes.
Note: The attribute is always limited by quotes,
thats why '
is never serialized.
Note: Control chars are written unescaped, but if the user uses others than tab, LF
and CR the resulting XML will become invalid.
IsXMLName(string)
Simple check for valid XMLNames.
public static bool IsXMLName(string name)
Parameters
name
stringan XML Name
Returns
- bool
Return
true
if the name is correct.
Remarks
Simple check for valid XMLNames. Within ASCII range
":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6]
are accepted, above all characters (which is not entirely
correct according to the XML Spec.
IsXMLNameNS(string)
Checks if the value is a legal "unqualified" XML name, as defined in the XML Namespaces proposed recommendation.
public static bool IsXMLNameNS(string name)
Parameters
name
stringthe value to check
Returns
- bool
Returns true if the name is a valid "unqualified" XML name.
Remarks
Checks if the value is a legal "unqualified" XML name, as defined in the XML Namespaces proposed recommendation. These are XML names, except that they must not contain a colon.
NormalizeLangValue(string)
Normalize an xml:lang value so that comparisons are effectively case insensitive as required by RFC 3066 (which superceeds RFC 1766).
public static string NormalizeLangValue(string value)
Parameters
value
stringraw value
Returns
- string
Returns the normalized value.
Remarks
Normalize an xml:lang value so that comparisons are effectively case insensitive as required by RFC 3066 (which superceeds RFC 1766). The normalization rules:
- The primary subtag is lower case, the suggested practice of ISO 639.
- All 2 letter secondary subtags are upper case, the suggested practice of ISO 3166.
- All other subtags are lower case.