C# Class iTextSharp.xmp.XmpPathFactory

Utility services for the metadata object. It has only public static functions, you cannot create an object. These are all functions that layer cleanly on top of the core XMP toolkit.

These functions provide support for composing path expressions to deeply nested properties. The functions XMPMeta such as getProperty(), getArrayItem() and getStructField() provide easy access to top level simple properties, items in top level arrays, and fields of top level structs. They do not provide convenient access to more complex things like fields several levels deep in a complex struct, or fields within an array of structs, or items of an array that is a field of a struct. These functions can also be used to compose paths to top level array items or struct fields so that you can use the binary accessors like getPropertyAsInteger().

You can use these functions is to compose a complete path expression, or all but the last component. Suppose you have a property that is an array of integers within a struct. You can access one of the array items like this:

 String path = XMPPathFactory.composeStructFieldPath (schemaNs, "Struct", fieldNs, "Array"); String path += XMPPathFactory.composeArrayItemPath (schemaNs, "Array" index); PropertyInteger result = xmpObj.getPropertyAsInteger(schemaNs, path); 
You could also use this code if you want the string form of the integer:
 String path = XMPPathFactory.composeStructFieldPath (schemaNs, "Struct", fieldNs, "Array"); PropertyText xmpObj.getArrayItem (schemaNs, path, index); 

Note: It might look confusing that the schemaNs is passed in all of the calls above. This is because the XMP toolkit keeps the top level "schema" namespace separate from the rest of the path expression. Note: These methods are much simpler than in the C++-API, they don't check the given path or array indices. @since 25.01.2006

Mostrar archivo Open project: nonorganic/dssnet

Public Methods

Method Description
ComposeArrayItemPath ( string arrayName, int itemIndex ) : string

Compose the path expression for an item in an array.

ComposeFieldSelector ( string arrayName, string fieldNs, string fieldName, string fieldValue ) : string

Compose the path expression to select an alternate item by a field's value. The path syntax allows two forms of "content addressing" that may be used to select an item in an array of alternatives. The form used in ComposeFieldSelector lets you select an item in an array of structs based on the value of one of the fields in the structs. The other form of content addressing is shown in ComposeLangSelector. For example, consider a simple struct that has two fields, the name of a city and the URI of an FTP site in that city. Use this to create an array of download alternatives. You can show the user a popup built from the values of the city fields. You can then get the corresponding URI as follows:

 String path = composeFieldSelector ( schemaNs, "Downloads", fieldNs,  "City", chosenCity );  XMPProperty prop = xmpObj.getStructField ( schemaNs, path, fieldNs, "URI" ); 

ComposeLangSelector ( string arrayName, string langName ) : string

Compose the path expression to select an alternate item by language. The path syntax allows two forms of "content addressing" that may be used to select an item in an array of alternatives. The form used in ComposeLangSelector lets you select an item in an alt-text array based on the value of its xml:lang qualifier. The other form of content addressing is shown in ComposeFieldSelector. \note ComposeLangSelector does not supplant SetLocalizedText or GetLocalizedText. They should generally be used, as they provide extra logic to choose the appropriate language and maintain consistency with the 'x-default' value. ComposeLangSelector gives you an path expression that is explicitly and only for the language given in the langName parameter.

ComposeQualifierPath ( string qualNs, string qualName ) : string

Compose the path expression for a qualifier.

ComposeStructFieldPath ( string fieldNs, string fieldName ) : string

Compose the path expression for a field in a struct. The result can be added to the path of

Private Methods

Method Description
AssertFieldName ( string fieldName ) : void

ParameterAsserts that a struct field name is set.

AssertFieldNs ( string fieldNs ) : void

ParameterAsserts that a struct field namespace is set.

AssertQualName ( string qualName ) : void

ParameterAsserts that a qualifier name is set.

AssertQualNs ( string qualNs ) : void

ParameterAsserts that a qualifier namespace is set.

Method Details

ComposeArrayItemPath() public static method

Compose the path expression for an item in an array.
Throws exeption if index zero is used.
public static ComposeArrayItemPath ( string arrayName, int itemIndex ) : string
arrayName string The name of the array. May be a general path expression, must not be /// null or the empty string.
itemIndex int The index of the desired item. Arrays in XMP are indexed from 1. /// 0 and below means last array item and renders as [last()]. ///
return string

ComposeFieldSelector() public static method

Compose the path expression to select an alternate item by a field's value. The path syntax allows two forms of "content addressing" that may be used to select an item in an array of alternatives. The form used in ComposeFieldSelector lets you select an item in an array of structs based on the value of one of the fields in the structs. The other form of content addressing is shown in ComposeLangSelector. For example, consider a simple struct that has two fields, the name of a city and the URI of an FTP site in that city. Use this to create an array of download alternatives. You can show the user a popup built from the values of the city fields. You can then get the corresponding URI as follows:

 String path = composeFieldSelector ( schemaNs, "Downloads", fieldNs,  "City", chosenCity );  XMPProperty prop = xmpObj.getStructField ( schemaNs, path, fieldNs, "URI" ); 
Thrown if the path to create is not valid.
public static ComposeFieldSelector ( string arrayName, string fieldNs, string fieldName, string fieldValue ) : string
arrayName string The name of the array. May be a general path expression, must not be /// null or the empty string.
fieldNs string The namespace URI for the field used as the selector. Must not be /// null or the empty string.
fieldName string The name of the field used as the selector. Must be a simple XML name, must /// not be null or the empty string. It must be the name of a field that is /// itself simple.
fieldValue string The desired value of the field.
return string

ComposeLangSelector() public static method

Compose the path expression to select an alternate item by language. The path syntax allows two forms of "content addressing" that may be used to select an item in an array of alternatives. The form used in ComposeLangSelector lets you select an item in an alt-text array based on the value of its xml:lang qualifier. The other form of content addressing is shown in ComposeFieldSelector. \note ComposeLangSelector does not supplant SetLocalizedText or GetLocalizedText. They should generally be used, as they provide extra logic to choose the appropriate language and maintain consistency with the 'x-default' value. ComposeLangSelector gives you an path expression that is explicitly and only for the language given in the langName parameter.
public static ComposeLangSelector ( string arrayName, string langName ) : string
arrayName string /// The name of the array. May be a general path expression, must /// not be null or the empty string.
langName string /// The RFC 3066 code for the desired language.
return string

ComposeQualifierPath() public static method

Compose the path expression for a qualifier.
Thrown if the path to create is not valid.
public static ComposeQualifierPath ( string qualNs, string qualName ) : string
qualNs string The namespace URI for the qualifier. May be null or the empty /// string if the qualifier is in the XML empty namespace.
qualName string The name of the qualifier. Must be a simple XML name, must not be /// null or the empty string.
return string

ComposeStructFieldPath() public static method

Compose the path expression for a field in a struct. The result can be added to the path of
Thrown if the path to create is not valid.
public static ComposeStructFieldPath ( string fieldNs, string fieldName ) : string
fieldNs string The namespace URI for the field. Must not be null or the empty /// string.
fieldName string The name of the field. Must be a simple XML name, must not be /// null or the empty string.
return string