C# Class iTextSharp.xmp.impl.Utils

Utility functions for the XMPToolkit implementation. @since 06.06.2006
Inheritance: XmpConst
显示文件 Open project: nonorganic/dssnet

Public Properties

Property Type Description
UUID_LENGTH int

Public Methods

Method Description
EscapeXml ( string value, bool forAttribute, bool escapeWhitespaces ) : string

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 name ) : bool

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 name ) : bool

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 value ) : string

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.

Private Methods

Method Description
CheckUuidFormat ( string uuid ) : bool

Check some requirements for an UUID:

  • Length of the UUID is 32
  • The Delimiter count is 4 and all the 4 delimiter are on their right position (8,13,18,23)

InitCharTables ( ) : void

Initializes the char tables for the chars 0x00-0xFF for later use, according to the XML 1.1 specification http://www.w3.org/TR/xml11

IsControlChar ( char c ) : bool
IsInternalProperty ( string schema, string prop ) : bool
IsNameChar ( char ch ) : bool

Simple check if a character is a valid XML name char (every char except the first one), according to the XML Spec 1.1: http://www.w3.org/TR/xml11/#NT-NameChar

IsNameStartChar ( char ch ) : bool

Simple check if a character is a valid XML start name char. All characters according to the XML Spec 1.1 are accepted: http://www.w3.org/TR/xml11/#NT-NameStartChar

RemoveControlChars ( string value ) : string

Replaces the ASCII control chars with a space.

SplitNameAndValue ( string selector ) : string[]

Split the name and value parts for field and qualifier selectors:

  • [qualName="value"] - An element in an array of structs, chosen by a field value.
  • [?qualName="value"] - An element in an array, chosen by a qualifier value.
The value portion is a string quoted by ''' or '"'. The value may contain any character including a doubled quoting character. The value may be empty. Note: It is assumed that the expression is formal correct

Utils ( ) : System.Text

init char tables

Method Details

EscapeXml() public static method

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.
public static EscapeXml ( string value, bool forAttribute, bool escapeWhitespaces ) : string
value string a string
forAttribute bool flag if string is attribute value (need to additional escape quotes)
escapeWhitespaces bool Decides if LF, CR and TAB are escaped.
return string

IsXmlName() public static method

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.
public static IsXmlName ( string name ) : bool
name string an XML Name
return bool

IsXmlNameNs() public static method

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.
public static IsXmlNameNs ( string name ) : bool
name string the value to check
return bool

NormalizeLangValue() public static method

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.
public static NormalizeLangValue ( string value ) : string
value string /// raw value
return string

Property Details

UUID_LENGTH public_oe static_oe property

length of a UUID
public static int UUID_LENGTH
return int