Treex::PML::Schema::Decl - implements PML schema type declaration


This is an abstract class from which all specific type declaration classes inherit.


This class inherits from Treex::PML::Schema::XMLNode.


$decl->get_schema ()
$decl->schema ()

Return Treex::PML::Schema the declaration belongs to.

$decl->get_schema ()

Same as $decl->schema().

$decl->get_decl_type ()

Return the type of declaration as an integer constant (see "CONSTANTS" in Treex::PML::Schema).

$decl->get_decl_type_str ()

Return the type of declaration as string; one of: type, root, structure, container, sequence, list, alt, cdata, choice, constant, attribute, member, element.

$decl->is_atomic ()

Return 1 if the declaration is of atomic type (cdata, choice, constant), 0 if it is a structured type (structure, container, sequence, list, alt), or undef, if it is an auxiliary declaration (root, type, attribute, member, element).

$decl->get_content_decl ()

For declarations with content (type, root, container, list, alt, attribute, member, element), return the content declaration; return undef for other declarations. This method transparently resolves references to named types.

$decl->get_knit_content_decl ()

If the data type has a role '#KNIT', return a type declaration for the knitted content (Note: PML 1.1.2 allows role '#KNIT' role on list, element, and member declarations, but element knitting is not currenlty implemented). Otherwise return the same as get_content_decl.

$decl->get_type_ref ()

If the declaration has content and the content is specified via a reference to a named type, return the name of the referred type. Otherwise return undef.

$decl->get_type_ref_decl ()

Retrun content declaration object (if any), but only if it is specified via a reference to a named type. In all other cases, return undef.

$decl->get_base_type_name ()

If the declaration is a nested (even deeply) part of a named type declaration, return the name of that named type.

$decl->get_parent_decl ()

If this declaration is nested, return its parent declaration.

$decl->get_decl_path ()

Return a cannonical attribute path leading to the declaration (starting either at a named type or the root type declaration).


If the declaration is associated with a role, return it.

$decl->find (attribute-path,noresolve)

Locate a nested declaration specified by attribute-path starting from the current type. See $schema->find_type_by_path for details about locating declarations.

$decl->find_role (role, opts)

Search declarations with a given role nested within this declaration. In scalar context, return the first declaration that matches, in array context return all such declarations.

The last argument opts can be used to pass some flags to the algorithm. Currently only the flag no_children is available. If true, then the function never recurses into content declaration of declarations with the role #CHILDNODES.

$decl->convert_from_hash (class, hash, schema, path)

Compatibility method building the schema object from a nested hash structure created by XML::Simple which was used in older implementations. This is useful for upgrading objects stored in old binary dumps. Not to be used directly.

$decl->get_normal_fields ()

This method is provided for convenience.

For a structure type, return names of its members, for a container return names of its attributes plus the name '#content' referring to the container's content value. In both cases, eliminate fields of values with role #CHILDNODES and strip a possible .rf suffix of fields with role #KNIT.

$decl->get_childnodes_decls ()

If the $decl has the role #NODE, this method locates a sub-declaration with role #CHILDNODES and returns a list of declarations of the child nodes.

$decl->get_attribute_paths (\%opts)

Return attribute paths leading from this declaration to all (possibly deeply) nested declarations of atomic type. This method is an alias for


See Treex::PML::Schema for details.

$decl->get_paths_to_atoms (\%opts)

Same as


See Treex::PML::Schema for details.


See validate_object() method of Treex::PML::Schema.

$decl->for_each_decl (sub{ ... })

This method traverses all nested sub-declarations and calls a given subroutine passing the sub-declaration object as a parameter.

$decl->write ({option => value})

This method serializes a declaration to XML. See Treex::PML::Schema->write for details and Treex::PML::Schema::XMLNode->write for implementation.


Treex::PML::Schema, Treex::PML::Schema::XMLNode


Copyright (C) 2008-2010 by Petr Pajas

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.


None reported... yet.