#!/usr/bin/perl
# Test schemas unqualified schemas with target-namespace
use warnings;
use strict;
use lib 'lib','t';
use TestTools;
use XML::Compile::Schema;
use XML::Compile::Tester;
use Test::More tests => 27;
set_compile_defaults
include_namespaces => 1
, prefixes => [ me => $TestNS ];
# targetNamespace and elementFormDefault just to add confusion.
my $s = <<__SCHEMA;
__SCHEMA
my $schema = XML::Compile::Schema->new($s
, target_namespace => $TestNS
, element_form_default => 'qualified'
);
ok(defined $schema, 'compiled schema');
is(join("\n", join "\n", $schema->types)."\n", "{$TestNS}ct1\n");
is(join("\n", join "\n", $schema->elements)."\n", <<__ELEMS__);
{$TestNS}test1
{$TestNS}test2
{$TestNS}test4
__ELEMS__
test_rw($schema, test1 => <<__XML, 10);
10
__XML
test_rw($schema, test2 => <<__XML, {c1_a => 11});
11
__XML
my %t4 = (c1_a => 14, a1_a => 15, c4_a => 16, a4_a => 17);
test_rw($schema, test4 => <<__XML, \%t4);
14
16
__XML