Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Generated Namespace Prexfix xmlns:Q1: How come?
Generated Namespace Prexfix xmlns:Q1: How come? [message #572231] Mon, 19 May 2003 17:51
Eclipse UserFriend
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;

}
Previous Topic:[FYI] More Tests with Schemas defined in WSDL
Next Topic:Generated Namespace Prexfix xmlns:Q1: How come?
Goto Forum:
  


Current Time: Thu Apr 25 22:46:59 GMT 2024

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

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

Back to the top