Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » xsdComplexType
xsdComplexType [message #48167] Mon, 21 June 2004 18:02 Go to next message
Eclipse UserFriend
Originally posted by: bikeev.gmx.net

How can a complex type defined in schema_A be copied into the schema_B.
There is an example showing how to do it on the schema elements but I am

failing to do the same for complex types.

Thanks,
Thomas
Re: xsdComplexType [message #48213 is a reply to message #48167] Mon, 21 June 2004 18:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Thomas,

What did you try that failed?


exquisitus wrote:

> How can a complex type defined in schema_A be copied into the schema_B.
> There is an example showing how to do it on the schema elements but I am
>
> failing to do the same for complex types.
>
> Thanks,
> Thomas
Re: xsdComplexType [message #48242 is a reply to message #48213] Mon, 21 June 2004 18:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bikeev.gmx.net

Hello Ed,

I have a ArrayList complexTypeDefinitions containing all the
XSDTypeDefinitions from initial schema.

I create a new schema and looping through ArrayList trying to write
the complexTypes out:

//////////////

//create new schema
XSDFactory xsdFactory = XSDFactory.eINSTANCE;
XSDSchema newSchema = xsdFactory.createXSDSchema();


newSchema.getQNamePrefixToNamespaceMap().putAll(oldSchema.ge tQNamePrefixToNamespaceMap());

for (Iterator iterator = complexTypeDefinitions.iterator();
iterator.hasNext();) {
XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)
iterator.next();
((XSDSchema) newSchema).getContents().
add((XSDComplexTypeDefinition)
xsdTypeDefinition.cloneConcreteComponent(true, false));
}

newSchema.updateElement();
resource.getContents().add(newSchema);
resourceSet.getResources().add(resource);
resource.save(Collections.EMPTY_MAP);

//////////////

I am getting:

org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
insert a node where it is not permitted.

- Thomas


Ed Merks wrote:

> Thomas,
>
> What did you try that failed?
>
>
> exquisitus wrote:
>
>
>>How can a complex type defined in schema_A be copied into the schema_B.
>>There is an example showing how to do it on the schema elements but I am
>>
>>failing to do the same for complex types.
>>
>>Thanks,
>>Thomas
>
>
Re: xsdComplexType [message #48272 is a reply to message #48242] Mon, 21 June 2004 18:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Thomas,

If you could send me a zipped up project that I can run to reproduce this problem, I'll have a
close look. Or at least show me the stack trace so I can see what's happening when the
failure strikes...


exquisitus wrote:

> Hello Ed,
>
> I have a ArrayList complexTypeDefinitions containing all the
> XSDTypeDefinitions from initial schema.
>
> I create a new schema and looping through ArrayList trying to write
> the complexTypes out:
>
> //////////////
>
> //create new schema
> XSDFactory xsdFactory = XSDFactory.eINSTANCE;
> XSDSchema newSchema = xsdFactory.createXSDSchema();
>
>
> newSchema.getQNamePrefixToNamespaceMap().putAll(oldSchema.ge tQNamePrefixToNamespaceMap());
>
> for (Iterator iterator = complexTypeDefinitions.iterator();
> iterator.hasNext();) {
> XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)
> iterator.next();
> ((XSDSchema) newSchema).getContents().
> add((XSDComplexTypeDefinition)
> xsdTypeDefinition.cloneConcreteComponent(true, false));
> }
>
> newSchema.updateElement();
> resource.getContents().add(newSchema);
> resourceSet.getResources().add(resource);
> resource.save(Collections.EMPTY_MAP);
>
> //////////////
>
> I am getting:
>
> org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
> insert a node where it is not permitted.
>
> - Thomas
>
> Ed Merks wrote:
>
> > Thomas,
> >
> > What did you try that failed?
> >
> >
> > exquisitus wrote:
> >
> >
> >>How can a complex type defined in schema_A be copied into the schema_B.
> >>There is an example showing how to do it on the schema elements but I am
> >>
> >>failing to do the same for complex types.
> >>
> >>Thanks,
> >>Thomas
> >
> >
Re: xsdComplexType [message #48302 is a reply to message #48272] Mon, 21 June 2004 18:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bikeev.gmx.net

Thanks Ed,

here is the trace - otherwise I will cut down the project using
XSDPrototypicalSchema.html and try to reproduce.

- Thomas

org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
insert a node where it is not permitted.
at
org.apache.xerces.dom.ParentNode.internalInsertBefore(Parent Node.java:413)
at org.apache.xerces.dom.ParentNode.insertBefore(ParentNode.jav a:322)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceNiceInser tBefore(XSDConcreteComponentImpl.java:1547)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.niceInsertBefo re(XSDConcreteComponentImpl.java:1478)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.handleElementF orAdopt(XSDConcreteComponentImpl.java:1331)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:360)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:361)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:352)
at Reader.main(Reader.java:88)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)



