Re: extending namespaces

On Feb 28, 2011, at 2:23 AM, Andrew Leslie wrote:

> Folks,
>  
> Rather than modifying a schema directly, I would like to explore the options of utilizing namespace extensions.
> One suggestion is to extend the namespace to include an extra xsd with certain elements declared and then call this from the parent  xsd.

If schema document Base.xsd is the base (pre-existing) definition
of a namespace, and your extensions are in Extensions.xsd, it
may sometimes be simpler to have Extensions.xsd include Base.xsd
instead of vice versa.

Of course, if you control both documents, it's six of one and a
half dozen of the other.

>  However, this is all well and good until a certain element is actually inserted, as all the namespace attributes are inserted with it.
> Similar to the S1000D  xlink (eg: <arc xmlns="http://www.w3.org/1999/xlink" xmlns:ns1="http://www.w3.org/1999/xlink" ns1:type="1" ns1:from="1" ns1:to="5"/>
>             <arc xmlns="http://www.w3.org/1999/xlink"/>)

I am not entirely certain that I understand the behavior you
are seeing, where you are seeing it, or why it's a problem.

Can you explain a bit more clearly?

It's all well and good until a certain element is actually
inserted where?  Do you mean until an element declaration
is added to the Extensions.xsd schema document?  Or
until an element instance is added to an instance document?

All the namespace attributes are inserted where?

If the example you are giving illustrates the point, it looks
rather as if you are saying "when we insert an element in 
namespace A into our document instance, with attributes 
in namespace B which are given non-default values, the 
authoring tool insists on making sure that namespaces 
A and B are both declared and in scope!  How can I stop 
that from happening?"

If that is what you are saying, then I think there is no 
solution to the problem short of a better understanding of
namespaces.

If on the other hand you're saying "The authoring tool is
ignoring the existing declarations for the namespaces in
question and adding new declarations with new prefixes",
then there are two possible solutions:  (1) figure out how to
tell the authoring tool to pay better attention to the existing
namespace declarations and reuse them where possible,
or (2) find the error which is causing the namespace declarations
you think are already in scope not to be in scope.  (Well,
three solutions, really:  you could also ask "why does it
matter if the tool inserts redundant namespace declarations?
What harm are they doing to anyone?"  They are unsightly,
perhaps, and if they really are unnecessary they may offend
the taste of those who read the XML source.  But those who
read XML source must inure themselves to insults to taste.)


> 
> Do you know of any way the schema or even the data in fact can be extended so that these certain elements can be inserted without the namespaces appearing within the attributes ?
> OR is the only  method to modify the schema directly ?
>  

Whether elements and attributes are declared in one schema
document or in a different schema document has nothing 
much to do with whether they are assigned an explicit 
namespace or not.  

It's possible that the underlying problem is that your schema
documents are inadvertently declaring things in namespaces
which you intended not to be given explicit namespaces.

A small but complete example illustrating the phenomenon
would probably make it a little easier to identify the source of
the difficulty.

I hope this helps.

-- 
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
****************************************************************

Received on Saturday, 5 March 2011 16:13:09 UTC