Home » Archived » XML Schema Definition (XSD) » Changing namespaces?
Changing namespaces? [message #68265] |
Thu, 01 June 2006 15:42  |
Eclipse User |
|
|
|
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 15:55   |
Eclipse User |
|
|
|
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 #68298 is a reply to message #68287] |
Thu, 01 June 2006 16:56  |
Eclipse User |
|
|
|
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 15:55  |
Eclipse User |
|
|
|
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 #598159 is a reply to message #68277] |
Thu, 01 June 2006 16:16  |
Eclipse User |
|
|
|
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 16:56  |
Eclipse User |
|
|
|
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".
|
|
|
Goto Forum:
Current Time: Sat May 10 07:35:35 EDT 2025
Powered by FUDForum. Page generated in 0.03992 seconds
|