[Xml-compile] xsi:type namespace
Mark Overmeer
mark at overmeer.net
Fri Mar 19 21:00:53 GMT 2010
* 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 and 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 = ($comptype => $do3);
foreach my $alttype (@{$self->{xsi_type}{$comptype}})
{ my ($ns, $local) = unpack_type $alttype;
my $prefix = $node->lookupNamespacePrefix($ns);
defined $prefix or $prefix = $self->_registerNSprefix(undef, $ns, 1);
my $type = length $prefix ? "$prefix:$local" : $local;
# do not accidentally use the default namespace, when there
# may also be namespace-less types used.
my $doc = $node->ownerDocument;
- my $altnode = $doc->createElementNS(SCHEMA2001, 'element');
+ my $altnode = $doc->createElement('element');
+ $altnode->setNamespace(SCHEMA2001, 'temp1234', 1);
+ $altnode->setNamespace($ns, $prefix);
$altnode->setAttribute(name => $name);
$altnode->setAttribute(type => $type);
my $altnodeid = $altnode->nodePath.'#'.$fullname;
delete $self->{_created}{$altnodeid}; # clean nesting cache
$alt{$alttype} = $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
More information about the Xml-compile
mailing list