=head1 NAME

XML::Compile::Schema::NameSpaces - Connect name-spaces from schemas

=head1 SYNOPSIS

 # Used internally by XML::Compile::Schema
 my $nss = XML::Compile::Schema::NameSpaces->new;
 $nss->add($schema);

=head1 DESCRIPTION

This module keeps overview on a set of namespaces, collected from various
schema files.  Per XML namespace, it will collect a list of fragments
which contain definitions for the namespace, each fragment comes from a
different source.  These fragments are searched in reverse order when
an element or type is looked up (the last definitions overrule the
older definitions).

=head1 METHODS

=head2 Constructors

$obj-E<gt>B<new>(OPTIONS)

=over 4

=back

=head2 Accessors

$obj-E<gt>B<add>(SCHEMA, [SCHEMAS])

=over 4

Add L<XML::Compile::Schema::Instance|XML::Compile::Schema::Instance> objects to the internal
knowledge of this object.

=back

$obj-E<gt>B<allSchemas>

=over 4

Returns a list of all known schema instances.

=back

$obj-E<gt>B<find>(KIND, ADDRESS|(URI,NAME), OPTIONS)

=over 4

Lookup the definition for the specified KIND of definition: the name
of a global element, global attribute, attributeGroup or model group.
The ADDRESS is constructed as C< {uri}name > or as seperate URI and NAME.

 Option      --Default
 include_used  <true>

. include_used => BOOLEAN

=back

$obj-E<gt>B<findID>(ADDRESS|(URI,ID))

=over 4

Lookup the definition for the specified id, which is constructed as
C< uri#id > or as seperate URI and ID.

=back

$obj-E<gt>B<findSgMembers>(TYPE|(URI,NAME))

=over 4

Lookup the substitutionGroup alternatives for a specific element, which
is an TYPE (element full name) of form C< {uri}name > or as seperate
URI and NAME.  Returned is a list of node info objects (HASHes)

=back

$obj-E<gt>B<list>

=over 4

Returns the list of name-space URIs defined.

=back

$obj-E<gt>B<namespace>(URI)

=over 4

Returns a list of L<XML::Compile::Schema::Instance|XML::Compile::Schema::Instance> objects which have
the URI as target namespace.

=back

$obj-E<gt>B<printIndex>([FILEHANDLE], OPTIONS)

=over 4

Show all definitions from all namespaces, for debugging purposes, by
default the selected.  Additional OPTIONS are passed to 
L<XML::Compile::Schema::Instance::printIndex()|XML::Compile::Schema::Instance/"Index">.

 Option      --Default
 include_used  <true>
 namespace     <ALL>

. include_used => BOOLEAN

=over 4

Show also the index from all the schema objects which are defined
to be usable as well; which were included via L<use()|XML::Compile::Schema::NameSpaces/"Accessors">.

=back

. namespace => URI|ARRAY-of-URI

=over 4

Show only information about the indicate namespaces.

=back

example: 

 my $nss = $schema->namespaces;
 $nss->printIndex(\*MYFILE);
 $nss->printIndex(namespace => "my namespace");

 # types defined in the wsdl schema
 use XML::Compile::SOAP::Util qw/WSDL11/;
 $nss->printIndex(\*STDERR, namespace => WSDL11);

=back

$obj-E<gt>B<schemas>(URI)

=over 4

We need the name-space; when it is lacking then import must help, but that
must be called explictly.

=back

$obj-E<gt>B<use>(OBJECT)

=over 4

Use any other L<XML::Compile::Schema|XML::Compile::Schema> extension as fallback, if the
L<find()|XML::Compile::Schema::NameSpaces/"Accessors"> does not succeed for the current object.  Searches for
definitions do not recurse into the used object.

Returns the list of all used OBJECTS.
This method implements L<XML::Compile::Schema::useSchema()|XML::Compile::Schema/"Accessors">.

=back

=head1 SEE ALSO

This module is part of XML-Compile distribution version 1.12,
built on January 11, 2010. Website: F<http://perl.overmeer.net/xml-compile/>

All modules in this suite:
L<XML::Compile>,
L<XML::Compile::SOAP>,
L<XML::Compile::SOAP12>,
L<XML::Compile::SOAP::Daemon>,
L<XML::Compile::Tester>,
L<XML::Compile::Cache>,
L<XML::Compile::Dumper>,
L<XML::Compile::RPC>,
and
L<XML::Rewrite>,
L<XML::ExistDB>,
L<XML::LibXML::Simple>.

Please post questions or ideas to the mailinglist at
F<http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile>
For life contact with other developers, visit the C<#xml-compile> channel
on C<irc.perl.org>.

=head1 LICENSE

Copyrights 2006-2010 by Mark Overmeer. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://www.perl.com/perl/misc/Artistic.html>