Ed Merks wrote:

> Thomas,
>
> If you could send me a zipped up project that I can run to reproduce this problem, I'll have a
> close look. Or at least show me the stack trace so I can see what's happening when the
> failure strikes...
>
>
> exquisitus wrote:
>
>
>>Hello Ed,
>>
>>I have a ArrayList complexTypeDefinitions containing all the
>>XSDTypeDefinitions from initial schema.
>>
>>I create a new schema and looping through ArrayList trying to write
>>the complexTypes out:
>>
>>//////////////
>>
>>//create new schema
>> XSDFactory xsdFactory = XSDFactory.eINSTANCE;
>> XSDSchema newSchema = xsdFactory.createXSDSchema();
>>
>>
>> newSchema.getQNamePrefixToNamespaceMap().putAll(oldSchema.ge tQNamePrefixToNamespaceMap());
>>
>> for (Iterator iterator = complexTypeDefinitions.iterator();
>>iterator.hasNext();) {
>> XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)
>>iterator.next();
>> ((XSDSchema) newSchema).getContents().
>> add((XSDComplexTypeDefinition)
>>xsdTypeDefinition.cloneConcreteComponent(true, false));
>> }
>>
>> newSchema.updateElement();
>> resource.getContents().add(newSchema);
>> resourceSet.getResources().add(resource);
>> resource.save(Collections.EMPTY_MAP);
>>
>>//////////////
>>
>>I am getting:
>>
>>org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
>>insert a node where it is not permitted.
>>
>> - Thomas
>>
>>Ed Merks wrote:
>>
>>
>>>Thomas,
>>>
>>>What did you try that failed?
>>>
>>>
>>>exquisitus wrote:
>>>
>>>
>>>
>>>>How can a complex type defined in schema_A be copied into the schema_B.
>>>>There is an example showing how to do it on the schema elements but I am
>>>>
>>>>failing to do the same for complex types.
>>>>
>>>>Thanks,
>>>>Thomas
>>>
>>>
>
Re: xsdComplexType [message #48331 is a reply to message #48272] Mon, 21 June 2004 19:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bikeev.gmx.net

Ed - please find Example and Exception below:
- Thomas

import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.XSDComplexTypeDefinition;
import org.eclipse.xsd.XSDFactory;
import org.eclipse.xsd.util.XSDPrototypicalSchema;
import org.eclipse.xsd.util.XSDResourceImpl;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.common.util.URI;

import java.util.Collections;
import java.io.IOException;

public class ComplexTypeTest {
public static void main(String[] args) throws IOException {

//get complex type from PO schema
XSDSchema po = XSDPrototypicalSchema.getPurchaseOrderSchema();
XSDComplexTypeDefinition poType =
po.resolveComplexTypeDefinition("PurchaseOrderType");

//create new schema
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = new XSDResourceImpl(URI.createURI("test.xsd"));
XSDFactory xsdFactory = XSDFactory.eINSTANCE;
XSDSchema newSchema = xsdFactory.createXSDSchema();

//clone complex types
((XSDSchema)
newSchema).getContents().add(poType.cloneConcreteComponent(t rue, false));

//add newSchema to the ressource and then save
newSchema.updateElement();
resource.getContents().add(newSchema);
resourceSet.getResources().add(resource);
resource.save(Collections.EMPTY_MAP);

System.exit(0);
}
}

Exception:
////////////////////////
org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
insert a node where it is not permitted.
at
org.apache.xerces.dom.ParentNode.internalInsertBefore(Parent Node.java:413)
at org.apache.xerces.dom.ParentNode.insertBefore(ParentNode.jav a:322)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceNiceInser tBefore(XSDConcreteComponentImpl.java:1547)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.niceInsertBefo re(XSDConcreteComponentImpl.java:1478)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.handleElementF orAdopt(XSDConcreteComponentImpl.java:1331)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:360)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:361)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:352)
at ComplexTypeTest.main(ComplexTypeTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
Exception in thread "main" Process terminated with exit code 1



Ed Merks wrote:

> Thomas,
>
> If you could send me a zipped up project that I can run to reproduce this problem, I'll have a
> close look. Or at least show me the stack trace so I can see what's happening when the
> failure strikes...
>
>
> exquisitus wrote:
>
>
>>Hello Ed,
>>
>>I have a ArrayList complexTypeDefinitions containing all the
>>XSDTypeDefinitions from initial schema.
>>
>>I create a new schema and looping through ArrayList trying to write
>>the complexTypes out:
>>
>>//////////////
>>
>>//create new schema
>> XSDFactory xsdFactory = XSDFactory.eINSTANCE;
>> XSDSchema newSchema = xsdFactory.createXSDSchema();
>>
>>
>> newSchema.getQNamePrefixToNamespaceMap().putAll(oldSchema.ge tQNamePrefixToNamespaceMap());
>>
>> for (Iterator iterator = complexTypeDefinitions.iterator();
>>iterator.hasNext();) {
>> XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)
>>iterator.next();
>> ((XSDSchema) newSchema).getContents().
>> add((XSDComplexTypeDefinition)
>>xsdTypeDefinition.cloneConcreteComponent(true, false));
>> }
>>
>> newSchema.updateElement();
>> resource.getContents().add(newSchema);
>> resourceSet.getResources().add(resource);
>> resource.save(Collections.EMPTY_MAP);
>>
>>//////////////
>>
>>I am getting:
>>
>>org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
>>insert a node where it is not permitted.
>>
>> - Thomas
>>
>>Ed Merks wrote:
>>
>>
>>>Thomas,
>>>
>>>What did you try that failed?
>>>
>>>
>>>exquisitus wrote:
>>>
>>>
>>>
>>>>How can a complex type defined in schema_A be copied into the schema_B.
>>>>There is an example showing how to do it on the schema elements but I am
>>>>
>>>>failing to do the same for complex types.
>>>>
>>>>Thanks,
>>>>Thomas
>>>
>>>
>
Re: xsdComplexType [message #48362 is a reply to message #48331] Mon, 21 June 2004 20:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Thomas,

I haven't had a chance to look closely, but I noticed that you haven't choosen a schema for schema
namespace for the new XSD. Doing that no doubt will help...


exquisitus wrote:

> Ed - please find Example and Exception below:
> - Thomas
>
> import org.eclipse.xsd.XSDSchema;
> import org.eclipse.xsd.XSDComplexTypeDefinition;
> import org.eclipse.xsd.XSDFactory;
> import org.eclipse.xsd.util.XSDPrototypicalSchema;
> import org.eclipse.xsd.util.XSDResourceImpl;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.common.util.URI;
>
> import java.util.Collections;
> import java.io.IOException;
>
> public class ComplexTypeTest {
> public static void main(String[] args) throws IOException {
>
> //get complex type from PO schema
> XSDSchema po = XSDPrototypicalSchema.getPurchaseOrderSchema();
> XSDComplexTypeDefinition poType =
> po.resolveComplexTypeDefinition("PurchaseOrderType");
>
> //create new schema
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource resource = new XSDResourceImpl(URI.createURI("test.xsd"));
> XSDFactory xsdFactory = XSDFactory.eINSTANCE;
> XSDSchema newSchema = xsdFactory.createXSDSchema();
>
> //clone complex types
> ((XSDSchema)
> newSchema).getContents().add(poType.cloneConcreteComponent(t rue, false));
>
> //add newSchema to the ressource and then save
> newSchema.updateElement();
> resource.getContents().add(newSchema);
> resourceSet.getResources().add(resource);
> resource.save(Collections.EMPTY_MAP);
>
> System.exit(0);
> }
> }
>
> Exception:
> ////////////////////////
> org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
> insert a node where it is not permitted.
> at
> org.apache.xerces.dom.ParentNode.internalInsertBefore(Parent Node.java:413)
> at org.apache.xerces.dom.ParentNode.insertBefore(ParentNode.jav a:322)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceNiceInser tBefore(XSDConcreteComponentImpl.java:1547)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.niceInsertBefo re(XSDConcreteComponentImpl.java:1478)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.handleElementF orAdopt(XSDConcreteComponentImpl.java:1331)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:360)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:361)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:352)
> at ComplexTypeTest.main(ComplexTypeTest.java:39)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
> Exception in thread "main" Process terminated with exit code 1
>
> Ed Merks wrote:
>
> > Thomas,
> >
> > If you could send me a zipped up project that I can run to reproduce this problem, I'll have a
> > close look. Or at least show me the stack trace so I can see what's happening when the
> > failure strikes...
> >
> >
> > exquisitus wrote:
> >
> >
> >>Hello Ed,
> >>
> >>I have a ArrayList complexTypeDefinitions containing all the
> >>XSDTypeDefinitions from initial schema.
> >>
> >>I create a new schema and looping through ArrayList trying to write
> >>the complexTypes out:
> >>
> >>//////////////
> >>
> >>//create new schema
> >> XSDFactory xsdFactory = XSDFactory.eINSTANCE;
> >> XSDSchema newSchema = xsdFactory.createXSDSchema();
> >>
> >>
> >> newSchema.getQNamePrefixToNamespaceMap().putAll(oldSchema.ge tQNamePrefixToNamespaceMap());
> >>
> >> for (Iterator iterator = complexTypeDefinitions.iterator();
> >>iterator.hasNext();) {
> >> XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)
> >>iterator.next();
> >> ((XSDSchema) newSchema).getContents().
> >> add((XSDComplexTypeDefinition)
> >>xsdTypeDefinition.cloneConcreteComponent(true, false));
> >> }
> >>
> >> newSchema.updateElement();
> >> resource.getContents().add(newSchema);
> >> resourceSet.getResources().add(resource);
> >> resource.save(Collections.EMPTY_MAP);
> >>
> >>//////////////
> >>
> >>I am getting:
> >>
> >>org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
> >>insert a node where it is not permitted.
> >>
> >> - Thomas
> >>
> >>Ed Merks wrote:
> >>
> >>
> >>>Thomas,
> >>>
> >>>What did you try that failed?
> >>>
> >>>
> >>>exquisitus wrote:
> >>>
> >>>
> >>>
> >>>>How can a complex type defined in schema_A be copied into the schema_B.
> >>>>There is an example showing how to do it on the schema elements but I am
> >>>>
> >>>>failing to do the same for complex types.
> >>>>
> >>>>Thanks,
> >>>>Thomas
> >>>
> >>>
> >
Re: xsdComplexType [message #48421 is a reply to message #48362] Mon, 21 June 2004 21:50 Go to previous message
Eclipse UserFriend
Originally posted by: bikeev.gmx.net

Ed -
many thanks - worked like spell !!!

- Thomas



Ed Merks wrote:
> Thomas,
>
> I haven't had a chance to look closely, but I noticed that you haven't choosen a schema for schema
> namespace for the new XSD. Doing that no doubt will help...
>
Re: xsdComplexType [message #589442 is a reply to message #48167] Mon, 21 June 2004 18:24 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Thomas,

What did you try that failed?


exquisitus wrote:

> How can a complex type defined in schema_A be copied into the schema_B.
> There is an example showing how to do it on the schema elements but I am
>
> failing to do the same for complex types.
>
> Thanks,
> Thomas


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: xsdComplexType [message #589458 is a reply to message #48213] Mon, 21 June 2004 18:43 Go to previous message
exquisitus is currently offline exquisitusFriend
Messages: 211
Registered: July 2009
Senior Member
Hello Ed,

I have a ArrayList complexTypeDefinitions containing all the
XSDTypeDefinitions from initial schema.

I create a new schema and looping through ArrayList trying to write
the complexTypes out:

//////////////

//create new schema
XSDFactory xsdFactory = XSDFactory.eINSTANCE;
XSDSchema newSchema = xsdFactory.createXSDSchema();


newSchema.getQNamePrefixToNamespaceMap().putAll(oldSchema.ge tQNamePrefixToNamespaceMap());

for (Iterator iterator = complexTypeDefinitions.iterator();
iterator.hasNext();) {
XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)
iterator.next();
((XSDSchema) newSchema).getContents().
add((XSDComplexTypeDefinition)
xsdTypeDefinition.cloneConcreteComponent(true, false));
}

newSchema.updateElement();
resource.getContents().add(newSchema);
resourceSet.getResources().add(resource);
resource.save(Collections.EMPTY_MAP);

//////////////

I am getting:

org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
insert a node where it is not permitted.

- Thomas


Ed Merks wrote:

> Thomas,
>
> What did you try that failed?
>
>
> exquisitus wrote:
>
>
>>How can a complex type defined in schema_A be copied into the schema_B.
>>There is an example showing how to do it on the schema elements but I am
>>
>>failing to do the same for complex types.
>>
>>Thanks,
>>Thomas
>
>
Re: xsdComplexType [message #589468 is a reply to message #48242] Mon, 21 June 2004 18:51 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Thomas,

If you could send me a zipped up project that I can run to reproduce this problem, I'll have a
close look. Or at least show me the stack trace so I can see what's happening when the
failure strikes...


exquisitus wrote:

> Hello Ed,
>
> I have a ArrayList complexTypeDefinitions containing all the
> XSDTypeDefinitions from initial schema.
>
> I create a new schema and looping through ArrayList trying to write
> the complexTypes out:
>
> //////////////
>
> //create new schema
> XSDFactory xsdFactory = XSDFactory.eINSTANCE;
> XSDSchema newSchema = xsdFactory.createXSDSchema();
>
>
> newSchema.getQNamePrefixToNamespaceMap().putAll(oldSchema.ge tQNamePrefixToNamespaceMap());
>
> for (Iterator iterator = complexTypeDefinitions.iterator();
> iterator.hasNext();) {
> XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)
> iterator.next();
> ((XSDSchema) newSchema).getContents().
> add((XSDComplexTypeDefinition)
> xsdTypeDefinition.cloneConcreteComponent(true, false));
> }
>
> newSchema.updateElement();
> resource.getContents().add(newSchema);
> resourceSet.getResources().add(resource);
> resource.save(Collections.EMPTY_MAP);
>
> //////////////
>
> I am getting:
>
> org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
> insert a node where it is not permitted.
>
> - Thomas
>
> Ed Merks wrote:
>
> > Thomas,
> >
> > What did you try that failed?
> >
> >
> > exquisitus wrote:
> >
> >
> >>How can a complex type defined in schema_A be copied into the schema_B.
> >>There is an example showing how to do it on the schema elements but I am
> >>
> >>failing to do the same for complex types.
> >>
> >>Thanks,
> >>Thomas
> >
> >


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: xsdComplexType [message #589479 is a reply to message #48272] Mon, 21 June 2004 18:59 Go to previous message
exquisitus is currently offline exquisitusFriend
Messages: 211
Registered: July 2009
Senior Member
Thanks Ed,

here is the trace - otherwise I will cut down the project using
XSDPrototypicalSchema.html and try to reproduce.

- Thomas

org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
insert a node where it is not permitted.
at
org.apache.xerces.dom.ParentNode.internalInsertBefore(Parent Node.java:413)
at org.apache.xerces.dom.ParentNode.insertBefore(ParentNode.jav a:322)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceNiceInser tBefore(XSDConcreteComponentImpl.java:1547)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.niceInsertBefo re(XSDConcreteComponentImpl.java:1478)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.handleElementF orAdopt(XSDConcreteComponentImpl.java:1331)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:360)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:361)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:352)
at Reader.main(Reader.java:88)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)



