How to create a local simpleContentComplexType ? [message #23108] |
Thu, 29 May 2003 12:03  |
Eclipse User |
|
|
|
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 19:33   |
Eclipse User |
|
|
|
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 15:58  |
Eclipse User |
|
|
|
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 19:33  |
Eclipse User |
|
|
|
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 15:58  |
Eclipse User |
|
|
|
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;
>
> }
|
|
|
Powered by
FUDForum. Page generated in 0.04472 seconds