Source

XML-LibXML-CData-Bug-Reproduce / t / 21types.t

#!/usr/bin/perl

# Copyrights 2006-2012 by [Mark Overmeer].
#  For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.00.
use warnings;
use strict;

use XML::Compile::Schema;

use Data::Dumper qw/Dumper/;

our $TestNS    = 'http://test-types';
our $SchemaNS  =  'http://www.w3.org/2001/XMLSchema';


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

<element name="test1" type="int" />
<element name="test2" type="boolean" />
<element name="test3" type="float" />
<element name="test4" type="NMTOKENS" />
<element name="test5" type="positiveInteger" />
<element name="test6" type="base64Binary" />
<element name="test7" type="dateTime" />
<element name="test8" type="duration" />
<element name="test9" type="hexBinary" />
<element name="testA" type="string" />

</schema>
__SCHEMA__

my @compile_defaults = (elements_qualified => 'NONE');

my $xml = '<testA><![CDATA[abc]]></testA>';

my $h2 = XML::LibXML::CDATASection->new('abc');

my $test = 'testA';

my $type = "{$TestNS}$test";

my $r = $schema->compile
     ( READER             => $type
     , check_values       => 1
     , include_namespaces => 0
     , @compile_defaults
     );

my $h = $r->($xml);

my $writer = $schema->compile
( WRITER                => $type
    , check_values          => 1
    , include_namespaces    => 0
    , use_default_namespace => 1
    , @compile_defaults
);



my $dupl;
{ no strict; $dupl = eval Dumper $h2 }