Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Changing XSDSchema / Clone
Changing XSDSchema / Clone [message #74241] Mon, 21 April 2008 17:38 Go to next message
Eclipse User
Originally posted by: spotthoff.gmx.de

Hi,
I am trying to change a XSDSchema Object. In my use case I want to change
just a copy of this schema not the original one.

Everything seems to work fine but the cloning does not clone the complexe
types as it seems. In my understanding both lines below should have the
same result concerning the code at the end.
All complexe Types are null. Why? Where is my fault?

1. change.test((XSDSchema)schema.cloneConcreteComponent(true, false));
2. change.test(schema);

But the result of statement 1 is:
bla 2: SKU - org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@1a99561
(element: null) (name: SKU, targetNamespace: null) (variety: <unset>,
final: null, lexicalFinal: null, validFacets: null)
bla 2: USState - org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@8e32e7
(element: null) (name: USState, targetNamespace: null) (variety: <unset>,
final: null, lexicalFinal: null, validFacets: null)


and of statement 2:
bla 1: herstellerorg.eclipse.xsd.impl.XSDParticleImpl@1a99561 (element:
[xs:all: null]) (minOccurs: <unset>, maxOccurs: <unset>)
bla 1: Itemsorg.eclipse.xsd.impl.XSDParticleImpl@8e32e7 (element:
[xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
bla 1: partsorg.eclipse.xsd.impl.XSDParticleImpl@1b000e7 (element:
[xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
bla 1: PurchaseOrderTypeorg.eclipse.xsd.impl.XSDParticleImpl@b76fa
(element: [xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
bla 2: SKU - org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@b01d43
(element: [xs:simpleType: null]) (name: SKU, targetNamespace: null)
(variety: atomic, final: [], lexicalFinal: null, validFacets: [length,
minLength, maxLength, pattern, enumeration, whiteSpace])
bla 1: USAddressorg.eclipse.xsd.impl.XSDParticleImpl@513cf0 (element:
[xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
bla 2: USState - org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@177b3cd
(element: [xs:simpleType: null]) (name: USState, targetNamespace: null)
(variety: atomic, final: [], lexicalFinal: null, validFacets: [length,
minLength, maxLength, pattern, enumeration, whiteSpace])


#### Test Code:
private void test(XSDSchema s){
XSDTypeDefinition type = null;

EList <XSDTypeDefinition> types = s.getTypeDefinitions();
for(Iterator<XSDTypeDefinition> it = types.iterator();
it.hasNext();){
XSDTypeDefinition typ = it.next();
if(typ.getComplexType()!= null){
XSDParticle t = typ.getComplexType();
System.out.println("bla1: " + typ.getName() + t);
}
if(typ.getSimpleType()!= null){
System.out.println("bla2: " + typ.getName() +
typ.getSimpleType());
}
}
}
Re: Changing XSDSchema / Clone [message #74259 is a reply to message #74241] Mon, 21 April 2008 18:12 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Spotti,

I'm really not sure I understand 1. verses 2... Keep in mind that
imports and includes will not be resolved if
xsdSchema.getSchemaLocation() == null; generally the schema location
will be set when the XSDSchema is added to an XSDResourceImpl's
getContents, at which point the location will be set to the resource's
URI...



spotti wrote:
> Hi,
> I am trying to change a XSDSchema Object. In my use case I want to
> change just a copy of this schema not the original one.
>
> Everything seems to work fine but the cloning does not clone the
> complexe types as it seems. In my understanding both lines below
> should have the same result concerning the code at the end. All
> complexe Types are null. Why? Where is my fault?
>
> 1. change.test((XSDSchema)schema.cloneConcreteComponent(true, false));
> 2. change.test(schema);
>
> But the result of statement 1 is:
> bla 2: SKU - org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@1a99561
> (element: null) (name: SKU, targetNamespace: null) (variety: <unset>,
> final: null, lexicalFinal: null, validFacets: null)
> bla 2: USState -
> org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@8e32e7 (element:
> null) (name: USState, targetNamespace: null) (variety: <unset>, final:
> null, lexicalFinal: null, validFacets: null)
>
>
> and of statement 2:
> bla 1: herstellerorg.eclipse.xsd.impl.XSDParticleImpl@1a99561
> (element: [xs:all: null]) (minOccurs: <unset>, maxOccurs: <unset>)
> bla 1: Itemsorg.eclipse.xsd.impl.XSDParticleImpl@8e32e7 (element:
> [xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
> bla 1: partsorg.eclipse.xsd.impl.XSDParticleImpl@1b000e7 (element:
> [xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
> bla 1: PurchaseOrderTypeorg.eclipse.xsd.impl.XSDParticleImpl@b76fa
> (element: [xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
> bla 2: SKU - org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@b01d43
> (element: [xs:simpleType: null]) (name: SKU, targetNamespace: null)
> (variety: atomic, final: [], lexicalFinal: null, validFacets: [length,
> minLength, maxLength, pattern, enumeration, whiteSpace])
> bla 1: USAddressorg.eclipse.xsd.impl.XSDParticleImpl@513cf0 (element:
> [xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
> bla 2: USState -
> org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@177b3cd (element:
> [xs:simpleType: null]) (name: USState, targetNamespace: null)
> (variety: atomic, final: [], lexicalFinal: null, validFacets: [length,
> minLength, maxLength, pattern, enumeration, whiteSpace])
>
>
> #### Test Code:
> private void test(XSDSchema s){
> XSDTypeDefinition type = null;
> EList <XSDTypeDefinition> types = s.getTypeDefinitions();
> for(Iterator<XSDTypeDefinition> it = types.iterator();
> it.hasNext();){
> XSDTypeDefinition typ = it.next();
> if(typ.getComplexType()!= null){
> XSDParticle t = typ.getComplexType();
> System.out.println("bla1: " + typ.getName() + t);
> }
> if(typ.getSimpleType()!= null){
> System.out.println("bla2: " + typ.getName() +
> typ.getSimpleType());
> }
> }
> }
>
Re: Changing XSDSchema / Clone [message #74275 is a reply to message #74259] Mon, 21 April 2008 18:35 Go to previous messageGo to next message
Eclipse User
Originally posted by: spotthoff.gmx.de

The difference between these examples lies in the output. The schema
object in version one does not have any complexe types which are not null.
In version 2, the uncloned schema object, simple AND complexe type are
found which are not null.

my example xsd-file does not have any imports or includes. It is confusing
that SimpleTypeDefinitions are not null contrasting the complexe types.
My goal is to change the schema and decide later whether to write the new
or the old unchanged schema. While the changes are done on the new
version(or copy) I read out the old one. Therefor I need both versions.
Otherwise I get an exception.
Re: Changing XSDSchema / Clone [message #74291 is a reply to message #74275] Mon, 21 April 2008 19:33 Go to previous message
Eclipse User
Originally posted by: merks.ca.ibm.com

Spotti,

References to types, even if they are in the same schema, will not be
resolved until the schema is assigned a schema location. In fact, all
references will resolve to placeholders (objects not contained by any
schema) until the schema location has been set. So, in general, a
schema that's not contained in XSDResourceImpl (which indirectly sets
the resource's URI as the schema's location) will not be all that
functionally completely. If you want to work with a schema that's fully
analyzed and has properly resolved references it will need to be in a
resource within a resource set.


spotti wrote:
> The difference between these examples lies in the output. The schema
> object in version one does not have any complexe types which are not
> null. In version 2, the uncloned schema object, simple AND complexe
> type are found which are not null.
>
> my example xsd-file does not have any imports or includes. It is
> confusing that SimpleTypeDefinitions are not null contrasting the
> complexe types.
> My goal is to change the schema and decide later whether to write the
> new or the old unchanged schema. While the changes are done on the new
> version(or copy) I read out the old one. Therefor I need both
> versions. Otherwise I get an exception.
>
Re: Changing XSDSchema / Clone [message #602980 is a reply to message #74241] Mon, 21 April 2008 18:12 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26010
Registered: July 2009
Senior Member
Spotti,

I'm really not sure I understand 1. verses 2... Keep in mind that
imports and includes will not be resolved if
xsdSchema.getSchemaLocation() == null; generally the schema location
will be set when the XSDSchema is added to an XSDResourceImpl's
getContents, at which point the location will be set to the resource's
URI...



spotti wrote:
> Hi,
> I am trying to change a XSDSchema Object. In my use case I want to
> change just a copy of this schema not the original one.
>
> Everything seems to work fine but the cloning does not clone the
> complexe types as it seems. In my understanding both lines below
> should have the same result concerning the code at the end. All
> complexe Types are null. Why? Where is my fault?
>
> 1. change.test((XSDSchema)schema.cloneConcreteComponent(true, false));
> 2. change.test(schema);
>
> But the result of statement 1 is:
> bla 2: SKU - org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@1a99561
> (element: null) (name: SKU, targetNamespace: null) (variety: <unset>,
> final: null, lexicalFinal: null, validFacets: null)
> bla 2: USState -
> org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@8e32e7 (element:
> null) (name: USState, targetNamespace: null) (variety: <unset>, final:
> null, lexicalFinal: null, validFacets: null)
>
>
> and of statement 2:
> bla 1: herstellerorg.eclipse.xsd.impl.XSDParticleImpl@1a99561
> (element: [xs:all: null]) (minOccurs: <unset>, maxOccurs: <unset>)
> bla 1: Itemsorg.eclipse.xsd.impl.XSDParticleImpl@8e32e7 (element:
> [xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
> bla 1: partsorg.eclipse.xsd.impl.XSDParticleImpl@1b000e7 (element:
> [xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
> bla 1: PurchaseOrderTypeorg.eclipse.xsd.impl.XSDParticleImpl@b76fa
> (element: [xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
> bla 2: SKU - org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@b01d43
> (element: [xs:simpleType: null]) (name: SKU, targetNamespace: null)
> (variety: atomic, final: [], lexicalFinal: null, validFacets: [length,
> minLength, maxLength, pattern, enumeration, whiteSpace])
> bla 1: USAddressorg.eclipse.xsd.impl.XSDParticleImpl@513cf0 (element:
> [xs:sequence: null]) (minOccurs: <unset>, maxOccurs: <unset>)
> bla 2: USState -
> org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl@177b3cd (element:
> [xs:simpleType: null]) (name: USState, targetNamespace: null)
> (variety: atomic, final: [], lexicalFinal: null, validFacets: [length,
> minLength, maxLength, pattern, enumeration, whiteSpace])
>
>
> #### Test Code:
> private void test(XSDSchema s){
> XSDTypeDefinition type = null;
> EList <XSDTypeDefinition> types = s.getTypeDefinitions();
> for(Iterator<XSDTypeDefinition> it = types.iterator();
> it.hasNext();){
> XSDTypeDefinition typ = it.next();
> if(typ.getComplexType()!= null){
> XSDParticle t = typ.getComplexType();
> System.out.println("bla1: " + typ.getName() + t);
> }
> if(typ.getSimpleType()!= null){
> System.out.println("bla2: " + typ.getName() +
> typ.getSimpleType());
> }
> }
> }
>
Re: Changing XSDSchema / Clone [message #602984 is a reply to message #74259] Mon, 21 April 2008 18:35 Go to previous message
Eclipse User
Originally posted by: spotthoff.gmx.de

The difference between these examples lies in the output. The schema
object in version one does not have any complexe types which are not null.
In version 2, the uncloned schema object, simple AND complexe type are
found which are not null.

my example xsd-file does not have any imports or includes. It is confusing
that SimpleTypeDefinitions are not null contrasting the complexe types.
My goal is to change the schema and decide later whether to write the new
or the old unchanged schema. While the changes are done on the new
version(or copy) I read out the old one. Therefor I need both versions.
Otherwise I get an exception.
Re: Changing XSDSchema / Clone [message #602988 is a reply to message #74275] Mon, 21 April 2008 19:33 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26010
Registered: July 2009
Senior Member
Spotti,

References to types, even if they are in the same schema, will not be
resolved until the schema is assigned a schema location. In fact, all
references will resolve to placeholders (objects not contained by any
schema) until the schema location has been set. So, in general, a
schema that's not contained in XSDResourceImpl (which indirectly sets
the resource's URI as the schema's location) will not be all that
functionally completely. If you want to work with a schema that's fully
analyzed and has properly resolved references it will need to be in a
resource within a resource set.


spotti wrote:
> The difference between these examples lies in the output. The schema
> object in version one does not have any complexe types which are not
> null. In version 2, the uncloned schema object, simple AND complexe
> type are found which are not null.
>
> my example xsd-file does not have any imports or includes. It is
> confusing that SimpleTypeDefinitions are not null contrasting the
> complexe types.
> My goal is to change the schema and decide later whether to write the
> new or the old unchanged schema. While the changes are done on the new
> version(or copy) I read out the old one. Therefor I need both
> versions. Otherwise I get an exception.
>
Previous Topic:Changing XSDSchema / Clone
Next Topic:Can't get XSD graphical editor working...
Goto Forum:
  


Current Time: Wed Aug 27 15:23:43 EDT 2014

Powered by FUDForum. Page generated in 0.01723 seconds