Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Error using sequence
Error using sequence [message #55302] Fri, 26 November 2004 09:48 Go to next message
Eclipse UserFriend
Originally posted by: ooi.de.ibm.com

Hi!

I came across a funny error and have no idea why it happens.
when I run this code :
XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("PurchaseOrderType");

XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
particle.setContent(modelGroup);
complexType.setContent(particle);
schema.getContents().add(complexType); //error shown here

its shows the following error during runtime:
org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to
insert a node where it is not permitted.

but using only:
XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("PurchaseOrderType");
schema.getContents().add(complexType);

there is no problem.

what could be the cause of this error?

Thanks.
Re: Error using sequence [message #55384 is a reply to message #55302] Fri, 26 November 2004 12:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------020808050602050005090005
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

HT,

I added this code to
org.eclipse.xsd.util.XSDPrototypicalSchema.initializePrototy peSchema:

XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("PurchaseOrderType");

XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
particle.setContent(modelGroup);
complexType.setContent(particle);
prototypeSchema.updateElement();
prototypeSchema.getContents().add(complexType); //error shown here

if (true) return prototypeSchema;

and this result is printed when I run org.eclipse.xsd.test.XSDMainTest:

<!-- ** PrototypicalSchema ** -->
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:EXT="http://www.example.com/SomeOtherSchema"
xmlns:PTS="http://www.example.com/PrototypicalSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://www.example.com/PrototypicalSchema">
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence/>
</xsd:complexType>
</xsd:schema>

So I can't reproduce your problem.

I can best help if you provide a complete sample that reproduces the
problem.


HT Ooi wrote:

> Hi!
>
> I came across a funny error and have no idea why it happens.
> when I run this code :
> XSDComplexTypeDefinition complexType =
> XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
> complexType.setName("PurchaseOrderType");
>
> XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
> XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
> modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
> particle.setContent(modelGroup);
> complexType.setContent(particle);
> schema.getContents().add(complexType); //error shown here
>
> its shows the following error during runtime:
> org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made
> to insert a node where it is not permitted.
> but using only:
> XSDComplexTypeDefinition complexType =
> XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
> complexType.setName("PurchaseOrderType");
> schema.getContents().add(complexType);
>
> there is no problem.
>
> what could be the cause of this error?
>
> Thanks.
>
>


--------------020808050602050005090005
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
HT,<br>
<br>
I added this code to
org.eclipse.xsd.util.XSDPrototypicalSchema.initializePrototy peSchema: <br>
<blockquote>XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();<br>
complexType.setName("PurchaseOrderType");<br>
<br>
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();<br>
XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();<br>
modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);<br >
particle.setContent(modelGroup);<br>
complexType.setContent(particle);<br>
prototypeSchema.updateElement();<br>
prototypeSchema.getContents().add(complexType); //error shown here <br>
</blockquote>
<blockquote>if (true) return prototypeSchema;<br>
</blockquote>
and this result is printed when I run org.eclipse.xsd.test.XSDMainTest:<br>
<blockquote>&lt;!-- ** PrototypicalSchema ** --&gt;<br>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>
&lt;xsd:schema xmlns:EXT=<a class="moz-txt-link-rfc2396E" href="http://www.example.com/SomeOtherSchema">"http://www.example.com/SomeOtherSchema"</a>
xmlns:PTS=<a class="moz-txt-link-rfc2396E" href="http://www.example.com/PrototypicalSchema">"http://www.example.com/PrototypicalSchema"</a>
xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://www.example.com/PrototypicalSchema">"http://www.example.com/PrototypicalSchema"</a>&gt;<br>
Re: Error using sequence [message #55411 is a reply to message #55384] Fri, 26 November 2004 12:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ooi.de.ibm.com

Hi Ed!

Here's a bigger piece of my sample programme...

static Document document;

public void createElementWithSchema(){

Element schemaElement = (Element) document.createElement("schema");
document.appendChild(schemaElement);
XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
xsdSchema.setElement(schemaElement);
xsdSchema.setTargetNamespace("http://www.eclipse.org/xsd/examples/createxsd");
java.util.Map qNamePrefixToNamespaceMap =
xsdSchema.getQNamePrefixToNamespaceMap();
qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
qNamePrefixToNamespaceMap.put("createxsd", xsdSchema.getTargetNamespace());

XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("PurchaseOrderType");
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
particle.setContent(modelGroup);
complexType.setContent(particle);
xsdSchema.getContents().add(complexType);

xsdSchema.update();
xsdSchema.updateElement();



If it helps I could send the whole Java source file.

Thank you.
Re: Error using sequence [message #55437 is a reply to message #55411] Fri, 26 November 2004 12:41 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------090508090102010607080800
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

HT,

I don't just need a slightly bigger sample, I need the complete sample
that runs and by doing so demonstrates the problem.

Note that this code still has your *wrong *schema element in it. You
need to use createElementNS. (If you would just use
XSDSchema.setDocument, the element will be *correctly *created for you.)


HT Ooi wrote:

> Hi Ed!
>
> Here's a bigger piece of my sample programme...
>
> static Document document;
>
> public void createElementWithSchema(){
>
> Element schemaElement = (Element) document.*createElement*("schema");
> document.appendChild(schemaElement);
> XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
> xsdSchema.setElement(schemaElement);
> xsdSchema.setTargetNamespace("http://www.eclipse.org/xsd/examples/createxsd");
>
> java.util.Map qNamePrefixToNamespaceMap =
> xsdSchema.getQNamePrefixToNamespaceMap();
> qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
> qNamePrefixToNamespaceMap.put("createxsd",
> xsdSchema.getTargetNamespace());
>
> XSDComplexTypeDefinition complexType =
> XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
> complexType.setName("PurchaseOrderType");
> XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
> XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
> modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
> particle.setContent(modelGroup);
> complexType.setContent(particle);
> xsdSchema.getContents().add(complexType);
>
> xsdSchema.update();
> xsdSchema.updateElement();
>
>
>
> If it helps I could send the whole Java source file.
>
> Thank you.
>


--------------090508090102010607080800
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
HT,<br>
<br>
I don't just need a slightly bigger sample, I need the complete sample
that runs and by doing so demonstrates the problem.<br>
<br>
Note that this code still has your <b>wrong </b>schema element in
it.
Re: Error using sequence [message #592770 is a reply to message #55302] Fri, 26 November 2004 12:11 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020808050602050005090005
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

HT,

I added this code to
org.eclipse.xsd.util.XSDPrototypicalSchema.initializePrototy peSchema:

XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("PurchaseOrderType");

XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
particle.setContent(modelGroup);
complexType.setContent(particle);
prototypeSchema.updateElement();
prototypeSchema.getContents().add(complexType); //error shown here

if (true) return prototypeSchema;

and this result is printed when I run org.eclipse.xsd.test.XSDMainTest:

<!-- ** PrototypicalSchema ** -->
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:EXT="http://www.example.com/SomeOtherSchema"
xmlns:PTS="http://www.example.com/PrototypicalSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://www.example.com/PrototypicalSchema">
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence/>
</xsd:complexType>
</xsd:schema>

So I can't reproduce your problem.

I can best help if you provide a complete sample that reproduces the
problem.


HT Ooi wrote:

> Hi!
>
> I came across a funny error and have no idea why it happens.
> when I run this code :
> XSDComplexTypeDefinition complexType =
> XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
> complexType.setName("PurchaseOrderType");
>
> XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
> XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
> modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
> particle.setContent(modelGroup);
> complexType.setContent(particle);
> schema.getContents().add(complexType); //error shown here
>
> its shows the following error during runtime:
> org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made
> to insert a node where it is not permitted.
> but using only:
> XSDComplexTypeDefinition complexType =
> XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
> complexType.setName("PurchaseOrderType");
> schema.getContents().add(complexType);
>
> there is no problem.
>
> what could be the cause of this error?
>
> Thanks.
>
>


--------------020808050602050005090005
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
HT,<br>
<br>
I added this code to
org.eclipse.xsd.util.XSDPrototypicalSchema.initializePrototy peSchema: <br>
<blockquote>XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();<br>
complexType.setName("PurchaseOrderType");<br>
<br>
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();<br>
XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();<br>
modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);<br >
particle.setContent(modelGroup);<br>
complexType.setContent(particle);<br>
prototypeSchema.updateElement();<br>
prototypeSchema.getContents().add(complexType); //error shown here <br>
</blockquote>
<blockquote>if (true) return prototypeSchema;<br>
</blockquote>
and this result is printed when I run org.eclipse.xsd.test.XSDMainTest:<br>
<blockquote>&lt;!-- ** PrototypicalSchema ** --&gt;<br>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>
&lt;xsd:schema xmlns:EXT=<a class="moz-txt-link-rfc2396E" href="http://www.example.com/SomeOtherSchema">"http://www.example.com/SomeOtherSchema"</a>
xmlns:PTS=<a class="moz-txt-link-rfc2396E" href="http://www.example.com/PrototypicalSchema">"http://www.example.com/PrototypicalSchema"</a>
xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://www.example.com/PrototypicalSchema">"http://www.example.com/PrototypicalSchema"</a>&gt;<br>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Error using sequence [message #592784 is a reply to message #55384] Fri, 26 November 2004 12:21 Go to previous message
Eclipse UserFriend
Originally posted by: ooi.de.ibm.com

Hi Ed!

Here's a bigger piece of my sample programme...

static Document document;

public void createElementWithSchema(){

Element schemaElement = (Element) document.createElement("schema");
document.appendChild(schemaElement);
XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
xsdSchema.setElement(schemaElement);
xsdSchema.setTargetNamespace("http://www.eclipse.org/xsd/examples/createxsd");
java.util.Map qNamePrefixToNamespaceMap =
xsdSchema.getQNamePrefixToNamespaceMap();
qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
qNamePrefixToNamespaceMap.put("createxsd", xsdSchema.getTargetNamespace());

XSDComplexTypeDefinition complexType =
XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
complexType.setName("PurchaseOrderType");
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
particle.setContent(modelGroup);
complexType.setContent(particle);
xsdSchema.getContents().add(complexType);

xsdSchema.update();
xsdSchema.updateElement();



If it helps I could send the whole Java source file.

Thank you.
Re: Error using sequence [message #592797 is a reply to message #55411] Fri, 26 November 2004 12:41 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090508090102010607080800
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

HT,

I don't just need a slightly bigger sample, I need the complete sample
that runs and by doing so demonstrates the problem.

Note that this code still has your *wrong *schema element in it. You
need to use createElementNS. (If you would just use
XSDSchema.setDocument, the element will be *correctly *created for you.)


HT Ooi wrote:

> Hi Ed!
>
> Here's a bigger piece of my sample programme...
>
> static Document document;
>
> public void createElementWithSchema(){
>
> Element schemaElement = (Element) document.*createElement*("schema");
> document.appendChild(schemaElement);
> XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
> xsdSchema.setElement(schemaElement);
> xsdSchema.setTargetNamespace("http://www.eclipse.org/xsd/examples/createxsd");
>
> java.util.Map qNamePrefixToNamespaceMap =
> xsdSchema.getQNamePrefixToNamespaceMap();
> qNamePrefixToNamespaceMap.put(xsdSchema.getSchemaForSchemaQN amePrefix(),
> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
> qNamePrefixToNamespaceMap.put("createxsd",
> xsdSchema.getTargetNamespace());
>
> XSDComplexTypeDefinition complexType =
> XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
> complexType.setName("PurchaseOrderType");
> XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
> XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
> modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
> particle.setContent(modelGroup);
> complexType.setContent(particle);
> xsdSchema.getContents().add(complexType);
>
> xsdSchema.update();
> xsdSchema.updateElement();
>
>
>
> If it helps I could send the whole Java source file.
>
> Thank you.
>


--------------090508090102010607080800
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
HT,<br>
<br>
I don't just need a slightly bigger sample, I need the complete sample
that runs and by doing so demonstrates the problem.<br>
<br>
Note that this code still has your <b>wrong </b>schema element in
it.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Error using sequence
Next Topic:Generating JAVA classes from XSDs
Goto Forum:
  


Current Time: Thu Apr 25 16:49:35 GMT 2024

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

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

Back to the top