Treex-PML

 view release on metacpan or  search on metacpan

lib/Treex/PML/Backend/CSTS/Csts2fs.pm  view on Meta::CPAN

                               my ($s,$data)=@_;
                               $data=~s/\s+/|/g;
                               &to_composed_node_attr($s,$data,'_','','src','MAIDREFS');
                             }],
           'x name' => [sub {
                          my ($s,$data)=@_;
                          $s->{node}->{X_hide}='' if ($data eq 'TNT');
                        }]
          );

my %pcdata = (
              'source' => [\&to_node_attr,'','cstssource'],
              'mauth' => [sub {
                my ($s)=@_;
                if (($s->{elements}->[-3]||'') eq 'h') {
                  to_attr(@_,'following_root','','cstsmarkup');
                } else {
                  to_attr(@_,'following_root','','docmarkup');
                }
              }],
              'mdate' => [sub {

lib/Treex/PML/Backend/CSTS/Csts2fs.pm  view on Meta::CPAN

      $next_attributes=[];
    } elsif ($type eq ')') { # end element
      if (exists($end_tag{$data})) {
        my ($cb,@args)=@{ $end_tag{$data} };
        &$cb($state,$data,@args);
      }
      pop @elements;
      pop @attributes;
    } elsif ($type eq '-') { # character data
      my $element = $elements[-1];
      if (exists($pcdata{$element})) {
        my ($cb,@args)=@{ $pcdata{$element} };
        &$cb($state,unescape_data($data),@args);
      }
    } elsif ($type eq 'A') { # attribute of the next element
      my ($name,$value)= $data=~m{^(\S+) (?:IMPLIED$|(?:CDATA|NOTATION|ENTITY|TOKEN|ID) (.*))};
      push @$next_attributes,[$name,unescape_data($value)];
    } elsif ($type eq 'C') { # document is conforming
      $document_is_conforming=1;
    }
  }

lib/Treex/PML/Backend/FS.pm  view on Meta::CPAN

    }
    # allow ``alt'' values concatenated with |
    if ($fs->isList($attr)) {
      $m->{alt} = {
        -flat => 1,
        choice => [ $fs->listValues($attr) ]
      };
    } else {
      $m->{alt} = {
        -flat => 1,
        cdata => { format =>'any' }
      };
    }
  }
  return $mbr->{structure}{member};
}

sub read {
  my ($fileref,$fsfile) = @_;
  return unless ref($fsfile);
  my $FS = Treex::PML::Factory->createFSFormat();

lib/Treex/PML/Backend/TEIXML.pm  view on Meta::CPAN

sub xml_quote {
  local $_=$_[0];
  s/&/&/g;
  s/\'/'/g;
  s/\"/"/g;
  s/>/>/g;
  s/</&lt;/g;
  return $_;
}

sub xml_quote_pcdata {
  local $_=$_[0];
  s/&/&amp;/g;
  s/>/&gt;/g;
  s/</&lt;/g;
  return $_;
}


sub write {
  my ($output, $src_doc) = @_;

lib/Treex/PML/Backend/TEIXML.pm  view on Meta::CPAN

		      defined($node->{$_}) and 
		      !/^[sp]_|^(?:form|type|ord|dep)$/ }
	       $src_doc->FS->attributes()) {
	print $output " $_=\"".xml_quote($node->{$_})."\"";
      }
      print $output " dep=\"".
	xml_quote($node->parent->parent ? ($node->parent->{id}
					   || $node->parent->{AID} #grrrrrrrr!
					  ) : $rootdep )."\"";
      print $output ">";
      print $output xml_quote_pcdata($node->{form});
      print $output "</$type>\n";
    }

    print $output "</s>\n";
  }

  print $output "</p>\n";
  print $output "</body>\n";
  print $output "</text>\n";
}

lib/Treex/PML/Backend/TEIXML.pm  view on Meta::CPAN


sub entity_reference {
  my $self = $_[0];
  my $name = $_[1]->{Name};
  if ($self->{Node}->{tei_type} eq 'w' or
      $self->{Node}->{tei_type} eq 'c') {
    $self->{Node}->{form}.='&'.$name.';';
  }
}

sub start_cdata { # not much use for this
  my $self = shift;
  $self->{InCDATA} = 1;
}

sub end_cdata { # not much use for this
  my $self = shift;
  $self->{InCDATA} = 0;
}

sub comment {
  my $self = $_[0];
  my $data = $_[1];
  if ($self->{Node}) {
    $self->{Node}->{xml_comment}.='<!--'.$data.'-->';
  }

lib/Treex/PML/Backend/TrXML.pm  view on Meta::CPAN

sub xml_quote {
  local $_=$_[0];
  s/&/&amp;/g;
  s/'/&apos;/g;
  s/"/&quot;/g;
  s/>/&gt;/g;
  s/</&lt;/g;
  return $_;
}

sub xml_quote_pcdata {
  local $_=$_[0];
  s/&/&amp;/g;
  s/>/&gt;/g;
  s/</&lt;/g;
  return $_;
}

sub write {
  my ($output, $src_doc) = @_;

lib/Treex/PML/Backend/TrXML.pm  view on Meta::CPAN

  if ($hash->{Name} eq 'nd') {
    $self->{Node}=$self->{Node}->parent;
  } elsif ($hash->{Name} eq 'trees') {
    $self->{Node}=undef;
  }
}

sub entity_reference {
}

sub start_cdata { # not much use for this
  my $self = shift;
  $self->{InCDATA} = 1;
}

sub end_cdata { # not much use for this
  my $self = shift;
  $self->{InCDATA} = 0;
}

sub comment {
  my $self = $_[0];
  my $data = $_[1];
  if ($self->{Node}) {
    $self->{Node}->{xml_comment}.='<!--'.$data.'-->';
  }

lib/Treex/PML/Instance.pm  view on Meta::CPAN

Here is an example of a configuration file (see the schema for more
details).

    <?xml version="1.0" encoding="utf-8"?>
    <pmlbackend xmlns="http://ufal.mff.cuni.cz/pdt/pml/">
      <head>
        <schema href="pmlbackend_conf_schema.xml"/>
      </head>
      <options>
        <load>
          <validate_cdata>1</validate_cdata>
          <use_resources>1</use_resources>
        </load>
        <save>
          <indent>4</indent>
          <validate_cdata>1</validate_cdata>
          <write_single_LM>1</write_single_LM>
        </save>
      </options>
      <transform_map>
        <transform id="alpino" test="alpino_ds[@version='1.1' or @version='1.2']">
          <in type="xslt" href="alpino2pml.xsl"/>
          <out type="xslt" href="pml2alpino.xsl"/>
        </transform>
        <transform id="sdata" root="sdata" ns="http://ufal.mff.cuni.cz/pdt/pml/">
          <in type="perl" command="require SDataMerge; return SDataMerge::transform(@_);"/>

lib/Treex/PML/Instance/Reader.pm  view on Meta::CPAN

    $HAVE_XS = 0;
  }
}

my (%handlers,%src,
    %handler_cache,@handler_cache,
    %schema_cache,@schema_cache
   );

