[Xml-compile] xsi:type support
Roman Daniel
roman.daniel at davosro.cz
Mon Jan 11 09:47:03 GMT 2010
Hi Mark,
maybe I don't understand the xsi:type support in READER.
I extracted a simple example from "real world" schema, but the compilation
failed:
Use of uninitialized value in length at
/usr/lib/perl5/site_perl/5.8.3/XML/Compile/Translate.pm line 677.
error: cannot find type {http://www.w3.org/2001/XMLSchema}SpecPayloadType at
{http://m.cz}Response/Payload
What is wrong?
Thank you for reply
Roman Daniel
#!/usr/bin/perl
use strict;
use warnings;
use XML::Compile::Schema;
my $schema1 =3D <<"END_SCHEMA";
<xs:schema
targetNamespace=3D"http://m.cz" elementFormDefault=3D"qualified"
xmlns:xs=3D"http://www.w3.org/2001/XMLSchema"
xmlns:tns=3D"http://m.cz">
<xs:complexType name=3D"PayloadType" abstract=3D"true" />
<xs:element name=3D"Response">
<xs:complexType>
<xs:sequence>
<xs:element name=3D"Payload" type=3D"tns:PayloadType" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
END_SCHEMA
my $schema2 =3D <<"END_SCHEMA";
<xs:schema
targetNamespace=3D"http://t.cz" elementFormDefault=3D"qualified"
xmlns:xs=3D"http://www.w3.org/2001/XMLSchema"
xmlns:tns=3D"http://t.cz">
<xs:complexType name=3D"SpecPayloadType">
<xs:sequence>
<xs:element name=3D"ticketId" type=3D"xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
END_SCHEMA
my $xml =3D <<END_XML;
<msg:Response xmlns:msg=3D"http://m.cz">
<msg:Payload xmlns:tts=3D"http://t.cz" xmlns:xsi=3D"
http://www.w3.org/2001/XMLSchema-instance" xsi:type=3D"tts:SpecPayloadType">
<tts:ticketId>99999999</tts:ticketId>
</msg:Payload>
</msg:Response>
END_XML
my $xs =3D XML::Compile::Schema->new;
$xs->importDefinitions($_) for $schema1, $schema2;
my $r =3D $xs->compile(
READER =3D> "{http://m.cz}Response",
xsi_type =3D> {
"{http://m.cz}PayloadType" =3D> [ "{http://t.cz}SpecPayloadType" ]
}
);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20100111/00=
04d268/attachment.htm
More information about the Xml-compile
mailing list