Modules Index

XML Schema Home

# XML::Schema::Wildcard

The module implements a wildcard to select or reject an XML element based on its namespace.

## Table of Contents

Synopsis |  |  |
Description |  |  |
Methods | : | new(), select(), process(), namespace(), accept() |

## Synopsis

    use XML::Schema::Wildcard;

    my $wildcard;

    $wildcard = XML::Schema::Wildcard->new( namespace => 'any' );
    $wildcard = XML::Schema::Wildcard->new( namespace => 'not' );

    # shorter form of above
    $wildcard = XML::Schema::Wildcard->new( any => 1 );
    $wildcard = XML::Schema::Wildcard->new( not => 1 );

    $wildcard = XML::Schema::Wildcard->new( {
        namespace => 'http://tt2.org/XML/Example.xml',
    } );

    $wildcard = XML::Schema::Wildcard->new( {
        namespace => [
            'http://tt2.org/XML/Example1.xml',
            'http://tt2.org/XML/Example2.xml',
        ],
    } );

    $wildcard = XML::Schema::Wildcard->new( {
        namespace => [ not => 'http://tt2.org/XML/Example.xml' ],
    } );

## Description

This module implements an object class for representing XML Schema wildcards. This provides for validation of elements based on their XML namespace component.

## Methods

- new( \%config )

  Constructor method called to create a new wildcard object. A list of '`key => value` ' pairs can be specified as command line arguments, or alternately, a hash reference can be passed which contains these configuration values. The method returns a newly instantiated object on success. On error it returns undef and sets an internal error message which can be retrieved by calling `error()` as a class method.

      # list of options
      my $card = XML::Schema::Wildcard->new( namespace => 'any' )
          || die XML::Schema::Wildcard->error();

      # hash ref of options
      my $card = XML::Schema::Wildcard->new( {
          namespace => 'any',
      } ) || die XML::Schema::Wildcard->error();

  The following configuration options may be specifed:

  Name | Typical Values | Description
  `namespace` | `'any'` `'not'` `'http://tt2.org/XML/...'` `[ not => 'http://tt2.org/XML/...' ]` | This option is used to specify which XML namespaces should be included or excluded by the wildcard. The value of '`any` ' indicates that any namespaces should be accepted along with elements that are not namespace qualified. The value of '`not` ' indicates that only those elements that are not namespace qualified should be accepted. Any other single value is treated as a namespace to which the element should be qualified. The option can also be specified as a reference to an array of namespaces. The first element in the list can be '`not` ' to indicate that it contains namespaces that the element should not match. Otherwise it is taken to be a list of namespaces, one of which the element must match.
  `any` | `1` | Alternate way of specifying `namespace => 'any'` .
  `not` | `1` | Alternate way of specifying `namespace => 'not'` .
  `process` | `'skip'` `'lax'` `'strict'` | This value controls the impact on assessment of the items allowed by wildcards. At present, this has no effect.

- select()
  Return the current selection criteria as one of the strings '`any` ', '`not` ' or '`one` '.

- process()
  Return the current assessment process as one of the strings '`skip` ', '`lax` ' or '`strict` '.

- namespace()
  Return a reference to a hash array of namespace that are accepted or rejected according to the selection criteria.

- accept( $value )
  Returns true (1) if the value is namespace qualified according to the wildcard selection criteria or false (0) if not.

Perl XML::Schema Documentation