Generated Namespace Prexfix xmlns:Q1: How come? [message #572231] |
Mon, 19 May 2003 17: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;
}
|
|
|
Powered by
FUDForum. Page generated in 0.02521 seconds