See METHODS in XML::Compile
See Constructors in XML::Compile
Details about many name-spaces can be organized with only a single schema object (actually, the data is administered in an internal XML::Compile::Schema::NameSpaces object)
The initial information is extracted from the $xmldata source. The $xmldata can be anything what is acceptable by importDefinitions(), which is everything accepted by dataToXML() or an ARRAY of those things. You may also add any OPTION accepted by addSchemas() to guide the understanding of the schema. When no $xmldata is provided, you can add it later with importDefinitions()
You can specify the hooks before you define the schemas the hooks work on: all schema information and all hooks are only used when the readers and writers get compiled.
Option | Defined in | Default |
---|---|---|
block_namespace | [] | |
hook |
| |
hooks | [] | |
ignore_unused_tags | <false> | |
key_rewrite | [] | |
parser_options | XML::Compile | <many> |
schema_dirs | XML::Compile |
|
typemap | {} |
A $hook is specified as HASH or a LIST of PAIRS. When undef
, this call
is ignored. See addHooks() and Schema hooks below.
Add multiple hooks at once. These must all be HASHes. See Schema hooks
and addHook(). undef
values are ignored.
Add new rewrite rules to the existing list (initially provided with new(key_rewrite)). The whole list of rewrite rules is returned.
PREFIXED
rules will be applied first. Special care is taken that the
prefix will not be called twice. The last added set of rewrite rules
will be applied first. See Key rewrite.
Collect all the schemas defined in the $xml data. The $xml parameter must be a XML::LibXML node, therefore it is advised to use importDefinitions(), which has a much more flexible way to specify the data.
When the object extends XML::Compile::Cache, the prefixes declared on the schema element will be taken as default prefixes.
Option | Default |
---|---|
attribute_form_default | <undef> |
element_form_default | <undef> |
filename |
|
source |
|
target_namespace | <undef> |
Synonym for addTypemap().
Add new XML-Perl type relations. See Typemaps.
Block all references to a $ns or full $type, as if they do not appear in the schema. Specially useful if the schema includes references to old (deprecated) versions of itself which are not being used. It can also be used to block inclusion of huge structures which are not used, for increased compile performance, or to avoid buggy constructs.
These values can also be passed with new(block_namespace) and compile(block_namespace).
Returns the LIST of defined hooks (as HASHes). [1.36] When an action parameter is provided, it will only return a list with hooks added with that action value or no action at all.
Pass a XML::Compile::Schema object, or extensions like XML::Compile::Cache, to be used as definitions as well. First, elements are looked-up in the current schema definition object. If not found the other provided $schema objects are checked in the order as they were added.
Searches for definitions do not recurse into schemas which are used by the used schema.
my $wsdl = XML::Compile::WSDL->new($wsdl); my $geo = Geo::GML->new(version => '3.2.1'); # both $wsdl and $geo extend XML::Compile::Schema $wsdl->useSchema($geo);
Translate the specified ELEMENT (found in one of the read schemas) into
a CODE reference which is able to translate between XML-text and a HASH.
When the $type is undef
, an empty LIST is returned.
The indicated $type is the starting-point for processing in the
data-structure, a toplevel element or attribute name. The name must
be specified in {url}name
format, there the url is the name-space.
An alternative is the url#id
which refers to an element or type with
the specific id
attribute value.
When a READER is created, a CODE reference is returned which needs to be called with XML, as accepted by XML::Compile::dataToXML(). Returned is a nested HASH structure which contains the data from contained in the XML. The transformation rules are explained below.
When a WRITER is created, a CODE reference is returned which needs to be called with an XML::LibXML::Document object and a HASH, and returns a XML::LibXML::Node.
Many %options below are explained in more detailed in the manual-page XML::Compile::Translate, which implements the compilation.
Option | Default |
---|---|
abstract_types | 'ERROR' |
any_attribute |
|
any_element |
|
any_type | <returns string or node> |
attributes_qualified | <undef> |
block_namespace | [] |
check_occurs | <true> |
check_values | <true> |
default_values | <depends on backend> |
elements_qualified | <undef> |
hook |
|
hooks |
|
ignore_facets | <false> |
ignore_unused_tags | <false> |
include_namespaces | <true> |
interpret_nillable_as_optional | <false> |
json_friendly | <false> |
key_rewrite | [] |
mixed_elements | 'ATTRIBUTES' |
namespace_reset | <false> |
output_namespaces | undef |
path | <expanded name of type> |
permit_href | <false> |
prefixes | {} |
sloppy_floats | <false> |
sloppy_integers | <false> |
typemap | {} |
use_default_namespace | <false> |
validation | <true> |
xsi_type | {} |
xsi_type_everywhere | <false> |
This is a hack to be able to process components of SOAP messages, which are only specified by type. Probably (hopefully) you do no need it. All %options are the same as for compile().
Schema's can be horribly complex and unreadible. Therefore, this template method can be called to create an example which demonstrates how data of the specified $element shown as XML or Perl is organized in practice.
The 'TREE' template returns the intermediate parse tree, which gets formatted into the XML or Perl example. This is not a very stable interface: it may change without much notice.
Some %options are explained in XML::Compile::Translate. There are some extra %options defined for the final output process.
The templates produced are not always correct. Please contribute improvements: read and understand the comments in the text.
Option | Default |
---|---|
abstract_types | 'ERROR' |
attributes_qualified | <undef> |
elements_qualified | <undef> |
include_namespaces | <true> |
indent | " " |
key_rewrite | [] |
show_comments |
|
skip_header | <false> |
Returns true when the $exttype extends the $basetype. See XML::Compile::Schema::NameSpaces::doesExtend()
List all elements, defined by all schemas sorted alphabetically.
Import (include) the schema information included in the $xmldata. The $xmldata must be acceptable for dataToXML(). The resulting node and all the %options are passed to addSchemas(). The schema node does not need to be the top element: any schema node found in the data will be decoded.
Returned is a list of XML::Compile::Schema::Instance objects, for each processed schema component.
If your program imports the same string or file definitions multiple times, it will re-use the schema information from the first import. This removal of dupplications will not work for open files or pre-parsed XML structures.
As an extension to the handling dataToXML() provides, you can specify an
ARRAY of things which are acceptable to dataToXML
. This way, you can
specify multiple resources at once, each of which will be processed with
the same %options.
Option | Default |
---|---|
details | <from XMLDATA> |
my $schema = XML::Compile::Schema->new; $schema->importDefinitions('my-spec.xsd'); my $other = "<schema>...</schema>"; # use 'HERE' documents! my @specs = ('my-spec.xsd', 'types.xsd', $other); $schema->importDefinitions(\@specs, @options);
Returns the XML::Compile::Schema::NameSpaces object which is used to collect schemas.
Print all the elements which are defined in the schemas to the $fh (by default the selected handle). %options are passed to XML::Compile::Schema::NameSpaces::printIndex() and XML::Compile::Schema::Instance::printIndex().
List all types, defined by all schemas sorted alphabetically.