| Home » Archived » XML Schema Definition (XSD) » Generated Namespace Prexfix xmlns:Q1: How come?
 Goto Forum:| 
| Generated Namespace Prexfix xmlns:Q1: How come? [message #22851] | Mon, 19 May 2003 13:51  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: dirk.schesmer.divos.de 
 Hi there,
 whenever I add an element reference to the method generating my schema (see
 code below), the system automatically adds the namespace prefix
 xmlns:Q1="..." to the schema it generates. How come? (I can get rid of it
 when specifying a default namespace, but that's not want I want to...)
 Thanks for help,
 
 Dirk
 
 (Example it an excerpt from library.xsd taken from the very good O'Reillly
 book XMLSchema, author: E. van der Vlist)
 public XSDSchema initializeSD3Schema() throws Exception {
 
 XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
 
 xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
 
 xsdSchema.setTargetNamespace("http://www.divos.de/sd3.xsd");
 
 Map qNamePrefixToNamespaceMap =
 
 xsdSchema.getQNamePrefixToNamespaceMap();
 
 qNamePrefixToNamespaceMap.put(
 
 xsdSchema.getSchemaForSchemaQNamePrefix(),
 
 XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
 
 XSDFactory xsdFactory = XSDSchemaBuildingTools.getXSDFactory();
 
 String targetNamespace = xsdSchema.getTargetNamespace();
 
 XSDElementDeclaration elementDecl = null;
 
 elementDecl =
 
 xsdSchema.resolveElementDeclaration(targetNamespace, "name");
 
 XSDTypeDefinition typeDef =
 
 xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
 
 "string");
 
 elementDecl.setTypeDefinition(typeDef);
 
 xsdSchema.getContents().add(elementDecl);
 
 elementDecl =
 
 xsdSchema.resolveElementDeclaration(targetNamespace, "isbn");
 
 typeDef =
 
 xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
 
 "string");
 
 elementDecl.setTypeDefinition(typeDef);
 
 xsdSchema.getContents().add(elementDecl);
 
 elementDecl =
 
 xsdSchema.resolveElementDeclaration(targetNamespace, "author");
 
 XSDComplexTypeDefinition anonymousComplexTypeDefinition =
 
 xsdFactory.createXSDComplexTypeDefinition();
 
 XSDModelGroup anonymousComplexTypeDefinitionSequence =
 
 xsdFactory.createXSDModelGroup();
 
 anonymousComplexTypeDefinitionSequence.setCompositor(
 
 XSDCompositor.SEQUENCE_LITERAL);
 
 XSDParticle anonymousTypeDefinitionParticle =
 
 xsdFactory.createXSDParticle();
 
 anonymousTypeDefinitionParticle.setContent(
 
 anonymousComplexTypeDefinitionSequence);
 
 XSDElementDeclaration nameRef =
 
 xsdFactory.createXSDElementDeclaration();
 
 nameRef.setResolvedElementDeclaration(
 
 xsdSchema.resolveElementDeclaration("name"));
 
 XSDParticle nameRefParticle = xsdFactory.createXSDParticle();
 
 nameRefParticle.setContent(nameRef);
 
 anonymousComplexTypeDefinitionSequence.getContents().add(
 
 nameRefParticle);
 
 anonymousComplexTypeDefinition.setContent(
 
 anonymousTypeDefinitionParticle);
 
 elementDecl.setAnonymousTypeDefinition(anonymousComplexTypeD efinition);
 
 xsdSchema.getContents().add(elementDecl);
 
 XSDAttributeDeclaration attributeDecl =
 
 xsdFactory.createXSDAttributeDeclaration();
 
 attributeDecl.setName("id");
 
 attributeDecl.setTypeDefinition(
 
 xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("ID "));
 
 xsdSchema.getContents().add(attributeDecl);
 
 return xsdSchema;
 
 }
 |  |  |  |  | 
| Re: Generated Namespace Prexfix xmlns:Q1: How come? [message #22894 is a reply to message #22851] | Tue, 20 May 2003 11:40  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: merks.ca.ibm.com 
 --------------8193787C9112A53913FC62B0
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 Dirk,
 
 In order to reference anything in any namespace, an xmlns declaration is
 required for the namespace.  If there isn't one already specified, one is
 created on demand.  If you have a particular favorite prefix you want to use,
 you should set it into the prefix map beforehand, e.g., this will create a null
 prefix for the schema's target namespace:
 
 qNameToPrefixMap.put(null, targetNamespace)
 
 "Dirk V. Schesmer" wrote:
 
 > Hi there,
 > whenever I add an element reference to the method generating my schema (see
 > code below), the system automatically adds the namespace prefix
 > xmlns:Q1="..." to the schema it generates. How come? (I can get rid of it
 > when specifying a default namespace, but that's not want I want to...)
 > Thanks for help,
 >
 > Dirk
 >
 > (Example it an excerpt from library.xsd taken from the very good O'Reillly
 > book XMLSchema, author: E. van der Vlist)
 > public XSDSchema initializeSD3Schema() throws Exception {
 >
 > XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
 >
 > xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
 >
 > xsdSchema.setTargetNamespace("http://www.divos.de/sd3.xsd");
 >
 > Map qNamePrefixToNamespaceMap =
 >
 > xsdSchema.getQNamePrefixToNamespaceMap();
 >
 > qNamePrefixToNamespaceMap.put(
 >
 > xsdSchema.getSchemaForSchemaQNamePrefix(),
 >
 > XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
 >
 > XSDFactory xsdFactory = XSDSchemaBuildingTools.getXSDFactory();
 >
 > String targetNamespace = xsdSchema.getTargetNamespace();
 >
 > XSDElementDeclaration elementDecl = null;
 >
 > elementDecl =
 >
 > xsdSchema.resolveElementDeclaration(targetNamespace, "name");
 >
 > XSDTypeDefinition typeDef =
 >
 > xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
 >
 > "string");
 >
 > elementDecl.setTypeDefinition(typeDef);
 >
 > xsdSchema.getContents().add(elementDecl);
 >
 > elementDecl =
 >
 > xsdSchema.resolveElementDeclaration(targetNamespace, "isbn");
 >
 > typeDef =
 >
 > xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
 >
 > "string");
 >
 > elementDecl.setTypeDefinition(typeDef);
 >
 > xsdSchema.getContents().add(elementDecl);
 >
 > elementDecl =
 >
 > xsdSchema.resolveElementDeclaration(targetNamespace, "author");
 >
 > XSDComplexTypeDefinition anonymousComplexTypeDefinition =
 >
 > xsdFactory.createXSDComplexTypeDefinition();
 >
 > XSDModelGroup anonymousComplexTypeDefinitionSequence =
 >
 > xsdFactory.createXSDModelGroup();
 >
 > anonymousComplexTypeDefinitionSequence.setCompositor(
 >
 > XSDCompositor.SEQUENCE_LITERAL);
 >
 > XSDParticle anonymousTypeDefinitionParticle =
 >
 > xsdFactory.createXSDParticle();
 >
 > anonymousTypeDefinitionParticle.setContent(
 >
 > anonymousComplexTypeDefinitionSequence);
 >
 > XSDElementDeclaration nameRef =
 >
 > xsdFactory.createXSDElementDeclaration();
 >
 > nameRef.setResolvedElementDeclaration(
 >
 > xsdSchema.resolveElementDeclaration("name"));
 >
 > XSDParticle nameRefParticle = xsdFactory.createXSDParticle();
 >
 > nameRefParticle.setContent(nameRef);
 >
 > anonymousComplexTypeDefinitionSequence.getContents().add(
 >
 > nameRefParticle);
 >
 > anonymousComplexTypeDefinition.setContent(
 >
 > anonymousTypeDefinitionParticle);
 >
 >  elementDecl.setAnonymousTypeDefinition(anonymousComplexTypeD efinition);
 >
 > xsdSchema.getContents().add(elementDecl);
 >
 > XSDAttributeDeclaration attributeDecl =
 >
 > xsdFactory.createXSDAttributeDeclaration();
 >
 > attributeDecl.setName("id");
 >
 > attributeDecl.setTypeDefinition(
 >
 > xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("ID "));
 >
 > xsdSchema.getContents().add(attributeDecl);
 >
 > return xsdSchema;
 >
 > }
 
 --------------8193787C9112A53913FC62B0
 Content-Type: text/html; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
 <html>
 Dirk,
 <p>In order to reference anything in any namespace, an xmlns declaration
 is required for the namespace.  If there isn't one already specified,
 one is created on demand.  If you have a particular favorite prefix
 you want to use, you should set it into the prefix map beforehand, e.g.,
 this will create a null prefix for the schema's target namespace:
 <blockquote>qNameToPrefixMap.put(null, targetNamespace)</blockquote>
 
 <p>"Dirk V. Schesmer" wrote:
 <blockquote TYPE=CITE>Hi there,
 <br>whenever I add an element reference to the method generating my schema
 (see
 <br>code below), the system automatically adds the namespace prefix
 <br>xmlns:Q1="..." to the schema it generates. How come? (I can get rid
 of it
 <br>when specifying a default namespace, but that's not want I want to...)
 <br>Thanks for help,
 <p>Dirk
 <p>(Example it an excerpt from library.xsd taken from the very good O'Reillly
 <br>book XMLSchema, author: E. van der Vlist)
 <br>public XSDSchema initializeSD3Schema() throws Exception {
 <p>XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
 <p>xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
 <p>xsdSchema.setTargetNamespace("<a href="http://www.divos.de/sd3.xsd">http://www.divos.de/sd3.xsd</a>");
 <p>Map qNamePrefixToNamespaceMap =
 <p>xsdSchema.getQNamePrefixToNamespaceMap();
 <p>qNamePrefixToNamespaceMap.put(
 <p>xsdSchema.getSchemaForSchemaQNamePrefix(),
 <p>XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
 <p>XSDFactory xsdFactory = XSDSchemaBuildingTools.getXSDFactory();
 <p>String targetNamespace = xsdSchema.getTargetNamespace();
 <p>XSDElementDeclaration elementDecl = null;
 <p>elementDecl =
 <p>xsdSchema.resolveElementDeclaration(targetNamespace, "name");
 <p>XSDTypeDefinition typeDef =
 <p>xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
 <p>"string");
 <p>elementDecl.setTypeDefinition(typeDef);
 <p>xsdSchema.getContents().add(elementDecl);
 <p>elementDecl =
 <p>xsdSchema.resolveElementDeclaration(targetNamespace, "isbn");
 <p>typeDef =
 <p>xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
 <p>"string");
 <p>elementDecl.setTypeDefinition(typeDef);
 <p>xsdSchema.getContents().add(elementDecl);
 <p>elementDecl =
 <p>xsdSchema.resolveElementDeclaration(targetNamespace, "author");
 <p>XSDComplexTypeDefinition anonymousComplexTypeDefinition =
 <p>xsdFactory.createXSDComplexTypeDefinition();
 <p>XSDModelGroup anonymousComplexTypeDefinitionSequence =
 <p>xsdFactory.createXSDModelGroup();
 <p>anonymousComplexTypeDefinitionSequence.setCompositor(
 <p>XSDCompositor.SEQUENCE_LITERAL);
 <p>XSDParticle anonymousTypeDefinitionParticle =
 <p>xsdFactory.createXSDParticle();
 <p>anonymousTypeDefinitionParticle.setContent(
 <p>anonymousComplexTypeDefinitionSequence);
 <p>XSDElementDeclaration nameRef =
 <p>xsdFactory.createXSDElementDeclaration();
 <p>nameRef.setResolvedElementDeclaration(
 <p>xsdSchema.resolveElementDeclaration("name"));
 <p>XSDParticle nameRefParticle = xsdFactory.createXSDParticle();
 <p>nameRefParticle.setContent(nameRef);
 <p>anonymousComplexTypeDefinitionSequence.getContents().add(
 <p>nameRefParticle);
 <p>anonymousComplexTypeDefinition.setContent(
 <p>anonymousTypeDefinitionParticle);
 <p> elementDecl.setAnonymousTypeDefinition(anonymousComplexTypeD efinition);
 <p>xsdSchema.getContents().add(elementDecl);
 <p>XSDAttributeDeclaration attributeDecl =
 <p>xsdFactory.createXSDAttributeDeclaration();
 <p>attributeDecl.setName("id");
 <p>attributeDecl.setTypeDefinition(
 <p>xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition( "ID"));
 <p>xsdSchema.getContents().add(attributeDecl);
 <p>return xsdSchema;
 <p>}</blockquote>
 </html>
 
 --------------8193787C9112A53913FC62B0--
 |  |  |  |  | 
| Re: Generated Namespace Prexfix xmlns:Q1: How come? [message #572267 is a reply to message #22851] | Tue, 20 May 2003 11:40  |  | 
| Eclipse User  |  |  |  |  | --------------8193787C9112A53913FC62B0 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 Dirk,
 
 In order to reference anything in any namespace, an xmlns declaration is
 required for the namespace.  If there isn't one already specified, one is
 created on demand.  If you have a particular favorite prefix you want to use,
 you should set it into the prefix map beforehand, e.g., this will create a null
 prefix for the schema's target namespace:
 
 qNameToPrefixMap.put(null, targetNamespace)
 
 "Dirk V. Schesmer" wrote:
 
 > Hi there,
 > whenever I add an element reference to the method generating my schema (see
 > code below), the system automatically adds the namespace prefix
 > xmlns:Q1="..." to the schema it generates. How come? (I can get rid of it
 > when specifying a default namespace, but that's not want I want to...)
 > Thanks for help,
 >
 > Dirk
 >
 > (Example it an excerpt from library.xsd taken from the very good O'Reillly
 > book XMLSchema, author: E. van der Vlist)
 > public XSDSchema initializeSD3Schema() throws Exception {
 >
 > XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
 >
 > xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
 >
 > xsdSchema.setTargetNamespace("http://www.divos.de/sd3.xsd");
 >
 > Map qNamePrefixToNamespaceMap =
 >
 > xsdSchema.getQNamePrefixToNamespaceMap();
 >
 > qNamePrefixToNamespaceMap.put(
 >
 > xsdSchema.getSchemaForSchemaQNamePrefix(),
 >
 > XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
 >
 > XSDFactory xsdFactory = XSDSchemaBuildingTools.getXSDFactory();
 >
 > String targetNamespace = xsdSchema.getTargetNamespace();
 >
 > XSDElementDeclaration elementDecl = null;
 >
 > elementDecl =
 >
 > xsdSchema.resolveElementDeclaration(targetNamespace, "name");
 >
 > XSDTypeDefinition typeDef =
 >
 > xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
 >
 > "string");
 >
 > elementDecl.setTypeDefinition(typeDef);
 >
 > xsdSchema.getContents().add(elementDecl);
 >
 > elementDecl =
 >
 > xsdSchema.resolveElementDeclaration(targetNamespace, "isbn");
 >
 > typeDef =
 >
 > xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
 >
 > "string");
 >
 > elementDecl.setTypeDefinition(typeDef);
 >
 > xsdSchema.getContents().add(elementDecl);
 >
 > elementDecl =
 >
 > xsdSchema.resolveElementDeclaration(targetNamespace, "author");
 >
 > XSDComplexTypeDefinition anonymousComplexTypeDefinition =
 >
 > xsdFactory.createXSDComplexTypeDefinition();
 >
 > XSDModelGroup anonymousComplexTypeDefinitionSequence =
 >
 > xsdFactory.createXSDModelGroup();
 >
 > anonymousComplexTypeDefinitionSequence.setCompositor(
 >
 > XSDCompositor.SEQUENCE_LITERAL);
 >
 > XSDParticle anonymousTypeDefinitionParticle =
 >
 > xsdFactory.createXSDParticle();
 >
 > anonymousTypeDefinitionParticle.setContent(
 >
 > anonymousComplexTypeDefinitionSequence);
 >
 > XSDElementDeclaration nameRef =
 >
 > xsdFactory.createXSDElementDeclaration();
 >
 > nameRef.setResolvedElementDeclaration(
 >
 > xsdSchema.resolveElementDeclaration("name"));
 >
 > XSDParticle nameRefParticle = xsdFactory.createXSDParticle();
 >
 > nameRefParticle.setContent(nameRef);
 >
 > anonymousComplexTypeDefinitionSequence.getContents().add(
 >
 > nameRefParticle);
 >
 > anonymousComplexTypeDefinition.setContent(
 >
 > anonymousTypeDefinitionParticle);
 >
 >  elementDecl.setAnonymousTypeDefinition(anonymousComplexTypeD efinition);
 >
 > xsdSchema.getContents().add(elementDecl);
 >
 > XSDAttributeDeclaration attributeDecl =
 >
 > xsdFactory.createXSDAttributeDeclaration();
 >
 > attributeDecl.setName("id");
 >
 > attributeDecl.setTypeDefinition(
 >
 > xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("ID "));
 >
 > xsdSchema.getContents().add(attributeDecl);
 >
 > return xsdSchema;
 >
 > }
 
 --------------8193787C9112A53913FC62B0
 Content-Type: text/html; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
 <html>
 Dirk,
 <p>In order to reference anything in any namespace, an xmlns declaration
 is required for the namespace.  If there isn't one already specified,
 one is created on demand.  If you have a particular favorite prefix
 you want to use, you should set it into the prefix map beforehand, e.g.,
 this will create a null prefix for the schema's target namespace:
 <blockquote>qNameToPrefixMap.put(null, targetNamespace)</blockquote>
 
 <p>"Dirk V. Schesmer" wrote:
 <blockquote TYPE=CITE>Hi there,
 <br>whenever I add an element reference to the method generating my schema
 (see
 <br>code below), the system automatically adds the namespace prefix
 <br>xmlns:Q1="..." to the schema it generates. How come? (I can get rid
 of it
 <br>when specifying a default namespace, but that's not want I want to...)
 <br>Thanks for help,
 <p>Dirk
 <p>(Example it an excerpt from library.xsd taken from the very good O'Reillly
 <br>book XMLSchema, author: E. van der Vlist)
 <br>public XSDSchema initializeSD3Schema() throws Exception {
 <p>XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();
 <p>xsdSchema.setSchemaForSchemaQNamePrefix("xsd");
 <p>xsdSchema.setTargetNamespace("<a href="http://www.divos.de/sd3.xsd">http://www.divos.de/sd3.xsd</a>");
 <p>Map qNamePrefixToNamespaceMap =
 <p>xsdSchema.getQNamePrefixToNamespaceMap();
 <p>qNamePrefixToNamespaceMap.put(
 <p>xsdSchema.getSchemaForSchemaQNamePrefix(),
 <p>XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
 <p>XSDFactory xsdFactory = XSDSchemaBuildingTools.getXSDFactory();
 <p>String targetNamespace = xsdSchema.getTargetNamespace();
 <p>XSDElementDeclaration elementDecl = null;
 <p>elementDecl =
 <p>xsdSchema.resolveElementDeclaration(targetNamespace, "name");
 <p>XSDTypeDefinition typeDef =
 <p>xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
 <p>"string");
 <p>elementDecl.setTypeDefinition(typeDef);
 <p>xsdSchema.getContents().add(elementDecl);
 <p>elementDecl =
 <p>xsdSchema.resolveElementDeclaration(targetNamespace, "isbn");
 <p>typeDef =
 <p>xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition(
 <p>"string");
 <p>elementDecl.setTypeDefinition(typeDef);
 <p>xsdSchema.getContents().add(elementDecl);
 <p>elementDecl =
 <p>xsdSchema.resolveElementDeclaration(targetNamespace, "author");
 <p>XSDComplexTypeDefinition anonymousComplexTypeDefinition =
 <p>xsdFactory.createXSDComplexTypeDefinition();
 <p>XSDModelGroup anonymousComplexTypeDefinitionSequence =
 <p>xsdFactory.createXSDModelGroup();
 <p>anonymousComplexTypeDefinitionSequence.setCompositor(
 <p>XSDCompositor.SEQUENCE_LITERAL);
 <p>XSDParticle anonymousTypeDefinitionParticle =
 <p>xsdFactory.createXSDParticle();
 <p>anonymousTypeDefinitionParticle.setContent(
 <p>anonymousComplexTypeDefinitionSequence);
 <p>XSDElementDeclaration nameRef =
 <p>xsdFactory.createXSDElementDeclaration();
 <p>nameRef.setResolvedElementDeclaration(
 <p>xsdSchema.resolveElementDeclaration("name"));
 <p>XSDParticle nameRefParticle = xsdFactory.createXSDParticle();
 <p>nameRefParticle.setContent(nameRef);
 <p>anonymousComplexTypeDefinitionSequence.getContents().add(
 <p>nameRefParticle);
 <p>anonymousComplexTypeDefinition.setContent(
 <p>anonymousTypeDefinitionParticle);
 <p> elementDecl.setAnonymousTypeDefinition(anonymousComplexTypeD efinition);
 <p>xsdSchema.getContents().add(elementDecl);
 <p>XSDAttributeDeclaration attributeDecl =
 <p>xsdFactory.createXSDAttributeDeclaration();
 <p>attributeDecl.setName("id");
 <p>attributeDecl.setTypeDefinition(
 <p>xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition( "ID"));
 <p>xsdSchema.getContents().add(attributeDecl);
 <p>return xsdSchema;
 <p>}</blockquote>
 </html>
 
 --------------8193787C9112A53913FC62B0--
 |  |  |  | 
 
 
 Current Time: Fri Oct 31 19:10:57 EDT 2025 
 Powered by FUDForum . Page generated in 0.03251 seconds |