Ed Merks wrote:

> Thomas,
>
> If you could send me a zipped up project that I can run to reproduce this problem, I'll have a
> close look. Or at least show me the stack trace so I can see what's happening when the
> failure strikes...
>
>
> exquisitus wrote:
>
>
>>Hello Ed,
>>
>>I have a ArrayList complexTypeDefinitions containing all the
>>XSDTypeDefinitions from initial schema.
>>
>>I create a new schema and looping through ArrayList trying to write
>>the complexTypes out:
>>
>>//////////////
>>
>>//create new schema
>> XSDFactory xsdFactory = XSDFactory.eINSTANCE;
>> XSDSchema newSchema = xsdFactory.createXSDSchema();
>>
>>
>> newSchema.getQNamePrefixToNamespaceMap().putAll(oldSchema.ge tQNamePrefixToNamespaceMap());
>>
>> for (Iterator iterator = complexTypeDefinitions.iterator();
>>iterator.hasNext();) {
>> XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)
>>iterator.next();
>> ((XSDSchema) newSchema).getContents().
>> add((XSDComplexTypeDefinition)
>>xsdTypeDefinition.cloneConcreteComponent(true, false));
>> }
>>
>> newSchema.updateElement();
>> resource.getContents().add(newSchema);
>> resourceSet.getResources().add(resource);
>> resource.save(Collections.EMPTY_MAP);
>>
>>//////////////
>>
>>I am getting:
>>
>>org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
>>insert a node where it is not permitted.
>>
>> - Thomas
>>
>>Ed Merks wrote:
>>
>>
>>>Thomas,
>>>
>>>What did you try that failed?
>>>
>>>
>>>exquisitus wrote:
>>>
>>>
>>>
>>>>How can a complex type defined in schema_A be copied into the schema_B.
>>>>There is an example showing how to do it on the schema elements but I am
>>>>
>>>>failing to do the same for complex types.
>>>>
>>>>Thanks,
>>>>Thomas
>>>
>>>
>
Re: xsdComplexType [message #589486 is a reply to message #48272] Mon, 21 June 2004 19:30 Go to previous message
exquisitus is currently offline exquisitusFriend
Messages: 211
Registered: July 2009
Senior Member
Ed - please find Example and Exception below:
- Thomas

import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.XSDComplexTypeDefinition;
import org.eclipse.xsd.XSDFactory;
import org.eclipse.xsd.util.XSDPrototypicalSchema;
import org.eclipse.xsd.util.XSDResourceImpl;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.common.util.URI;

import java.util.Collections;
import java.io.IOException;

public class ComplexTypeTest {
public static void main(String[] args) throws IOException {

//get complex type from PO schema
XSDSchema po = XSDPrototypicalSchema.getPurchaseOrderSchema();
XSDComplexTypeDefinition poType =
po.resolveComplexTypeDefinition("PurchaseOrderType");

//create new schema
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = new XSDResourceImpl(URI.createURI("test.xsd"));
XSDFactory xsdFactory = XSDFactory.eINSTANCE;
XSDSchema newSchema = xsdFactory.createXSDSchema();

//clone complex types
((XSDSchema)
newSchema).getContents().add(poType.cloneConcreteComponent(t rue, false));

//add newSchema to the ressource and then save
newSchema.updateElement();
resource.getContents().add(newSchema);
resourceSet.getResources().add(resource);
resource.save(Collections.EMPTY_MAP);

System.exit(0);
}
}

Exception:
////////////////////////
org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
insert a node where it is not permitted.
at
org.apache.xerces.dom.ParentNode.internalInsertBefore(Parent Node.java:413)
at org.apache.xerces.dom.ParentNode.insertBefore(ParentNode.jav a:322)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceNiceInser tBefore(XSDConcreteComponentImpl.java:1547)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.niceInsertBefo re(XSDConcreteComponentImpl.java:1478)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.handleElementF orAdopt(XSDConcreteComponentImpl.java:1331)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:360)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:361)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:352)
at ComplexTypeTest.main(ComplexTypeTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
Exception in thread "main" Process terminated with exit code 1



Ed Merks wrote:

> Thomas,
>
> If you could send me a zipped up project that I can run to reproduce this problem, I'll have a
> close look. Or at least show me the stack trace so I can see what's happening when the
> failure strikes...
>
>
> exquisitus wrote:
>
>
>>Hello Ed,
>>
>>I have a ArrayList complexTypeDefinitions containing all the
>>XSDTypeDefinitions from initial schema.
>>
>>I create a new schema and looping through ArrayList trying to write
>>the complexTypes out:
>>
>>//////////////
>>
>>//create new schema
>> XSDFactory xsdFactory = XSDFactory.eINSTANCE;
>> XSDSchema newSchema = xsdFactory.createXSDSchema();
>>
>>
>> newSchema.getQNamePrefixToNamespaceMap().putAll(oldSchema.ge tQNamePrefixToNamespaceMap());
>>
>> for (Iterator iterator = complexTypeDefinitions.iterator();
>>iterator.hasNext();) {
>> XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)
>>iterator.next();
>> ((XSDSchema) newSchema).getContents().
>> add((XSDComplexTypeDefinition)
>>xsdTypeDefinition.cloneConcreteComponent(true, false));
>> }
>>
>> newSchema.updateElement();
>> resource.getContents().add(newSchema);
>> resourceSet.getResources().add(resource);
>> resource.save(Collections.EMPTY_MAP);
>>
>>//////////////
>>
>>I am getting:
>>
>>org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
>>insert a node where it is not permitted.
>>
>> - Thomas
>>
>>Ed Merks wrote:
>>
>>
>>>Thomas,
>>>
>>>What did you try that failed?
>>>
>>>
>>>exquisitus wrote:
>>>
>>>
>>>
>>>>How can a complex type defined in schema_A be copied into the schema_B.
>>>>There is an example showing how to do it on the schema elements but I am
>>>>
>>>>failing to do the same for complex types.
>>>>
>>>>Thanks,
>>>>Thomas
>>>
>>>
>
Re: xsdComplexType [message #589496 is a reply to message #48331] Mon, 21 June 2004 20:59 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Thomas,

I haven't had a chance to look closely, but I noticed that you haven't choosen a schema for schema
namespace for the new XSD. Doing that no doubt will help...


exquisitus wrote:

> Ed - please find Example and Exception below:
> - Thomas
>
> import org.eclipse.xsd.XSDSchema;
> import org.eclipse.xsd.XSDComplexTypeDefinition;
> import org.eclipse.xsd.XSDFactory;
> import org.eclipse.xsd.util.XSDPrototypicalSchema;
> import org.eclipse.xsd.util.XSDResourceImpl;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.common.util.URI;
>
> import java.util.Collections;
> import java.io.IOException;
>
> public class ComplexTypeTest {
> public static void main(String[] args) throws IOException {
>
> //get complex type from PO schema
> XSDSchema po = XSDPrototypicalSchema.getPurchaseOrderSchema();
> XSDComplexTypeDefinition poType =
> po.resolveComplexTypeDefinition("PurchaseOrderType");
>
> //create new schema
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource resource = new XSDResourceImpl(URI.createURI("test.xsd"));
> XSDFactory xsdFactory = XSDFactory.eINSTANCE;
> XSDSchema newSchema = xsdFactory.createXSDSchema();
>
> //clone complex types
> ((XSDSchema)
> newSchema).getContents().add(poType.cloneConcreteComponent(t rue, false));
>
> //add newSchema to the ressource and then save
> newSchema.updateElement();
> resource.getContents().add(newSchema);
> resourceSet.getResources().add(resource);
> resource.save(Collections.EMPTY_MAP);
>
> System.exit(0);
> }
> }
>
> Exception:
> ////////////////////////
> org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
> insert a node where it is not permitted.
> at
> org.apache.xerces.dom.ParentNode.internalInsertBefore(Parent Node.java:413)
> at org.apache.xerces.dom.ParentNode.insertBefore(ParentNode.jav a:322)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceNiceInser tBefore(XSDConcreteComponentImpl.java:1547)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.niceInsertBefo re(XSDConcreteComponentImpl.java:1478)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.handleElementF orAdopt(XSDConcreteComponentImpl.java:1331)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:360)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:361)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.updateElement( XSDConcreteComponentImpl.java:352)
> at ComplexTypeTest.main(ComplexTypeTest.java:39)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
> Exception in thread "main" Process terminated with exit code 1
>
> Ed Merks wrote:
>
> > Thomas,
> >
> > If you could send me a zipped up project that I can run to reproduce this problem, I'll have a
> > close look. Or at least show me the stack trace so I can see what's happening when the
> > failure strikes...
> >
> >
> > exquisitus wrote:
> >
> >
> >>Hello Ed,
> >>
> >>I have a ArrayList complexTypeDefinitions containing all the
> >>XSDTypeDefinitions from initial schema.
> >>
> >>I create a new schema and looping through ArrayList trying to write
> >>the complexTypes out:
> >>
> >>//////////////
> >>
> >>//create new schema
> >> XSDFactory xsdFactory = XSDFactory.eINSTANCE;
> >> XSDSchema newSchema = xsdFactory.createXSDSchema();
> >>
> >>
> >> newSchema.getQNamePrefixToNamespaceMap().putAll(oldSchema.ge tQNamePrefixToNamespaceMap());
> >>
> >> for (Iterator iterator = complexTypeDefinitions.iterator();
> >>iterator.hasNext();) {
> >> XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)
> >>iterator.next();
> >> ((XSDSchema) newSchema).getContents().
> >> add((XSDComplexTypeDefinition)
> >>xsdTypeDefinition.cloneConcreteComponent(true, false));
> >> }
> >>
> >> newSchema.updateElement();
> >> resource.getContents().add(newSchema);
> >> resourceSet.getResources().add(resource);
> >> resource.save(Collections.EMPTY_MAP);
> >>
> >>//////////////
> >>
> >>I am getting:
> >>
> >>org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
> >>insert a node where it is not permitted.
> >>
> >> - Thomas
> >>
> >>Ed Merks wrote:
> >>
> >>
> >>>Thomas,
> >>>
> >>>What did you try that failed?
> >>>
> >>>
> >>>exquisitus wrote:
> >>>
> >>>
> >>>
> >>>>How can a complex type defined in schema_A be copied into the schema_B.
> >>>>There is an example showing how to do it on the schema elements but I am
> >>>>
> >>>>failing to do the same for complex types.
> >>>>
> >>>>Thanks,
> >>>>Thomas
> >>>
> >>>
> >


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: xsdComplexType [message #589514 is a reply to message #48362] Mon, 21 June 2004 21:50 Go to previous message
exquisitus is currently offline exquisitusFriend
Messages: 211
Registered: July 2009
Senior Member
Ed -
many thanks - worked like spell !!!

- Thomas



Ed Merks wrote:
> Thomas,
>
> I haven't had a chance to look closely, but I noticed that you haven't choosen a schema for schema
> namespace for the new XSD. Doing that no doubt will help...
>
Previous Topic:Re: EMF, SDO & XSD Update Site (was Re: EMF Update Site)
Next Topic:Re: EMF/SDO/XSD Update Site
Goto Forum:
  


Current Time: Thu Apr 25 18:04:15 GMT 2024

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

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

Back to the top