[Xml-compile] xsi:type namespace

Brendan Knox knox.brendan at gmail.com
Mon Mar 22 04:41:22 GMT 2010


Hi Mark,

I tried that change out and it works very well, thank you!

Cheers,
Brendan


On Sat, Mar 20, 2010 at 5:00 AM, Mark Overmeer <mark at overmeer.net> wrote:

> * Brendan Knox (knox.brendan at gmail.com) [100303 02:22]:
> > I have recently been trying to use some schema that implement xsi:type.
> > Unfortunately one of the schema involved does not specify a namespace a=
nd
> I
> > believe this is causing some issues with the xsi:type mapping.
>
> The complication was nasty, but the changes modest... when I finally
> got a round tuit. Very small change.
>
> XML/Compile/Translate.pm:
>
>    # Ugly xsi:type switch needed
>    my %alt =3D ($comptype =3D> $do3);
>    foreach my $alttype (@{$self->{xsi_type}{$comptype}})
>    {   my ($ns, $local) =3D unpack_type $alttype;
>        my $prefix  =3D $node->lookupNamespacePrefix($ns);
>        defined $prefix or $prefix =3D $self->_registerNSprefix(undef, $ns,
> 1);
>        my $type    =3D length $prefix ? "$prefix:$local" : $local;
>
>        # do not accidentally use the default namespace, when there
>        # may also be namespace-less types used.
>         my $doc     =3D $node->ownerDocument;
>  -      my $altnode =3D $doc->createElementNS(SCHEMA2001, 'element');
>  +      my $altnode =3D $doc->createElement('element');
>  +      $altnode->setNamespace(SCHEMA2001, 'temp1234', 1);
>  +      $altnode->setNamespace($ns, $prefix);
>         $altnode->setAttribute(name =3D> $name);
>        $altnode->setAttribute(type =3D> $type);
>
>         my $altnodeid =3D $altnode->nodePath.'#'.$fullname;
>        delete $self->{_created}{$altnodeid}; # clean nesting cache
>
>        $alt{$alttype} =3D $self->element($tree->descend($altnode));
>    }
>
>    $self->makeXsiTypeSwitch($where, $name, $comptype, \%alt);
>
>
> --
> Regards,
>               MarkOv
>
> ------------------------------------------------------------------------
>       Mark Overmeer MSc                                MARKOV Solutions
>       Mark at Overmeer.net                          solutions at overmeer.net
> http://Mark.Overmeer.net                   http://solutions.overmeer.net
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20100322/31=
c8cfe8/attachment.htm


More information about the Xml-compile mailing list