Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Changing namespaces?
Changing namespaces? [message #68265] Thu, 01 June 2006 19:42 Go to next message
Eclipse UserFriend
Originally posted by: stockina.fmi.uni-passau.de

Hi all,

I have the following problem:

I create a XSDComplexType and set name, namespace etc. Then I add it to
my schema. However, after adding it to the schema the namespace has changed.

Here a little code for demonstration:
XSDComplexTypeDefinition complexType =
factory.createXSDComplexTypeDefinition();
complexType.setName(name);
complexType.setTargetNamespace(namespace);
complexType.setBaseTypeDefinition(baseType);
complexType.setDerivationMethod(XSDDerivationMethod.EXTENSIO N_LITERAL);
System.out.println("A "+complexType);
schema.getContents().add(complexType);
System.out.println("B "+complexType);

The output is:

A org.eclipse.xsd.impl.XSDComplexTypeDefinitionImpl@1d10a5c (element:
null) (name: com.lizard.phoebe.plugin.model.JdbcConnection,
targetNamespace: http://www.lizardcreations.com/phoebe/plugin)
(derivationMethod: extension, final: null, abstract: <unset>,
contentTypeCategory: empty, prohibitedSubstitutions: null, lexicalFinal:
null, block: null, mixed: <unset>)

B org.eclipse.xsd.impl.XSDComplexTypeDefinitionImpl@1d10a5c (element:
null) (name: com.lizard.phoebe.plugin.model.JdbcConnection,
targetNamespace: http://www.lizardcreations.com/phoebe/test)
(derivationMethod: extension, final: [], abstract: <unset>,
contentTypeCategory: empty, prohibitedSubstitutions: [], lexicalFinal:
null, block: null, mixed: <unset>)

As you can see the namespace has changed after the call to
XSDSchema.getContents().add(). Any idea where this comes from?

Thanks for your help!

Alex
Re: Changing namespaces? [message #68277 is a reply to message #68265] Thu, 01 June 2006 19:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Alex,

The namespace of a complex type is determined by the namespace of the
containing schema. I.e., it's a derived property that can't be set.
After all, think about what a <schema> document looks like: there's
name="..." attribute on a <complexType>, but no targetNamespace="..."
attribute; only the <schema> has a targetNamespace="..." attribute.
Keep in mind too that if "baseType" comes from another schema, you'll
need to add an <import> to the schema that will the complex type that
references "baseType".


Alexander Stockinger wrote:
> Hi all,
>
> I have the following problem:
>
> I create a XSDComplexType and set name, namespace etc. Then I add it
> to my schema. However, after adding it to the schema the namespace has
> changed.
>
> Here a little code for demonstration:
> XSDComplexTypeDefinition complexType =
> factory.createXSDComplexTypeDefinition();
> complexType.setName(name);
> complexType.setTargetNamespace(namespace);
> complexType.setBaseTypeDefinition(baseType);
>
> complexType.setDerivationMethod(XSDDerivationMethod.EXTENSIO N_LITERAL);
> System.out.println("A "+complexType);
> schema.getContents().add(complexType);
> System.out.println("B "+complexType);
>
> The output is:
>
> A org.eclipse.xsd.impl.XSDComplexTypeDefinitionImpl@1d10a5c (element:
> null) (name: com.lizard.phoebe.plugin.model.JdbcConnection,
> targetNamespace: http://www.lizardcreations.com/phoebe/plugin)
> (derivationMethod: extension, final: null, abstract: <unset>,
> contentTypeCategory: empty, prohibitedSubstitutions: null,
> lexicalFinal: null, block: null, mixed: <unset>)
>
> B org.eclipse.xsd.impl.XSDComplexTypeDefinitionImpl@1d10a5c (element:
> null) (name: com.lizard.phoebe.plugin.model.JdbcConnection,
> targetNamespace: http://www.lizardcreations.com/phoebe/test)
> (derivationMethod: extension, final: [], abstract: <unset>,
> contentTypeCategory: empty, prohibitedSubstitutions: [], lexicalFinal:
> null, block: null, mixed: <unset>)
>
> As you can see the namespace has changed after the call to
> XSDSchema.getContents().add(). Any idea where this comes from?
>
> Thanks for your help!
>
> Alex
Re: Changing namespaces? [message #68287 is a reply to message #68277] Thu, 01 June 2006 20:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stockina.fmi.uni-passau.de

Hi Ed,

thanks for your quick reply.

So you say I can't put complex types with multiple target namespaces in
a single XSD? That would be a real drawback for XSD information created
on the fly and only stored in memory, wouldn't it? I think I can't
refernce a XSD via <import> when it's only available at runtime?

Cheers,
Alex

Ed Merks wrote:
> Alex,
>
> The namespace of a complex type is determined by the namespace of the
> containing schema. I.e., it's a derived property that can't be set.
> After all, think about what a <schema> document looks like: there's
> name="..." attribute on a <complexType>, but no targetNamespace="..."
> attribute; only the <schema> has a targetNamespace="..." attribute.
> Keep in mind too that if "baseType" comes from another schema, you'll
> need to add an <import> to the schema that will the complex type that
> references "baseType".
Re: Changing namespaces? [message #68298 is a reply to message #68287] Thu, 01 June 2006 20:56 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Alex,

You must create a schema instance just as what would be allowed by a
physical serialized instance. But you can create multiple schema
resources within the same resource set and thereby you'll be able to
create the import dependencies between them. Each resource has a URI
and you could make that URI just be the same as targetNamespace of the
schema it contains so that just creating an import for the namespace
will locate the correct schema resource in the resource set.


Alexander Stockinger wrote:
> Hi Ed,
>
> thanks for your quick reply.
>
> So you say I can't put complex types with multiple target namespaces
> in a single XSD? That would be a real drawback for XSD information
> created on the fly and only stored in memory, wouldn't it? I think I
> can't refernce a XSD via <import> when it's only available at runtime?
>
> Cheers,
> Alex
>
> Ed Merks wrote:
>> Alex,
>>
>> The namespace of a complex type is determined by the namespace of the
>> containing schema. I.e., it's a derived property that can't be set.
>> After all, think about what a <schema> document looks like: there's
>> name="..." attribute on a <complexType>, but no targetNamespace="..."
>> attribute; only the <schema> has a targetNamespace="..." attribute.
>> Keep in mind too that if "baseType" comes from another schema, you'll
>> need to add an <import> to the schema that will the complex type that
>> references "baseType".
Re: Changing namespaces? [message #598152 is a reply to message #68265] Thu, 01 June 2006 19:55 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Alex,

The namespace of a complex type is determined by the namespace of the
containing schema. I.e., it's a derived property that can't be set.
After all, think about what a <schema> document looks like: there's
name="..." attribute on a <complexType>, but no targetNamespace="..."
attribute; only the <schema> has a targetNamespace="..." attribute.
Keep in mind too that if "baseType" comes from another schema, you'll
need to add an <import> to the schema that will the complex type that
references "baseType".


Alexander Stockinger wrote:
> Hi all,
>
> I have the following problem:
>
> I create a XSDComplexType and set name, namespace etc. Then I add it
> to my schema. However, after adding it to the schema the namespace has
> changed.
>
> Here a little code for demonstration:
> XSDComplexTypeDefinition complexType =
> factory.createXSDComplexTypeDefinition();
> complexType.setName(name);
> complexType.setTargetNamespace(namespace);
> complexType.setBaseTypeDefinition(baseType);
>
> complexType.setDerivationMethod(XSDDerivationMethod.EXTENSIO N_LITERAL);
> System.out.println("A "+complexType);
> schema.getContents().add(complexType);
> System.out.println("B "+complexType);
>
> The output is:
>
> A org.eclipse.xsd.impl.XSDComplexTypeDefinitionImpl@1d10a5c (element:
> null) (name: com.lizard.phoebe.plugin.model.JdbcConnection,
> targetNamespace: http://www.lizardcreations.com/phoebe/plugin)
> (derivationMethod: extension, final: null, abstract: <unset>,
> contentTypeCategory: empty, prohibitedSubstitutions: null,
> lexicalFinal: null, block: null, mixed: <unset>)
>
> B org.eclipse.xsd.impl.XSDComplexTypeDefinitionImpl@1d10a5c (element:
> null) (name: com.lizard.phoebe.plugin.model.JdbcConnection,
> targetNamespace: http://www.lizardcreations.com/phoebe/test)
> (derivationMethod: extension, final: [], abstract: <unset>,
> contentTypeCategory: empty, prohibitedSubstitutions: [], lexicalFinal:
> null, block: null, mixed: <unset>)
>
> As you can see the namespace has changed after the call to
> XSDSchema.getContents().add(). Any idea where this comes from?
>
> Thanks for your help!
>
> Alex


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Changing namespaces? [message #598159 is a reply to message #68277] Thu, 01 June 2006 20:16 Go to previous message
Alexander Stockinger is currently offline Alexander StockingerFriend
Messages: 8
Registered: July 2009
Junior Member
Hi Ed,

thanks for your quick reply.

So you say I can't put complex types with multiple target namespaces in
a single XSD? That would be a real drawback for XSD information created
on the fly and only stored in memory, wouldn't it? I think I can't
refernce a XSD via <import> when it's only available at runtime?

Cheers,
Alex

Ed Merks wrote:
> Alex,
>
> The namespace of a complex type is determined by the namespace of the
> containing schema. I.e., it's a derived property that can't be set.
> After all, think about what a <schema> document looks like: there's
> name="..." attribute on a <complexType>, but no targetNamespace="..."
> attribute; only the <schema> has a targetNamespace="..." attribute.
> Keep in mind too that if "baseType" comes from another schema, you'll
> need to add an <import> to the schema that will the complex type that
> references "baseType".
Re: Changing namespaces? [message #598166 is a reply to message #68287] Thu, 01 June 2006 20:56 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Alex,

You must create a schema instance just as what would be allowed by a
physical serialized instance. But you can create multiple schema
resources within the same resource set and thereby you'll be able to
create the import dependencies between them. Each resource has a URI
and you could make that URI just be the same as targetNamespace of the
schema it contains so that just creating an import for the namespace
will locate the correct schema resource in the resource set.


Alexander Stockinger wrote:
> Hi Ed,
>
> thanks for your quick reply.
>
> So you say I can't put complex types with multiple target namespaces
> in a single XSD? That would be a real drawback for XSD information
> created on the fly and only stored in memory, wouldn't it? I think I
> can't refernce a XSD via <import> when it's only available at runtime?
>
> Cheers,
> Alex
>
> Ed Merks wrote:
>> Alex,
>>
>> The namespace of a complex type is determined by the namespace of the
>> containing schema. I.e., it's a derived property that can't be set.
>> After all, think about what a <schema> document looks like: there's
>> name="..." attribute on a <complexType>, but no targetNamespace="..."
>> attribute; only the <schema> has a targetNamespace="..." attribute.
>> Keep in mind too that if "baseType" comes from another schema, you'll
>> need to add an <import> to the schema that will the complex type that
>> references "baseType".


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Changing namespaces?
Next Topic:Problem while serializing xsd schema
Goto Forum:
  


Current Time: Sat Apr 20 02:07:42 GMT 2024

Powered by FUDForum. Page generated in 0.03659 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top