# TODO:
# - create one handler per cdata+format type
# - test inline schemas

our $CACHE_HANDLERS=1;
our $CACHE_SCHEMAS=1;
our $MAX_SCHEMA_CACHE_SIZE=50;

our $VALIDATE_CDATA=0;
our $VALIDATE_SEQUENCES=1;
our $BUILD_TREES = 1;
our $LOAD_REFFILES = 1;
our $KNIT = 1;

our $READER_OPTS = {
  no_cdata => 1,
  clean_namespaces => 1,
  expand_entities => 1,
  expand_xinclude => 1,
  no_xinclude_nodes => 1,
};

require Treex::PML;

sub _get_handlers_cache_key {
  my ($schema)=@_;

lib/Treex/PML/Instance/Reader.pm  view on Meta::CPAN

        };
       $ret
     } ($sel_knit,$sel_refs);
  }

  $ctxt->read_reffiles({use_resources=>$opts->{use_resources}});
  $ctxt->{'_no_read_trees'} = $opts->{no_trees};
  local $BUILD_TREES = $opts->{no_trees} ? 0 : 1;
  local $LOAD_REFFILES = $opts->{no_references} ? 0 : 1;
  local $KNIT = $opts->{no_knit} ? 0 : $LOAD_REFFILES;
  local $VALIDATE_CDATA =$opts->{validate_cdata} ? 1 : 0;
  local $VALIDATE_SEQUENCES =$opts->{ignore_content_patterns} ? 0 : 1;
  $ctxt->{'_id-hash'}={};

  prepare_handlers($ctxt);
  dump_handlers($ctxt) if $opts->{dump_handlers} or $ENV{PML_COMPILE_DUMP};
  load_data($ctxt,$reader,$opts);
  while ($reader->read) {
    if ($reader->nodeType == XML_READER_TYPE_PROCESSING_INSTRUCTION) {
      push @{$ctxt->{'_pi'}}, [ $reader->name,$reader->value ];
    }

lib/Treex/PML/Instance/Reader.pm  view on Meta::CPAN

  return unless $decl;
  my ($idM) = $decl->find_members_by_role('#ID');
  if ($idM) {
    # what follows is a hack fixing buggy PDT 2.0 schemas
    my $cdecl = $idM->get_content_decl(1); # no_resolve
    if ($cdecl and $cdecl->get_decl_type == PML_CDATA_DECL and $cdecl->get_format eq 'ID') {
      $cdecl->set_format('PMLREF');
    } elsif ($cdecl = $idM->get_content_decl()) {
      if ($cdecl and $cdecl->get_decl_type == PML_CDATA_DECL and $cdecl->get_format eq 'ID') {
          warn "Trying to knit object of type '".$decl->get_decl_path."' which has an #ID-attribute ".
            "'".$idM->get_name."' declared as <cdata format=\"ID\"/>. ".
              "Note that the data-type for #ID-attributes in objects knitted as DOM should be ".
                "<cdata format=\"PMLREF\"/> (Hint: redeclare with <derive> for imported types).";
      }
    }
  }
  return $idM;
}

