[Xml-compile] xsi:type support

Mark Overmeer mark at overmeer.net
Mon Jan 11 10:14:57 GMT 2010


* Roman Daniel (roman.daniel at davosro.cz) [100111 09:47]:
> 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

The xsi:type builds a switch, on the moment that the schema is processed.
However, the schema did not know about the namespace for your xsi:type
extension: it did not have a prefix defined for it.

Simple fix XML/Compile/Translate.pm line 748:

    my %alt = ($comptype => $do3);
    foreach my $alttype (@{$self->{xsi_type}{$comptype}})
    {   my ($ns, $local) = unpack_type $alttype;
        my $prefix  = $node->lookupNamespacePrefix($ns);
 +      $prefix   ||= $self->_registerNSprefix('x', $ns, 1);
        my $type    = length $prefix ? "$prefix:$local" : $local;

        my $doc     = $node->ownerDocument;
        my $altnode = $doc->createElementNS(SCHEMA2001, 'element');
        $altnode->setNamespace($ns => $prefix);
        $altnode->setAttribute(name => $name);
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




More information about the Xml-compile mailing list