Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » How to create a local simpleContentComplexType ?
How to create a local simpleContentComplexType ? [message #23108] Thu, 29 May 2003 16:03 Go to next message
Eclipse UserFriend
Originally posted by: dirk.schesmer.divos.de

Hi there, I try to create a simpleContentComplexType being local to an
global element called title.

As a result, I always get an additional namespace prefix "Q1". I do not get
this "Q1" prefix when I create a global type titleType having the same
structure and associating it then to an element title (see version 1 and 2
in the code).

Can please anyone give me a clue how come? I attached the code below!

Thanks for help,

Dirk V. Schesmer





public XSDSchema initSimpleContentComplexTypeDefinition() throws Exception {

XSDFactory xsdFactory;

XSDSchema xsdSchema;

Map qNamePrefixToNamespaceMap;

XSDElementDeclaration elementDecl;

xsdFactory = XSDFactory.eINSTANCE;

xsdSchema = xsdFactory.createXSDSchema();

xsdSchema.setTargetNamespace("http://dyomedea.com/ns/library");

xsdSchema.setElementFormDefault(XSDForm.QUALIFIED_LITERAL);

xsdSchema.setAttributeFormDefault(XSDForm.QUALIFIED_LITERAL) ;

xsdSchema.setSchemaForSchemaQNamePrefix("xsd");

qNamePrefixToNamespaceMap = xsdSchema.getQNamePrefixToNamespaceMap();

qNamePrefixToNamespaceMap

..put(xsdSchema.getSchemaForSchemaQNamePrefix(), XSDConstants /*}*/

..SCHEMA_FOR_SCHEMA_URI_2001);

String targetNamespace = xsdSchema.getTargetNamespace();

qNamePrefixToNamespaceMap.put("lib", targetNamespace);

qNamePrefixToNamespaceMap.put(

xsdSchema.getSchemaForSchemaQNamePrefix(),

XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);

qNamePrefixToNamespaceMap.put(null, "http://dyomedea.com/ns/library");

elementDecl =

xsdSchema.resolveElementDeclaration(targetNamespace, "title");

XSDComplexTypeDefinition simpleContentComplexTypeDefinition =

xsdFactory.createXSDComplexTypeDefinition();


simpleContentComplexTypeDefinition.setDerivationMethod(

XSDDerivationMethod.EXTENSION_LITERAL);

XSDSimpleTypeDefinition baseTypeString =

xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(

"string");

simpleContentComplexTypeDefinition.setBaseTypeDefinition(

baseTypeString);

XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =

xsdFactory.createXSDSimpleTypeDefinition();

simpleContentComplexTypeDefinition.setContent(

anonymousSimpleTypeDefinition);

XSDAttributeDeclaration simpleAttributeDeclaration =

xsdFactory.createXSDAttributeDeclaration();

simpleAttributeDeclaration.setName("bookId");

simpleAttributeDeclaration.setTypeDefinition(baseTypeString) ;

XSDAttributeUse simpleAttributeUse = xsdFactory.createXSDAttributeUse();

simpleAttributeUse.setContent(simpleAttributeDeclaration);

simpleContentComplexTypeDefinition.getAttributeContents().ad d(

simpleAttributeUse);

// version 1:

// create simpleContentComplexType as global type used by "title" element

simpleContentComplexTypeDefinition.setName("titleType");

xsdSchema.getContents().add(simpleContentComplexTypeDefiniti on);

elementDecl.setTypeDefinition(simpleContentComplexTypeDefini tion);

// version 2:

// attempt to create simpleContentComplexType as "title" element's local
type

// => a new namespace prefix "Q1" I have no clue where it comes from ?!

//elementDecl.setAnonymousTypeDefinition(simpleContentComple xTypeDefinition)
;

//xsdSchema.getContents().add(elementDecl);

xsdSchema.getContents().add(elementDecl);

//--------------------------------------------

xsdSchema.updateElement();

return xsdSchema;

}
Re: How to create a local simpleContentComplexType ? [message #23188 is a reply to message #23108] Wed, 04 June 2003 23:33 Go to previous messageGo to next message
Dave Spriet is currently offline Dave SprietFriend
Messages: 14
Registered: July 2009
Junior Member
Hello,

I think there could be a defect here. I will email Ed about it.

The fix would be to move some code around.

qNamePrefixToNamespaceMap.put(

xsdSchema.getSchemaForSchemaQNamePrefix(),

XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);

qNamePrefixToNamespaceMap.put(null, "http://dyomedea.com/ns/library");

xsdSchema.updateElement(); //Update Element after you set the namespace
stuff just so a Document is created.

elementDecl = xsdSchema.resolveElementDeclaration(targetNamespace, "title");

xsdSchema.getContents().add(elementDecl); //Add the element right away to
the XSDSchema. Then do the rest of the code.


Dave Spriet
Webshpere Business Integration
spriet@ca.ibm.com


"Dirk V. Schesmer" <dirk.schesmer@divos.de> wrote in message
news:bb5b0u$6b7$1@rogue.oti.com...
> Hi there, I try to create a simpleContentComplexType being local to an
> global element called title.
>
> As a result, I always get an additional namespace prefix "Q1". I do not
get
> this "Q1" prefix when I create a global type titleType having the same
> structure and associating it then to an element title (see version 1 and 2
> in the code).
>
> Can please anyone give me a clue how come? I attached the code below!
>
> Thanks for help,
>
> Dirk V. Schesmer
>
>
>
>
>
> public XSDSchema initSimpleContentComplexTypeDefinition() throws Exception
{
>
> XSDFactory xsdFactory;
>
> XSDSchema xsdSchema;
>
> Map qNamePrefixToNamespaceMap;
>
> XSDElementDeclaration elementDecl;
>
> xsdFactory = XSDFactory.eINSTANCE;
>
> xsdSchema = xsdFactory.createXSDSchema();
>
> xsdSchema.setTargetNamespace("http://dyomedea.com/ns/library");
>
> xsdSchema.setElementFormDefault(XSDForm.QUALIFIED_LITERAL);
>
> xsdSchema.setAttributeFormDefault(XSDForm.QUALIFIED_LITERAL) ;
>
> xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
>
> qNamePrefixToNamespaceMap = xsdSchema.getQNamePrefixToNamespaceMap();
>
> qNamePrefixToNamespaceMap
>
> .put(xsdSchema.getSchemaForSchemaQNamePrefix(), XSDConstants /*}*/
>
> .SCHEMA_FOR_SCHEMA_URI_2001);
>
> String targetNamespace = xsdSchema.getTargetNamespace();
>
> qNamePrefixToNamespaceMap.put("lib", targetNamespace);
>
> qNamePrefixToNamespaceMap.put(
>
> xsdSchema.getSchemaForSchemaQNamePrefix(),
>
> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>
> qNamePrefixToNamespaceMap.put(null, "http://dyomedea.com/ns/library");
>
> elementDecl =
>
> xsdSchema.resolveElementDeclaration(targetNamespace, "title");
>
> XSDComplexTypeDefinition simpleContentComplexTypeDefinition =
>
> xsdFactory.createXSDComplexTypeDefinition();
>
>
> simpleContentComplexTypeDefinition.setDerivationMethod(
>
> XSDDerivationMethod.EXTENSION_LITERAL);
>
> XSDSimpleTypeDefinition baseTypeString =
>
> xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
>
> "string");
>
> simpleContentComplexTypeDefinition.setBaseTypeDefinition(
>
> baseTypeString);
>
> XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
>
> xsdFactory.createXSDSimpleTypeDefinition();
>
> simpleContentComplexTypeDefinition.setContent(
>
> anonymousSimpleTypeDefinition);
>
> XSDAttributeDeclaration simpleAttributeDeclaration =
>
> xsdFactory.createXSDAttributeDeclaration();
>
> simpleAttributeDeclaration.setName("bookId");
>
> simpleAttributeDeclaration.setTypeDefinition(baseTypeString) ;
>
> XSDAttributeUse simpleAttributeUse = xsdFactory.createXSDAttributeUse();
>
> simpleAttributeUse.setContent(simpleAttributeDeclaration);
>
> simpleContentComplexTypeDefinition.getAttributeContents().ad d(
>
> simpleAttributeUse);
>
> // version 1:
>
> // create simpleContentComplexType as global type used by "title" element
>
> simpleContentComplexTypeDefinition.setName("titleType");
>
> xsdSchema.getContents().add(simpleContentComplexTypeDefiniti on);
>
> elementDecl.setTypeDefinition(simpleContentComplexTypeDefini tion);
>
> // version 2:
>
> // attempt to create simpleContentComplexType as "title" element's local
> type
>
> // => a new namespace prefix "Q1" I have no clue where it comes from ?!
>
>
//elementDecl.setAnonymousTypeDefinition(simpleContentComple xTypeDefinition)
> ;
>
> //xsdSchema.getContents().add(elementDecl);
>
> xsdSchema.getContents().add(elementDecl);
>
> //--------------------------------------------
>
> xsdSchema.updateElement();
>
> return xsdSchema;
>
> }
>
>
Re: How to create a local simpleContentComplexType ? [message #23326 is a reply to message #23108] Mon, 09 June 2003 19:58 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Dirk,

This should work better in the next driver.


"Dirk V. Schesmer" wrote:

> Hi there, I try to create a simpleContentComplexType being local to an
> global element called title.
>
> As a result, I always get an additional namespace prefix "Q1". I do not get
> this "Q1" prefix when I create a global type titleType having the same
> structure and associating it then to an element title (see version 1 and 2
> in the code).
>
> Can please anyone give me a clue how come? I attached the code below!
>
> Thanks for help,
>
> Dirk V. Schesmer
>
> public XSDSchema initSimpleContentComplexTypeDefinition() throws Exception {
>
> XSDFactory xsdFactory;
>
> XSDSchema xsdSchema;
>
> Map qNamePrefixToNamespaceMap;
>
> XSDElementDeclaration elementDecl;
>
> xsdFactory = XSDFactory.eINSTANCE;
>
> xsdSchema = xsdFactory.createXSDSchema();
>
> xsdSchema.setTargetNamespace("http://dyomedea.com/ns/library");
>
> xsdSchema.setElementFormDefault(XSDForm.QUALIFIED_LITERAL);
>
> xsdSchema.setAttributeFormDefault(XSDForm.QUALIFIED_LITERAL) ;
>
> xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
>
> qNamePrefixToNamespaceMap = xsdSchema.getQNamePrefixToNamespaceMap();
>
> qNamePrefixToNamespaceMap
>
> .put(xsdSchema.getSchemaForSchemaQNamePrefix(), XSDConstants /*}*/
>
> .SCHEMA_FOR_SCHEMA_URI_2001);
>
> String targetNamespace = xsdSchema.getTargetNamespace();
>
> qNamePrefixToNamespaceMap.put("lib", targetNamespace);
>
> qNamePrefixToNamespaceMap.put(
>
> xsdSchema.getSchemaForSchemaQNamePrefix(),
>
> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>
> qNamePrefixToNamespaceMap.put(null, "http://dyomedea.com/ns/library");
>
> elementDecl =
>
> xsdSchema.resolveElementDeclaration(targetNamespace, "title");
>
> XSDComplexTypeDefinition simpleContentComplexTypeDefinition =
>
> xsdFactory.createXSDComplexTypeDefinition();
>
> simpleContentComplexTypeDefinition.setDerivationMethod(
>
> XSDDerivationMethod.EXTENSION_LITERAL);
>
> XSDSimpleTypeDefinition baseTypeString =
>
> xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
>
> "string");
>
> simpleContentComplexTypeDefinition.setBaseTypeDefinition(
>
> baseTypeString);
>
> XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
>
> xsdFactory.createXSDSimpleTypeDefinition();
>
> simpleContentComplexTypeDefinition.setContent(
>
> anonymousSimpleTypeDefinition);
>
> XSDAttributeDeclaration simpleAttributeDeclaration =
>
> xsdFactory.createXSDAttributeDeclaration();
>
> simpleAttributeDeclaration.setName("bookId");
>
> simpleAttributeDeclaration.setTypeDefinition(baseTypeString) ;
>
> XSDAttributeUse simpleAttributeUse = xsdFactory.createXSDAttributeUse();
>
> simpleAttributeUse.setContent(simpleAttributeDeclaration);
>
> simpleContentComplexTypeDefinition.getAttributeContents().ad d(
>
> simpleAttributeUse);
>
> // version 1:
>
> // create simpleContentComplexType as global type used by "title" element
>
> simpleContentComplexTypeDefinition.setName("titleType");
>
> xsdSchema.getContents().add(simpleContentComplexTypeDefiniti on);
>
> elementDecl.setTypeDefinition(simpleContentComplexTypeDefini tion);
>
> // version 2:
>
> // attempt to create simpleContentComplexType as "title" element's local
> type
>
> // => a new namespace prefix "Q1" I have no clue where it comes from ?!
>
> //elementDecl.setAnonymousTypeDefinition(simpleContentComple xTypeDefinition)
> ;
>
> //xsdSchema.getContents().add(elementDecl);
>
> xsdSchema.getContents().add(elementDecl);
>
> //--------------------------------------------
>
> xsdSchema.updateElement();
>
> return xsdSchema;
>
> }
Re: How to create a local simpleContentComplexType ? [message #572637 is a reply to message #23108] Wed, 04 June 2003 23:33 Go to previous message
Dave Spriet is currently offline Dave SprietFriend
Messages: 14
Registered: July 2009
Junior Member
Hello,

I think there could be a defect here. I will email Ed about it.

The fix would be to move some code around.

qNamePrefixToNamespaceMap.put(

xsdSchema.getSchemaForSchemaQNamePrefix(),

XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);

qNamePrefixToNamespaceMap.put(null, "http://dyomedea.com/ns/library");

xsdSchema.updateElement(); //Update Element after you set the namespace
stuff just so a Document is created.

elementDecl = xsdSchema.resolveElementDeclaration(targetNamespace, "title");

xsdSchema.getContents().add(elementDecl); //Add the element right away to
the XSDSchema. Then do the rest of the code.


Dave Spriet
Webshpere Business Integration
spriet@ca.ibm.com


"Dirk V. Schesmer" <dirk.schesmer@divos.de> wrote in message
news:bb5b0u$6b7$1@rogue.oti.com...
> Hi there, I try to create a simpleContentComplexType being local to an
> global element called title.
>
> As a result, I always get an additional namespace prefix "Q1". I do not
get
> this "Q1" prefix when I create a global type titleType having the same
> structure and associating it then to an element title (see version 1 and 2
> in the code).
>
> Can please anyone give me a clue how come? I attached the code below!
>
> Thanks for help,
>
> Dirk V. Schesmer
>
>
>
>
>
> public XSDSchema initSimpleContentComplexTypeDefinition() throws Exception
{
>
> XSDFactory xsdFactory;
>
> XSDSchema xsdSchema;
>
> Map qNamePrefixToNamespaceMap;
>
> XSDElementDeclaration elementDecl;
>
> xsdFactory = XSDFactory.eINSTANCE;
>
> xsdSchema = xsdFactory.createXSDSchema();
>
> xsdSchema.setTargetNamespace("http://dyomedea.com/ns/library");
>
> xsdSchema.setElementFormDefault(XSDForm.QUALIFIED_LITERAL);
>
> xsdSchema.setAttributeFormDefault(XSDForm.QUALIFIED_LITERAL) ;
>
> xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
>
> qNamePrefixToNamespaceMap = xsdSchema.getQNamePrefixToNamespaceMap();
>
> qNamePrefixToNamespaceMap
>
> .put(xsdSchema.getSchemaForSchemaQNamePrefix(), XSDConstants /*}*/
>
> .SCHEMA_FOR_SCHEMA_URI_2001);
>
> String targetNamespace = xsdSchema.getTargetNamespace();
>
> qNamePrefixToNamespaceMap.put("lib", targetNamespace);
>
> qNamePrefixToNamespaceMap.put(
>
> xsdSchema.getSchemaForSchemaQNamePrefix(),
>
> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>
> qNamePrefixToNamespaceMap.put(null, "http://dyomedea.com/ns/library");
>
> elementDecl =
>
> xsdSchema.resolveElementDeclaration(targetNamespace, "title");
>
> XSDComplexTypeDefinition simpleContentComplexTypeDefinition =
>
> xsdFactory.createXSDComplexTypeDefinition();
>
>
> simpleContentComplexTypeDefinition.setDerivationMethod(
>
> XSDDerivationMethod.EXTENSION_LITERAL);
>
> XSDSimpleTypeDefinition baseTypeString =
>
> xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
>
> "string");
>
> simpleContentComplexTypeDefinition.setBaseTypeDefinition(
>
> baseTypeString);
>
> XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
>
> xsdFactory.createXSDSimpleTypeDefinition();
>
> simpleContentComplexTypeDefinition.setContent(
>
> anonymousSimpleTypeDefinition);
>
> XSDAttributeDeclaration simpleAttributeDeclaration =
>
> xsdFactory.createXSDAttributeDeclaration();
>
> simpleAttributeDeclaration.setName("bookId");
>
> simpleAttributeDeclaration.setTypeDefinition(baseTypeString) ;
>
> XSDAttributeUse simpleAttributeUse = xsdFactory.createXSDAttributeUse();
>
> simpleAttributeUse.setContent(simpleAttributeDeclaration);
>
> simpleContentComplexTypeDefinition.getAttributeContents().ad d(
>
> simpleAttributeUse);
>
> // version 1:
>
> // create simpleContentComplexType as global type used by "title" element
>
> simpleContentComplexTypeDefinition.setName("titleType");
>
> xsdSchema.getContents().add(simpleContentComplexTypeDefiniti on);
>
> elementDecl.setTypeDefinition(simpleContentComplexTypeDefini tion);
>
> // version 2:
>
> // attempt to create simpleContentComplexType as "title" element's local
> type
>
> // => a new namespace prefix "Q1" I have no clue where it comes from ?!
>
>
//elementDecl.setAnonymousTypeDefinition(simpleContentComple xTypeDefinition)
> ;
>
> //xsdSchema.getContents().add(elementDecl);
>
> xsdSchema.getContents().add(elementDecl);
>
> //--------------------------------------------
>
> xsdSchema.updateElement();
>
> return xsdSchema;
>
> }
>
>
Re: How to create a local simpleContentComplexType ? [message #572740 is a reply to message #23108] Mon, 09 June 2003 19:58 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31362
Registered: July 2009
Senior Member
Dirk,

This should work better in the next driver.


"Dirk V. Schesmer" wrote:

> Hi there, I try to create a simpleContentComplexType being local to an
> global element called title.
>
> As a result, I always get an additional namespace prefix "Q1". I do not get
> this "Q1" prefix when I create a global type titleType having the same
> structure and associating it then to an element title (see version 1 and 2
> in the code).
>
> Can please anyone give me a clue how come? I attached the code below!
>
> Thanks for help,
>
> Dirk V. Schesmer
>
> public XSDSchema initSimpleContentComplexTypeDefinition() throws Exception {
>
> XSDFactory xsdFactory;
>
> XSDSchema xsdSchema;
>
> Map qNamePrefixToNamespaceMap;
>
> XSDElementDeclaration elementDecl;
>
> xsdFactory = XSDFactory.eINSTANCE;
>
> xsdSchema = xsdFactory.createXSDSchema();
>
> xsdSchema.setTargetNamespace("http://dyomedea.com/ns/library");
>
> xsdSchema.setElementFormDefault(XSDForm.QUALIFIED_LITERAL);
>
> xsdSchema.setAttributeFormDefault(XSDForm.QUALIFIED_LITERAL) ;
>
> xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
>
> qNamePrefixToNamespaceMap = xsdSchema.getQNamePrefixToNamespaceMap();
>
> qNamePrefixToNamespaceMap
>
> .put(xsdSchema.getSchemaForSchemaQNamePrefix(), XSDConstants /*}*/
>
> .SCHEMA_FOR_SCHEMA_URI_2001);
>
> String targetNamespace = xsdSchema.getTargetNamespace();
>
> qNamePrefixToNamespaceMap.put("lib", targetNamespace);
>
> qNamePrefixToNamespaceMap.put(
>
> xsdSchema.getSchemaForSchemaQNamePrefix(),
>
> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>
> qNamePrefixToNamespaceMap.put(null, "http://dyomedea.com/ns/library");
>
> elementDecl =
>
> xsdSchema.resolveElementDeclaration(targetNamespace, "title");
>
> XSDComplexTypeDefinition simpleContentComplexTypeDefinition =
>
> xsdFactory.createXSDComplexTypeDefinition();
>
> simpleContentComplexTypeDefinition.setDerivationMethod(
>
> XSDDerivationMethod.EXTENSION_LITERAL);
>
> XSDSimpleTypeDefinition baseTypeString =
>
> xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
>
> "string");
>
> simpleContentComplexTypeDefinition.setBaseTypeDefinition(
>
> baseTypeString);
>
> XSDSimpleTypeDefinition anonymousSimpleTypeDefinition =
>
> xsdFactory.createXSDSimpleTypeDefinition();
>
> simpleContentComplexTypeDefinition.setContent(
>
> anonymousSimpleTypeDefinition);
>
> XSDAttributeDeclaration simpleAttributeDeclaration =
>
> xsdFactory.createXSDAttributeDeclaration();
>
> simpleAttributeDeclaration.setName("bookId");
>
> simpleAttributeDeclaration.setTypeDefinition(baseTypeString) ;
>
> XSDAttributeUse simpleAttributeUse = xsdFactory.createXSDAttributeUse();
>
> simpleAttributeUse.setContent(simpleAttributeDeclaration);
>
> simpleContentComplexTypeDefinition.getAttributeContents().ad d(
>
> simpleAttributeUse);
>
> // version 1:
>
> // create simpleContentComplexType as global type used by "title" element
>
> simpleContentComplexTypeDefinition.setName("titleType");
>
> xsdSchema.getContents().add(simpleContentComplexTypeDefiniti on);
>
> elementDecl.setTypeDefinition(simpleContentComplexTypeDefini tion);
>
> // version 2:
>
> // attempt to create simpleContentComplexType as "title" element's local
> type
>
> // => a new namespace prefix "Q1" I have no clue where it comes from ?!
>
> //elementDecl.setAnonymousTypeDefinition(simpleContentComple xTypeDefinition)
> ;
>
> //xsdSchema.getContents().add(elementDecl);
>
> xsdSchema.getContents().add(elementDecl);
>
> //--------------------------------------------
>
> xsdSchema.updateElement();
>
> return xsdSchema;
>
> }


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Probs with "Shane Curcuru's Article"
Next Topic:Synthetic Particle
Goto Forum:
  


Current Time: Sun Aug 09 23:40:16 GMT 2020

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

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

Back to the top