Hi Peter,

On Wed, Nov 25, 2009 at 4:04 PM, Peter A. Bigot <[email protected]> wrote:

> Just because a namespace is default within a schema doesn't mean it has to
> be default in documents that use components from that schema.   Also, it may
> not be a good thing to use the namespace of the top-level element as the
> default when generating documents from an instance; if most of the
> interesting elements are in a different namespace (as often happens with
> SOAP messages), that namespace would be a better selection as default.
>

Selecting the default namespace appears to be more of an art than I
thought.  Taking the suggestion for the default from the schema's namespace
map seems like a good idea to me.  I know it won't fit in all cases, but I
don't see a better approach for automation.


> If multiple namespaces are being used and I wanted something more
> informative than "ns1", I'd probably use the customization feature or a
> library initialization routine to declare in the global BDS a default
> preferred prefix for each namespace, and not configure a default namespace
> at all.  Unless configured through BindingDOMSupport.SetDefaultNamespace,
> the generated documents have no default namespace.


The Castor-generated bindings that I have to interoperate with seem to be
expecting a default namespace, otherwise I'd love to avoid the default
namespace issue entirely.  I shouldn't be so concerned with the aesthetics,
it would look nicer with the prefixes I'm sure, but the Castor output uses
ns1 and that should be good enough.


> Perhaps an alternative enhancement would be to have a global flag that uses
> the namespace of the top-level element as the default in this situation.
>  That's an enhancement I could see adding.  Or, use the name of the module
> into which the namespace bindings were generated as the default prefix for
> that namespace (in fact there're hooks in PyXB for that sort of thing, and I
> can't remember why I've added and then removed the feature several times).
>

The global flag idea sound promising.  Would you take the targetNamespace
from the schema element or something else?  I'm getting over the whole
prefix idea as it seems to be more trouble than it's worth.


> What happens when no bds instance is provided in a toxml() call is that a
> new one is created, initialized from the global defaults, used for the
> entire tree, then discarded.  This is necessary because the namespace/prefix
> map in the instance is updated based on the namespaces encountered when
> walking the instance tree.  If these instances were re-used, you could get a
> bunch of namespace declarations that weren't relevant to the particular
> document.  Trying to configure per-namespace defaults that handle
> multi-namespace documents could get very confusing.
>

I read the code for the toxml() method, which is how I got the idea for a
default BDS in each binding module Python file.  The custom code I was
writing redefined toxml()'s default parameter for the bds item from None to
a global BDS instance.  Then, I'd define a global BDS instance with the
default namespace and prefix information from the raw bindings.  It was
pretty easy to do.  (As yet, I haven't found the namespace or prefix
information; I'm sure its there somewhere.)  The idea works because, as you
said above, the values from the provided BDS is used in the tree and no
others.  The BDS instances are confined to the binding module's Python file,
so there would be no conflict or overlaps.


> At the moment, I'm not convinced a per-namespace default BDS configuration
> would be a good thing, but if you still think it would be useful, yes,
> please file an enhancement request in trac.  Include the details on these
> use cases, and any preferences you have on the interface and semantics,
> especially in cases where instance objects that reference multiple
> namespaces are concerned.  For example, it would be legal to add a new
> default namespace declaration at each element where it changes, which is
> perhaps more consistent with the "different default namespace per schema"
> perspective.
>
> <?xml version="1.0" ?>
> <Container xmlns="urn:Container:1.0" xmlns:cdb="urn:CDB:1.0">
>    <Autoload>
>        <_ string="baci" xmlns="urn:CDB:1.0"/>
>    </Autoload>
>
>    <LoggingConfig centralizedLogger="Log" dispatchPacketSize="0"
>        immediateDispatchLevel="99" minLogLevel="2"/>
> </Container>
>
> Peter
>

I don't believe I have a strong enough argument for the per-binding module
BDS instance.  It would be useful to me, but I'm doubtful that anyone else
would want it.  Setting the default namespace option would probably be more
useful in general.

Regards,

Arne
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pyxb-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyxb-users

Reply via email to