File: 34abstract.t

package info (click to toggle)
libxml-compile-perl 1.64-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,304 kB
  • sloc: perl: 11,616; makefile: 7
file content (58 lines) | stat: -rw-r--r-- 1,264 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env perl
# test abstract elements

use warnings;
use strict;

use lib 'lib','t';
use TestTools;

use XML::Compile::Schema;
use XML::Compile::Tester;

use Test::More tests => 11;

set_compile_defaults
    elements_qualified => 'NONE';

my $schema   = XML::Compile::Schema->new( <<__SCHEMA__ );
<schema targetNamespace="$TestNS"
        xmlns="$SchemaNS"
        xmlns:me="$TestNS">

<element name="test1" type="int" abstract="true" />

<element name="test2">
  <complexType>
    <sequence>
      <element ref="me:test1" />
    </sequence>
  </complexType>
</element>

</schema>
__SCHEMA__

ok(defined $schema);

my $error = error_w($schema, test2 => {test1 => 42});
is($error, "attempt to instantiate abstract element `test1' at {http://test-types}test2/me:test1");

$error = error_r($schema, test2 => <<__XML);
<test2><test1>43</test1></test2>
__XML
is($error, "abstract element `test1' used at {http://test-types}test2/me:test1");

# abstract elements are skipped from the docs
my $out = templ_perl($schema, "{$TestNS}test2", abstract_types => 1, skip_header => 1);
is($out, <<'__TEMPL');
# Describing complex x0:test2
#     {http://test-types}test2

# is an unnamed complex
{ # sequence of test1

  # is a xs:int
  # ABSTRACT
  test1 => 42, }
__TEMPL