sub knit_code {
  my ($decl,$assign,$fail)=@_;
  my $sub = q`
             if ($ref) {

lib/Treex/PML/Instance/Reader.pm  view on Meta::CPAN

               #return bless \@alt, 'Treex::PML::Alt';
               Treex::PML::Factory->createAlt(\@alt,1);
          }
       }
    `;
      # print $sub;
      $src{$src}=$sub;
      $handlers{$path} = eval $sub; die _nl($sub)."\n".$@.' ' if $@;

    } elsif ($decl_type == PML_CDATA_DECL) {
      my $src = $schema_name.'__generated_read_cdata@'.$path;
      $src=~y{/}{@};
      my $sub = q`#line 0 ".pml_compile.d/`.$src.q`"
         sub {
            my ($p)=@_;
            my $text;
            if (ref($p)) {
              my $c = $p->[XAT_CHILDREN];
              return undef unless $c and @$c;
              my $type;
              $text = join '',

lib/Treex/PML/Instance/Writer.pm  view on Meta::CPAN


my (
  %handlers,
  %src,
  %handler_cache,
  @handler_cache,
 );

# TODO:
# - test inline schemas
# - content_pattern and cdata validation on save
# - mixed content
# - decorate

our $CACHE_HANDLERS=1;
our $MAX_SCHEMA_CACHE_SIZE=50;

our $VALIDATE_CDATA=0;
our $SAVE_REFFILES = 1;
our $WITH_TREES = 1;
our $KEEP_KNIT = 0;

lib/Treex/PML/Instance/Writer.pm  view on Meta::CPAN

    return q`
  $indent_level--;`;
  } else {
    return q()
  }
}

sub save {
  my ($ctxt,$opts)=@_;
  my $fh = $opts->{fh};
  local $VALIDATE_CDATA=$opts->{validate_cdata} if
    exists $opts->{validate_cdata};

  $ctxt->set_filename($opts->{filename}) if $opts->{filename};
  my $href = $ctxt->{'_filename'};

  $fh=\*STDOUT if ($href eq '-' and !$fh);
  my $config = $opts->{config};
  if ($config and ref(my $load_opts = $config->get_data('options/save'))) {
    $opts = {%$load_opts, %$opts};
  }

lib/Treex/PML/Instance/Writer.pm  view on Meta::CPAN

               print $out `._indent().q`"<AM/>";
             }
           }`._indent_dec().q`
           print $out `._indent().q`"</$tag>" if defined $tag and length $tag;
         }
       }`;
      $src{$src}=$sub;
      $handlers{$path} = eval($sub); die _nl($sub)."\n".$@.' ' if $@;
    } elsif ($decl_type == PML_CDATA_DECL) {
      # TODO: CDATA FORMAT VALIDATION
      my $src = $schema_name.'__generated_write_cdata@'.$path;
      $src=~y{/}{@};
      my $sub = q`#line 1 ".pml_compile.d/`.$src.q`"
       sub {
         my ($tag,$data)=@_;
         print $out (length($tag) ? `._indent().q`"<$tag>" : '>') if defined $tag;
         if (defined $data and length $data) {
           $data=~s/&/&amp;/g;$data=~s/</&lt;/g;$data=~s/\]\]>/]]&gt;/g;
           print $out $data;
         }
         print $out "</$tag>" if defined $tag and length $tag;

lib/Treex/PML/Schema.pm  view on Meta::CPAN

    constant    => 'value',
  },
  Stringify => {
    description => 'content',
    revision    => 'content',
    value       => 'content',
    delete      => 'content',
  },
  Solitary => {
    map { $_ => 1 }
      qw(description revision root cdata structure container sequence constant list alt choice)
     },
  Bless => {
    member =>  'Treex::PML::Schema::Member',
    attribute =>  'Treex::PML::Schema::Attribute',
    element =>  'Treex::PML::Schema::Element',
    type =>  'Treex::PML::Schema::Type',
    root =>  'Treex::PML::Schema::Root',
    structure =>  'Treex::PML::Schema::Struct',
    container =>  'Treex::PML::Schema::Container',
    sequence =>  'Treex::PML::Schema::Seq',
    list =>  'Treex::PML::Schema::List',
    alt =>  'Treex::PML::Schema::Alt',
    cdata =>  'Treex::PML::Schema::CDATA',
    constant =>  'Treex::PML::Schema::Constant',
    choice =>  'Treex::PML::Schema::Choice',
    template => 'Treex::PML::Schema::Template',
    copy => 'Treex::PML::Schema::Copy',
    import => 'Treex::PML::Schema::Import',
    derive => 'Treex::PML::Schema::Derive',
    '*' => 'Treex::PML::Schema::XMLNode',
  },
  DefaultNs => PML_SCHEMA_NS,
);

lib/Treex/PML/Schema.pm  view on Meta::CPAN

               $parent_is == PML_ELEMENT_DECL) {
        $decl->{-path} = $parent->{-parent}{-path}.'/'.$parent->get_name;
      } elsif ($parent_is == PML_CONTAINER_DECL and $decl_is != PML_ATTRIBUTE_DECL) {
        $decl->{-path} = $parent->{-path}.'/#content';
      } elsif ($parent_is == PML_LIST_DECL) {
        $decl->{-path} = $parent->{-path}.'/LM';
      } elsif ($parent_is == PML_ALT_DECL) {
        $decl->{-path} = $parent->{-path}.'/AM';
      }
      if ($decl_is == PML_LIST_DECL and !$decl->{-decl} and $decl->{role} eq '#KNIT') {
        # warn ("List $decl->{-path} with role=\"#KNIT\" must have a content type declaration: assuming <cdata format=\"PMLREF\">!\n");
        __fix_knit_type($schema,$decl,$decl->{-path}.'/LM');
      }
    } elsif ($decl_is == PML_MEMBER_DECL) {
      if (!$decl->{-decl} and $decl->{role} eq '#KNIT') {
        # warn ("Member  $decl->{-parent}{-path}/$decl->{-name} with role=\"#KNIT\" must have a content type declaration: assuming <cdata format=\"PMLREF\">!\n");
        __fix_knit_type($schema,$decl);
      }
    }
  });
}

sub __fix_knit_type {
  my ($schema,$decl,$path)=@_;
  $decl->{-decl}='cdata';
  my $cdata = $decl->{cdata}= bless {
    format => 'PMLREF',
    -xml_name => 'cdata',
    -attributes => [ 'format' ],
  }, 'Treex::PML::Schema::CDATA';
  weaken( $cdata->{-schema} = $schema );
  weaken( $cdata->{-parent} = $decl );
  if (defined $path) {
    $cdata->{-path} = $path;
  } elsif ($decl->{-parent} and $decl->{-name}) {
    $cdata->{-path} = "$decl->{-parent}{-path}/$decl->{-name}";
  }
}

sub _traverse_data {
  my ($data,$sub,$seen,$hashes_only)=@_;
  $seen->{$data}=1;
  if (UNIVERSAL::isa($data,'ARRAY')) {
    $sub->($data,0) unless $hashes_only;
    foreach my $val (@$data) {
      if (ref($val) and !exists $seen->{$val}) {

lib/Treex/PML/Schema/CDATA.pm  view on Meta::CPAN

  $VERSION='2.28'; # version template
}
no warnings 'uninitialized';
use Carp;

use Treex::PML::Schema::Constants;
use base qw( Treex::PML::Schema::Decl );

=head1 NAME

Treex::PML::Schema::CDATA - implements cdata declaration.

=head1 INHERITANCE

This class inherits from L<Treex::PML::Schema::Decl>.

=head1 METHODS

See the super-class for the complete list.

=over 3

lib/Treex/PML/Schema/CDATA.pm  view on Meta::CPAN

=item $decl->is_atomic ()

Returns 1.

=item $decl->get_decl_type ()

Returns the constant PML_CDATA_DECL.

=item $decl->get_decl_type_str ()

Returns the string 'cdata'.

=item $decl->get_format ()

Return identifier of the data format.

=item $decl->set_format (format)

Set format to a given format identifier.

=item $decl->check_string_format (string, format-id?)

lib/Treex/PML/Schema/CDATA.pm  view on Meta::CPAN


Returns undef.

=back


=cut

sub is_atomic { 1 }
sub get_decl_type { return PML_CDATA_DECL; }
sub get_decl_type_str { return 'cdata'; }
sub get_content_decl { return(undef); }
sub get_format { return $_[0]->{format} }
sub set_format { $_[0]->{format} = $_[1] }
sub init {
  my ($self,$opts)=@_;
  $self->{-parent}{-decl} = 'cdata';
}

{
  our %format_re = (
    any => sub { 1 }, # to make it appear in the list of supported formats
    nonNegativeInteger => qr(^\s*(?:[+]?\d+|-0+)\s*$),
    positiveInteger => qr(^\s*[+]?\d*[1-9]\d*\s*$), # ? is zero allowed lexically
    negativeInteger => qr(^\s*-\d*[1-9]\d*\s*$), # ? is zero allowed lexically
    nonPositiveInteger => qr(^\s*(?:-\d+|[+]?0+)\s*$),
    decimal => qr(^\s*[+-]?\d+(?:\.\d*)?\s*$),

lib/Treex/PML/Schema/Copy.pm  view on Meta::CPAN

      if (defined($ref) and length($ref)) {
	my $owner = _lookup_upwards($type->{-parent},['type','derive','param'],$ref);
	if (defined $owner and $owner==$template) {
	  # the type is defined exactly on the level of the template
	  if (exists $copy->{let}{$ref}) {
	    my $let = $copy->{let}{$ref};
	    if ($let->{type}) {
	      $type->{type}=$let->{type}
	    } else {
	      delete $type->{type};
	      foreach my $d (qw(list alt structure container sequence cdata choice constant)) {
		if (exists $type->{$d}) {
		  delete $type->{$d};
		  last;
		}
	      }
	      delete $type->{-decl};
	      delete $type->{-resolved};
	      foreach my $d (qw(list alt structure container sequence cdata choice constant)) {
		if (exists $let->{$d}) {
		  $type->{$d} = $type->copy_decl($let->{$d});
		  $type->{-decl}=$d;
		  last;
		}
	      }
	    }
	  } else {
	    $type->{type} = $prefix.$ref; # do apply prefix
	  }

lib/Treex/PML/Schema/Decl.pm  view on Meta::CPAN

sub get_schema { return $_[0]->schema }

=item $decl->get_decl_type ()

Return the type of declaration as an integer constant (see
L<Treex::PML::Schema/"CONSTANTS">).

=item $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.

=cut

sub get_decl_type     { return(undef); } # VIRTUAL
sub get_decl_type_str { return(undef); } # VIRTUAL

=item $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).

=cut

sub is_atomic { croak "is_atomic(): UNKNOWN TYPE"; } # VIRTUAL

=item $decl->get_content_decl ()

lib/Treex/PML/Schema/Decl.pm  view on Meta::CPAN

        bless $mdecl, 'Treex::PML::Schema::Member';
        $mdecl->{'-xml_name'}='member';
        $mdecl->{'-attributes'}=[qw(name required as_attribute type role)];
        weaken($mdecl->{-parent}=$sub);
        weaken($mdecl->{-schema}=$schema);
        $class->convert_from_hash($mdecl,
                         $schema,
                         $path.'/'.$name
                        );
        if (!$mdecl->{-decl} and $mdecl->{role} eq '#KNIT') {
#          warn("Member $decl->{-parent}{-path}/$decl->{-name} with role=\"#KNIT\" must have a content type declaration: assuming <cdata format=\"PMLREF\">!\n");
          Treex::PML::Schema::__fix_knit_type($schema,$mdecl);
        }
      }
    }
  } elsif ($sub = $decl->{container}) {
    $decl_type = 'container';
    bless $sub, 'Treex::PML::Schema::Container';
    $sub->{'-attributes'}=[qw(role name type)];
    if (my $members = $sub->{attribute}) {
      my ($name, $mdecl);

lib/Treex/PML/Schema/Decl.pm  view on Meta::CPAN

                         $path.'/'.$name
                        );
      }
    }
  } elsif ($sub = $decl->{list}) {
    $decl_type = 'list';
    bless $sub, 'Treex::PML::Schema::List';
    $sub->{'-attributes'}=[qw(role ordered type)];
    $class->convert_from_hash($sub, $schema, $path.'/LM');
    if (!$sub->{-decl} and $sub->{role} eq '#KNIT') {
#      warn("List $sub->{-name} with role=\"#KNIT\" must have a content type declaration: assuming <cdata format=\"PMLREF\">!\n");
      Treex::PML::Schema::__fix_knit_type($schema,$sub,$path.'/LM');
    }
  } elsif ($sub = $decl->{alt}) {
    $decl_type = 'alt';
    bless $sub, 'Treex::PML::Schema::Alt';
    $sub->{'-attributes'}=[qw(role type)];
    $class->convert_from_hash($sub, $schema, $path.'/AM');
  } elsif ($sub = $decl->{choice}) {
    $decl_type = 'choice';
    # convert from an ARRAY to a hash

lib/Treex/PML/Schema/Decl.pm  view on Meta::CPAN

      bless $sub, 'Treex::PML::Schema::Choice';
      if (ref($sub->{value}) eq 'ARRAY') {
        $sub->{values} = [
          map { $_->{content} } @{$sub->{value}}
        ];
        delete $sub->{value};
      }
    } else {
      croak __PACKAGE__.": Invalid <choice> element in type '$path'?\n";
    }
  } elsif ($sub = $decl->{cdata}) {
    $decl_type = 'cdata';
    bless $sub, 'Treex::PML::Schema::CDATA';
    $sub->{'-attributes'}=['format'];
  } elsif (exists $decl->{constant}) { # can be 0
    $sub = $decl->{constant};
    $decl_type = 'constant';
    unless (ref($sub)) {
      $sub = $decl->{constant} = bless { value => $sub }, 'Treex::PML::Schema::Constant';
    }
    ## this is just a scalar value
    # bless $sub, 'Treex::PML::Schema::Constant';

lib/Treex/PML/Schema/Decl.pm  view on Meta::CPAN

  for my $d (qw(member attribute element)) {
    if (ref $self->{$d}) {
      foreach (values %{$self->{$d}}) {
        $_->for_each_decl($sub);
      }
      last if $d eq 'attribute'; # there may be content
      return; # otherwise
    }
  }
  for my $d (qw(list alt structure container sequence),
             qw(cdata choice constant)) {
    if (exists $self->{$d}) {
      $self->{$d}->for_each_decl($sub);
      return;
    }
  }
}

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

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

lib/Treex/PML/Schema/Derive.pm  view on Meta::CPAN

#      print STDERR Data::Dumper::Dumper([$type]);
      croak "Cannot derive sequence type '$name' from a non-sequence '$source'\n";
    }
  } elsif ($derive->{container}) {
    if ($type->{container}) {
      my $derive_container = $derive->{container};
      my $target_container = $type->{container};
      for my $attr (qw(type role)) {
	next unless exists $derive_container->{$attr};
	if ($attr eq 'type' and !exists($target_container->{type})) {
	  foreach my $d (qw(list alt structure container sequence cdata)) {
	    if (exists $target_container->{$d}) {
	      delete $target_container->{$d};
	      last;
	    }
	  }
	  delete $target_container->{-decl};
	  delete $target_container->{-resolved};
	}
	$target_container->{$attr} = $derive_container->{$attr};
	push @{$target_container->{-attributes}},$attr

lib/Treex/PML/Schema/Reader.pm  view on Meta::CPAN

use Carp;

use Scalar::Util qw(weaken blessed);
use XML::LibXML::Reader;

sub new {
  my ($class,$opts)=@_;
  my $URL = $opts->{URL};
  my @common = (
     no_xinclude_nodes => 1,
     no_cdata => 1,
     expand_xinclude => 1,
     no_blanks => 1,
     expand_entities => 1,
     suppress_errors => 0,
     suppress_warnings => 0,
  );
  if ($opts->{validate}) {
    my $rng = $opts->{relaxng_schema} || Treex::PML::FindInResources('pml_schema_inline.rng');
    if (defined $rng) {
      push @common, (RelaxNG => $rng);

lib/Treex/PML/share/pmlbackend_conf_schema.xml  view on Meta::CPAN

      <!-- parsing/serialization options -->
      <member name="options" type="options.type"/>
      <!-- pre- and post-processing rules -->
      <member name="transform_map" type="transform_map.type"/>
    </structure>
  </type>
  <type name="options.type">
    <structure>
      <!-- level of generated debugging messages -->
      <member name="debug">
	<cdata format="integer"/>
      </member>
      <!-- global parsing options -->
      <member name="load" type="options.load.type"/>
      <!-- global serialization options -->
      <member name="save" type="options.save.type"/>
    </structure>
  </type>
  <type name="options.load.type">
    <structure>
      <!-- validate the format of character data types -->
      <member name="validate_cdata" type="bool.type"/>
      <!-- ignore the #KNIT role -->
      <member name="no_knit" type="bool.type"/>
      <!-- do not load any external references -->
      <member name="no_references" type="bool.type"/>
      <!-- locate files related in Treex::PML resource paths  -->
      <member name="use_resources" type="bool.type"/>
    </structure>
  </type>
  <type name="options.save.type">
    <structure>
      <!-- serialize the embedded data from #KNIT into the referring instance (the result may be an invalid PML instance) -->
      <member name="keep_knit" type="bool.type"/>
      <!-- do not fold singleton lists -->
      <member name="write_single_LM" type="bool.type"/>
      <!-- decorate the instance with names of the corresponding PML types, not implemented  -->
      <member name="decorate" type="bool.type"/>
      <!-- validate the format of character data -->
      <member name="validate_cdata" type="bool.type"/>
      <!-- amount of indentation; use -1 to turn off generating any extraneous white space  -->
      <member name="indent"><cdata format="integer"/></member>
    </structure>
  </type>
  <type name="transform_map.type">
    <sequence>
      <!-- pre- and post-processing transformation rules -->
      <element name="transform" type="transform.type"/>
    </sequence>
  </type>
  <type name="transform.type">
    <!-- a transformation rule -->
    <structure>
      <!-- rule ID -->
      <member name="id" role="#ID" as_attribute="1" required="1">
	<cdata format="ID"/>
      </member>
      <!-- match name of the root-element of the input document  -->
      <member name="root" as_attribute="1">
	<cdata format="NCName"/>
      </member>
      <!-- match namespace of the root-element of the input document  -->
      <member name="ns" as_attribute="1">
	<cdata format="anyURI"/>
      </member>
      <!-- match input document using an XPath expression  -->
      <member name="test" as_attribute="1">
	<cdata format="string"/>
      </member>
      <!-- input transformation (if rule matched)  -->
      <member name="in" type="transf.type"/>
      <!-- outptu transformation (if rule matched)  -->
      <member name="out" type="transf.type"/>
    </structure>
  </type>
  <type name="transf.type">
    <container>
      <!-- tranformation method -->      
      <attribute name="type" required="1" type="transf_types.type"/>
      <!-- href for XSLT transformation -->      
      <attribute name="href" required="0">
	<cdata format="anyURI"/>
      </attribute>
      <!-- command for Perl, shell, or pipe -->
      <attribute name="command" required="0">
	<cdata format="string"/>
      </attribute>
      <!-- transformation parameters -->
      <sequence>
	<element name="param" type="param.type"/>
      </sequence>
    </container>
  </type>
  <type name="transf_types.type">
    <choice>
      <value>identity</value> <!-- no transformation -->
      <value>xslt</value> <!-- XSLT 1.0 based transformation -->
      <value>perl</value> <!-- Perl-based transformation of an input DOM -->
      <value>pipe</value> <!-- transform XML via a pipe to external command -->
      <value>shell</value> <!-- transform XML via an external command, obtaining the input URI as an argument -->
    </choice>
  </type>
  <type name="param.type">
    <container>
      <attribute name="name"> <!-- name of a transformation parameter -->
	<cdata format="Name"/>
      </attribute>
      <cdata format="string"/>  <!-- value of a transformation parameter -->
    </container>
  </type>
  <type name="bool.type">
    <choice>
      <value>0</value>
      <value>1</value>
    </choice>
  </type>
</pml_schema>

test_data/alpino/alpino_schema.xml  view on Meta::CPAN

<?xml version="1.0" encoding="utf-8"?>
<pml_schema xmlns="http://ufal.mff.cuni.cz/pdt/pml/schema/" version="1.1">
  <revision>0.1.3</revision>
  <description>Alpino DS 1.3</description>

  <root name="alpino_ds_pml" type="alpino_ds.type"/>

  <type name="alpino_ds.type">
    <structure>
      <member name="version"><cdata format="any"/></member>
      <member name="sentence"  type="sentence.type"/>
      <member name="comments">
        <sequence content_pattern="comment*">
          <element name="comment" type="comment.type"/>
        </sequence>
      </member>
      <member name="trees" role="#TREES">
	<list type="node.type" ordered="1"/>
      </member>
    </structure>

test_data/alpino/alpino_schema.xml  view on Meta::CPAN


  <type name="node.type">
    <structure role="#NODE">
      <member as_attribute="1" name="begin" type="index.type" required="1"/>
      <member as_attribute="1" name="cat" type="cat.type" required="0"/>
      <member as_attribute="1" name="end" type="index.type" required="1"/>
      <member as_attribute="1" name="id" type="index.type" required="1"/>
      <member as_attribute="1" name="index" type="index.type" required="0"/>
      <member as_attribute="1" name="pos" type="pos.type" required="0"/>
      <member as_attribute="1" name="rel" type="rel.type" required="1"/>
      <member as_attribute="1" name="root"><cdata format="normalizedString"/></member>
      <member as_attribute="1" name="word"><cdata format="normalizedString"/></member>
      <member name="children" role="#CHILDNODES">
	<list type="node.type" ordered="1"/>
      </member>
    </structure>
  </type>

  <type name="index.type">
    <cdata format="nonNegativeInteger"/>
  </type>

  <type name="sentence.type">
    <cdata format="any"/>
  </type>

  <type name="comment.type">
    <cdata format="any"/>
  </type>


  <type name="rel.type">
    <choice>
      <value>--</value>
      <value>app</value>
      <value>body</value>
      <value>cmp</value>
      <value>cnj</value>

test_data/pdt/adata_schema.xml  view on Meta::CPAN

  <revision>1.0.4</revision>
  <description>PDT 2.0 analytical trees</description>
  <reference name="mdata" readas="pml"/>

  <import schema="mdata_schema.xml" type="m-node.type" minimal_revision="1.0.2"/>
  <import schema="mdata_schema.xml" type="bool.type"/>

  <derive type="m-node.type">
    <structure>
      <member name="id" as_attribute="1" role="#ID" required="1">
	<cdata format="PMLREF"/>
      </member>
    </structure>
  </derive>

  <root name="adata" type="a-adata.type"/>

  <type name="a-adata.type">
    <structure>
      <member name="meta" required="0" type="a-meta.type"/>
      <member name="trees" role="#TREES" required="1">
	<list type="a-root.type" ordered="1"/>
      </member>
    </structure>
  </type>

  <type name="a-meta.type">
    <structure>
      <member name="annotation_info">
	<structure name="a-annotation-info">
	  <member name="version_info"><cdata format="any"/></member>
	  <member name="desc"><cdata format="any"/></member>
	</structure>
      </member>
    </structure>
  </type>

  <type name="a-root.type">
    <structure role="#NODE" name="a-root">
      <member name="id" role="#ID" as_attribute="1" required="1"><cdata format="ID"/></member>
      <member name="s.rf"><cdata format="PMLREF"/></member>
      <member name="afun"><constant>AuxS</constant></member>
      <member name="ord" role="#ORDER" required="1"><cdata format="nonNegativeInteger"/></member>
      <member name="children" role="#CHILDNODES">
	<list type="a-node.type" ordered="1"/>
      </member>
    </structure>
  </type>

  <type name="a-node.type">
    <structure role="#NODE" name="a-node">
      <member name="id" role="#ID" as_attribute="1" required="1"><cdata format="ID"/></member>
      <member name="m.rf" role="#KNIT" type="m-node.type">
	<cdata format="PMLREF"/>
      </member>
      <member name="afun" type="a-afun.type" required="1"/>
      <member name="is_member" type="bool.type"/>
      <member name="is_parenthesis_root" type="bool.type"/>
      <member name="ord" role="#ORDER" required="1"><cdata format="nonNegativeInteger"/></member>
      <member name="children" role="#CHILDNODES">
	<list type="a-node.type" ordered="1"/>
      </member>
    </structure>
  </type>
  
  <type name="a-afun.type">
    <choice>
      <value>Pred</value>
      <value>Pnom</value>

test_data/pdt/mdata_schema.xml  view on Meta::CPAN

  <revision>1.0.2</revision>
  <description>PDT 2.0 morphological annotation</description>
  <reference name="wdata" readas="pml"/>

  <import schema="wdata_schema.xml" type="w-node.type" minimal_revision="1.0.0"/>
  <import schema="wdata_schema.xml" type="bool.type"/>

  <derive type="w-node.type">
    <structure name="w-node">
      <member as_attribute="1" name="id" role="#ID" required="1">
	<cdata format="PMLREF"/>
      </member>
    </structure>
  </derive>

  <root name="mdata" type="m-mdata.type"/>

  <type name="m-mdata.type">
    <sequence role="#TREES" content_pattern="meta?, s+">
      <element name="meta" type="m-meta.type"/>
      <element name="s" type="m-s.type"/>
    </sequence>
  </type>

  <type name="m-meta.type">
    <structure>
      <member name="lang"><cdata format="any"/></member>
      <member name="annotation_info">
	<list ordered="0" type="m-annotation-info.type"/>
      </member>
    </structure>
  </type>

  <type name="m-annotation-info.type">
    <structure name="m-annotation-info">
      <member as_attribute="1" name="id" role="#ID" required="1"><cdata format="ID"/></member>
      <member name="version_info"><cdata format="any"/></member>
      <member name="desc"><cdata format="any"/></member>
    </structure>
  </type>

  <type name="m-s.type">
    <container role="#NODE">
      <attribute name="id" role="#ID" required="1"><cdata format="ID"/></attribute>
      <sequence role="#CHILDNODES">
	<element name="m" type="m-m.type"/>
      </sequence>
    </container>
  </type>

  <type name="m-m.type">
    <container role="#NODE">
      <alt type="m-node.type"/>
    </container>
  </type>

  <type name="m-node.type">
    <structure name="m-node">
      <member as_attribute="1" name="id" role="#ID" required="1"><cdata format="ID"/></member>
      <member name="src.rf"><cdata format="PMLREF"/></member>
      <member name="w.rf">
        <list ordered="1" role="#KNIT" type="w-node.type"><cdata format="PMLREF"/></list>
      </member>
      <member name="form_change" type="m-form_change.type"/>
      <member name="form" required="1"><cdata format="any"/></member>
      <member name="lemma" required="1"><cdata format="any"/></member>
      <member name="tag" required="1"><cdata format="any"/></member>
    </structure>
  </type>

  <type name="m-form_change.type">
    <list ordered="0">
      <choice>
	<value>ctcd</value>
	<value>spell</value>
	<value>insert</value>
	<value>num_normalization</value>

test_data/pdt/tdata_schema.xml  view on Meta::CPAN


  <type name="t-meta.type">
    <structure>
      <member name="annotation_info" type="t-annotation-info.type"/>
    </structure>
  </type>

  <type name="t-annotation-info.type">
    <structure name="t-annotation-info">
      <member name="version_info">
        <cdata format="any"/>
      </member>
      <member name="desc">
        <cdata format="any"/>
      </member>
    </structure>
  </type>

  <type name="t-root.type">
    <structure role="#NODE" name="t-root">
      <member as_attribute="1" name="id" role="#ID" required="1">
        <cdata format="ID"/>
      </member>
      <member name="atree.rf">
        <cdata format="PMLREF"/>
      </member>
      <member name="nodetype">
        <constant>root</constant>
      </member>
      <member name="deepord" role="#ORDER" required="0">
        <cdata format="nonNegativeInteger"/>
      </member>
      <member name="children" role="#CHILDNODES">
        <list ordered="1" type="t-node.type"/>
      </member>
    </structure>
  </type>

  <type name="t-node.type">
    <structure role="#NODE" name="t-node">
      <member as_attribute="1" name="id" role="#ID" required="1">
        <cdata format="ID"/>
      </member>
      <member name="a" type="t-a.type"/>
      <member name="compl.rf">
        <list ordered="0">
          <cdata format="PMLREF"/>
        </list>
      </member>
      <member name="coref_text.rf">
        <list ordered="0">
          <cdata format="PMLREF"/>
        </list>
      </member>
      <member name="coref_gram.rf">
        <list ordered="0">
          <cdata format="PMLREF"/>
        </list>
      </member>
      <member name="coref_special" type="coref_special.type"/>
      <member name="val_frame.rf">
        <alt>
          <cdata format="PMLREF"/>
        </alt>
      </member>
      <member name="nodetype" required="1" type="t-nodetype.type"/>
      <member name="is_generated" type="bool.type"/>
      <member name="t_lemma" required="1">
        <cdata format="any"/>
      </member>
      <member name="functor" required="1">
        <alt type="func.type"/>
      </member>
      <member name="subfunctor" type="t-subfunctor.type"/>
      <member name="is_member" type="bool.type"/>
      <member name="is_name_of_person" type="bool.type"/>
      <member name="quot">
        <list ordered="0">
          <structure>
            <member name="type" required="1" type="t-type.type"/>
            <member name="set_id" required="1">
              <cdata format="any"/>
            </member>
          </structure>
        </list>
      </member>
      <member name="is_dsp_root" type="bool.type"/>
      <member name="sentmod" type="t-sentmod.type"/>
      <member name="gram" type="t-gram.type"/>
      <member name="tfa" type="t-tfa.type"/>
      <member name="is_parenthesis" type="bool.type"/>
      <member name="is_state" type="bool.type"/>
      <member name="deepord" role="#ORDER" required="1">
        <cdata format="nonNegativeInteger"/>
      </member>
      <member name="children" role="#CHILDNODES">
        <list ordered="1" type="t-node.type"/>
      </member>
    </structure>
  </type>

  <type name="t-tfa.type">
    <choice>
      <value>t</value>

test_data/pdt/tdata_schema.xml  view on Meta::CPAN

      <value>dphr</value>
      <value>fphr</value>
      <value>list</value>
      <value>qcomplex</value>
    </choice>
  </type>

  <type name="t-a.type">
    <structure>
      <member name="lex.rf">
        <cdata format="PMLREF"/>
      </member>
      <member name="aux.rf">
        <list ordered="0">
          <cdata format="PMLREF"/>
        </list>
      </member>
    </structure>
  </type>

  <type name="coref_special.type">
    <choice>
      <value>segm</value>
      <value>exoph</value>
    </choice>

test_data/pdt/wdata_schema.xml  view on Meta::CPAN


  <type name="w-wdata.type">
    <structure>
      <member name="meta" type="w-meta.type"/>
      <member name="doc" type="w-doc.type"/>
    </structure>
  </type>

  <type name="w-meta.type">
    <structure>
      <member name="lang"><cdata format="any"/></member>
      <member name="original_format"><cdata format="any"/></member>
    </structure>
  </type>

  <type name="w-doc.type">
    <container>
      <attribute name="id" required="1" role="#ID"><cdata format="ID"/></attribute>
      <attribute name="source_id"><cdata format="any"/></attribute>
      <sequence content_pattern="docmeta, para+">
	<element name="docmeta" type="w-docmeta.type"/>
	<element name="para" type="w-para.type"/>
      </sequence>
    </container>
  </type>

  <type name="w-docmeta.type">
    <sequence>
      <element name="othermeta" type="w-othermeta.type"/>
    </sequence>
  </type>

  <type name="w-othermeta.type">
    <container>
      <attribute name="origin"><cdata format="any"/></attribute>
      <cdata format="any"/>
    </container>
  </type>

  <type name="w-para.type">
    <sequence>
      <element name="othermarkup" type="w-othermarkup.type"/>
      <element name="w" type="w-node.type"/>
    </sequence>
  </type>

  <type name="w-othermarkup.type">
    <container>
      <attribute name="origin"><cdata format="any"/></attribute>
      <cdata format="any"/>
    </container>
  </type>

  <type name="w-node.type">
    <structure name="w-node">
      <member as_attribute="1" name="id" role="#ID" required="1"><cdata format="ID"/></member>
      <member name="token" required="1"><cdata format="any"/></member>
      <member name="no_space_after" type="bool.type"/>
    </structure>
  </type>
  
  <type name="bool.type">
    <choice>
      <value>0</value>
      <value>1</value>
    </choice>
  </type>

test_data/pml/example10_schema.xml  view on Meta::CPAN

  <revision>0.1</revision>
  <description>
    Extended example of tree annotation over a tokenization layer
  </description>
  <reference name="tokenization" readas="dom"/>
  <!--  ============ import schema="example8_schema.xml" ============  -->
  <root name="annotation" type="annotation.type"/>
  <type name="w.type">
    <container>
      <attribute name="id" role="#ID" required="1">
        <cdata format="PMLREF"/>
      </attribute>
      <cdata format="any"/>
    </container>
  </type>
  <type name="ID.type">
    <cdata format="ID"/>
  </type>
  <!--  ============ derived from annotation.type ============  -->
  <type name="annotation.type">
    <sequence role="#TREES" content_pattern="meta, S+">
      <element name="S" type="S.type"/>
      <element name="meta" type="newmeta.type"/>
    </sequence>
  </type>
  <!--  ============ derived from S.type ============  -->
  <type name="S.type">
    <container role="#NODE">
      <attribute name="annotators_comment">
        <cdata format="any"/>
      </attribute>
      <attribute name="sentence.rf">
        <cdata format="PMLREF"/>
      </attribute>
      <list ordered="1" role="#CHILDNODES" type="node.type"/>
    </container>
  </type>
  <type name="node.type">
    <structure role="#NODE">
      <member as_attribute="1" name="label" type="label.type"/>
      <member name="w.rf">
        <list ordered="0" role="#KNIT" type="w.type">
          <cdata format="PMLREF"/>
        </list>
      </member>
      <member name="constituents" role="#CHILDNODES">
        <list ordered="1" type="node.type"/>
      </member>
    </structure>
  </type>
  <!--  ============ derived from label.type ============  -->
  <type name="label.type">
    <choice>

test_data/pml/example10_schema.xml  view on Meta::CPAN

      <value>SDECL</value>
      <value>SIMP</value>
      <value>SQUEST</value>
    </choice>
  </type>
  <!--  =============================================================  -->
  <!--  ============ import schema="example1_schema.xml"  type="meta.type"============  -->
  <type name="meta.type">
    <structure>
      <member name="annotator">
        <cdata format="any"/>
      </member>
      <member name="datetime">
        <cdata format="any"/>
      </member>
    </structure>
  </type>
  <!--  ==============================================================================  -->
  <type name="newmeta.type">
    <structure>
      <member name="lang">
        <cdata format="any"/>
      </member>
      <member name="changes">
        <list type="changes.type" ordered="1"/>
      </member>
    </structure>
  </type>
  <!--  ============ derived from meta.type ============  -->
  <type name="changes.type">
    <structure>
      <member name="annotator">
        <cdata format="any"/>
      </member>
      <member name="datetime">
        <cdata format="any"/>
      </member>
      <member name="id" role="#ID" as_attribute="1" required="1">
        <cdata format="ID"/>
      </member>
      <member name="desc">
        <cdata format="any"/>
      </member>
    </structure>
  </type>
</pml_schema>

test_data/pml/example1_schema.xml  view on Meta::CPAN

  <root name="annotation">
    <structure>
      <member name="meta" type="meta.type"/>
      <member name="trees" role="#TREES" required="1">
	<list type="node.type" ordered="1"/>
      </member>
    </structure>
  </root>
  <type name="meta.type">
    <structure>
      <member name="annotator"><cdata format="any"/></member>
      <member name="datetime"><cdata format="any"/></member>
    </structure>
  </type>
  <type name="node.type">
    <structure role="#NODE">
      <member name="ord" as_attribute="1" required="1" role="#ORDER">
        <cdata format="nonNegativeInteger"/>
      </member>
      <member name="func" type="func.type" required="1"/>
      <member name="form" required="1">
        <cdata format="any"/>
      </member>
      <member name="governs" role="#CHILDNODES" required="0">
        <list type="node.type" ordered="0"/>
      </member>
    </structure>
  </type>
  <type name="func.type">
    <choice>
      <value>Pred</value>
      <value>Subj</value>

test_data/pml/example2_schema.xml  view on Meta::CPAN

  xmlns="http://ufal.mff.cuni.cz/pdt/pml/schema/">
  <description>Example of constituency tree annotation</description>
  <root name="annotation">
    <sequence role="#TREES" content_pattern="meta, nt+">
      <element name="meta" type="meta.type"/>
      <element name="nt" type="nonterminal.type"/>
    </sequence>
  </root>
  <type name="meta.type">
    <structure>
      <member name="annotator"><cdata format="any"/></member>
      <member name="datetime"><cdata format="any"/></member>
    </structure>
  </type>
  <type name="nonterminal.type">
    <container role="#NODE">
      <attribute name="label" type="label.type"/>
      <sequence role="#CHILDNODES">
	<element name="nt" type="nonterminal.type"/>
	<element name="form" type="terminal.type"/>
      </sequence>
    </container>
  </type>
  <type name="terminal.type">
    <container role="#NODE">
      <cdata format="any"/>
    </container>
  </type>
  <type name="label.type">
    <choice>
      <value>S</value>
      <value>VP</value>
      <value>NP</value>
      <value>PP</value>
      <value>ADVP</value>
    </choice>

test_data/pml/example3_schema.xml  view on Meta::CPAN

  <description>
    Example of very compact constituency tree annotation
  </description>
  <root name="annotation">
    <sequence role="#TREES">
      <element name="S" type="nonterminal.type"/>
    </sequence>
  </root>
  <type name="nonterminal.type">
    <container role="#NODE">
      <attribute name="form"><cdata format="any"/></attribute>
      <sequence role="#CHILDNODES">
	<element name="VP" role="#NODE" type="nonterminal.type"/>
	<element name="NP" role="#NODE" type="nonterminal.type"/>
	<element name="PP" role="#NODE" type="nonterminal.type"/>
	<element name="ADVP" role="#NODE" type="nonterminal.type"/>
      </sequence>
    </container>
  </type>
</pml_schema>

test_data/pml/example4_schema.xml  view on Meta::CPAN

<?xml version="1.0"?>
<pml_schema version="1.1" xmlns="http://ufal.mff.cuni.cz/pdt/pml/schema/">
  <description>An oriented graph</description>
  <root name="graph">
    <structure>
      <member name="verteces">
        <list ordered="0">
          <structure>
            <member name="id" as_attribute="1" required="1" role="#ID">
              <cdata format="ID"/>
            </member>
            <member name="label" required="1">
              <cdata format="any"/>
            </member>
          </structure>
        </list>
      </member>
      <member name="edges">
        <list ordered="0">
          <structure>
            <member name="from.rf" required="1" as_attribute="1">
              <cdata format="PMLREF"/>
            </member>
            <member name="to.rf" required="1" as_attribute="1">
              <cdata format="PMLREF"/>
            </member>
          </structure>
        </list>
      </member>
    </structure>    
  </root>
</pml_schema>

test_data/pml/example5_schema.xml  view on Meta::CPAN

<?xml version="1.0"?>
<pml_schema version="1.1" xmlns="http://ufal.mff.cuni.cz/pdt/pml/schema/">
  <description>An oriented graph</description>
  <root name="graph">
    <structure>
      <member name="body" required="1">
	<list ordered="0">
	  <structure>
	    <member name="id" as_attribute="1" 
	      required="1" role="#ID">
	      <cdata format="ID"/>
	    </member>
	    <member name="label" required="1">
	      <cdata format="any"/>
	    </member>
	    <member name="edges.rf">
	      <list ordered="0">
		<cdata format="PMLREF"/>
	      </list>
	    </member>
	  </structure>
	</list>
      </member>
    </structure>
  </root>
</pml_schema>

test_data/pml/example6_schema.xml  view on Meta::CPAN

        <sequence>
          <element name="w" type="w.type"/>
        </sequence>
      </member>
    </structure>
  </type>
  <type name="w.type">
    <container>
      <attribute name="id" role="#ID" type="ID.type"
	required="1"/>
      <cdata format="any"/>
    </container>
  </type>
  <type name="ID.type">
    <cdata format="ID"/>
  </type>
</pml_schema>

test_data/pml/example7_schema.xml  view on Meta::CPAN

<pml_schema version="1.1" xmlns="http://ufal.mff.cuni.cz/pdt/pml/schema/">
  <description>
    Example of tree annotation over a tokenization layer
  </description>
  <reference name="tokenization" readas="dom"/>
  <root name="annotation">
    <sequence role="#TREES">
      <element name="S">
	<container role="#NODE">
	  <attribute name="sentence.rf">
	    <cdata format="PMLREF"/>
	  </attribute>
	  <list ordered="1" role="#CHILDNODES" type="node.type"/>
	</container>
      </element>
    </sequence>
  </root>
  <type name="node.type">
    <structure role="#NODE">
      <member as_attribute="1" name="label">
        <choice>
          <value>S</value>
          <value>VP</value>
          <value>NP</value>
          <value>PP</value>
          <value>ADVP</value>
        </choice>
      </member>
      <member name="w.rf">
	<list ordered="0" role="#KNIT" type="w.type">
	  <cdata format="PMLREF"/>
	</list>
      </member>
      <member name="constituents" role="#CHILDNODES">
        <list ordered="1" type="node.type"/>
      </member>
    </structure>
  </type>
  <type name="w.type">
    <container>
      <attribute name="id" role="#ID" required="1">
        <cdata format="ID"/>
      </attribute>
      <cdata format="any"/>
    </container>
  </type>
</pml_schema>

test_data/pml/example8_schema.xml  view on Meta::CPAN

    Example of tree annotation over a tokenization layer
  </description>
  <reference name="tokenization" readas="dom"/>

  <import type="w.type" schema="example6_schema.xml" revision="0.2"/>

  <!-- after DOM-knitting, #ID attribute contains a PMLREF -->
  <derive type="w.type">
    <container>
      <attribute name="id" role="#ID" required="1">
	<cdata format="PMLREF"/>
      </attribute>
    </container>
  </derive>

  <root name="annotation" type="annotation.type"/>

  <type name="annotation.type">
    <sequence role="#TREES">
      <element name="S" type="S.type"/>
    </sequence>
  </type>
  <type name="S.type">
    <container role="#NODE">
      <attribute name="sentence.rf">
	<cdata format="PMLREF"/>
      </attribute>
      <list ordered="1" role="#CHILDNODES" type="node.type"/>
    </container>
  </type>
  <type name="node.type">
    <structure role="#NODE">
      <member as_attribute="1" name="label" type="label.type"/>
      <member name="w.rf">
        <list ordered="0" role="#KNIT" type="w.type">
          <cdata format="PMLREF"/>
        </list>
      </member>
      <member name="constituents" role="#CHILDNODES">
        <list ordered="1" type="node.type"/>
      </member>
    </structure>
  </type>
  <type name="label.type">
    <choice>
      <value>S</value>

test_data/pml/example9_schema.xml  view on Meta::CPAN

  <import schema="example1_schema.xml" type="meta.type"/>

  <derive type="annotation.type">
    <sequence content_pattern="meta, S+">
      <element name="meta" type="newmeta.type"/>
    </sequence>
  </derive>
  <derive type="S.type">
    <container>
      <attribute name="annotators_comment">
        <cdata format="any"/>
      </attribute>
    </container>
  </derive>
  <derive type="meta.type" name="changes.type">
    <structure>
      <member name="id" role="#ID" as_attribute="1" required="1">
        <cdata format="ID"/>
      </member>
      <member name="desc"><cdata format="any"/></member>
    </structure>
  </derive>
  <derive type="label.type">
    <choice>
      <value>SDECL</value>
      <value>SIMP</value>
      <value>SQUEST</value>
      <delete>S</delete>
    </choice>
  </derive>
  <type name="newmeta.type">
    <structure>
      <member name="lang"><cdata format="any"/></member>
      <member name="changes"><list type="changes.type" ordered="1"/></member>
    </structure>
  </type>
</pml_schema>

test_data/pml/templates2_schema.xml  view on Meta::CPAN

<?xml version="1.0" encoding="utf-8"?>
<pml_schema
  xmlns="http://ufal.mff.cuni.cz/pdt/pml/schema/"
  version="1.2">
  <template name="example2.template">
    <param name="content"/>
    <import schema="example2_schema.xml"/>
    <derive type="terminal.type">
      <container  type="content" role="#NODE">
	<attribute name="id" required="0" role="#ID">
	  <cdata format="ID"/>
	</attribute>
      </container>
    </derive>
  </template>
  <copy template="example2.template" prefix="e2.">
    <let param="content">
      <cdata format="string"/>
    </let>
  </copy>
  <derive type="e2.terminal.type">
    <container>
      <attribute name="xml:id" required="0" role="#ID">
	<cdata format="NCName"/>
      </attribute>
      <delete>id</delete>
    </container>
  </derive>
  <derive type="e2.meta.type">
    <structure>
      <member name="xml:id" required="0" role="#ID" as_attribute="1">
	<cdata format="NCName"/>
      </member>
    </structure>
  </derive>
</pml_schema>



( run in 0.799 second using v1.01-cache-2.11-cpan-454fe037f31 )