File: 43group.t

package info (click to toggle)
libxml-compile-perl 1.47-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,224 kB
  • ctags: 355
  • sloc: perl: 11,042; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 1,220 bytes parent folder | download | duplicates (5)
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
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env perl

use warnings;
use strict;

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

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

use Test::More tests => 17;

set_compile_defaults
    elements_qualified => 'NONE';

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

<!-- all with one element -->

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

<group name="g1">
  <sequence>
    <element name="g1_a" type="int" />
    <element name="g1_b" type="int" />
  </sequence>
</group>

<element name="test2">
  <complexType>
    <sequence>
      <group ref="me:g1" minOccurs="0" maxOccurs="unbounded" />
    </sequence>
  </complexType>
</element>

</schema>
__SCHEMA__

ok(defined $schema);
my $error;

test_rw($schema, test1 => <<__XML, {g1_a => 10, g1_b => 11});
<test1><g1_a>10</g1_a><g1_b>11</g1_b></test1>
__XML

my %g2a =
 (gr_g1 =>
    [ { g1_a => 12, g1_b => 13}
    , { g1_a => 14, g1_b => 15}
    ]
 );

test_rw($schema, test2 => <<__XML, \%g2a);
<test2>
  <g1_a>12</g1_a><g1_b>13</g1_b>
  <g1_a>14</g1_a><g1_b>15</g1_b>
</test2>
__XML