Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » showing the prefix
showing the prefix [message #57003] Wed, 12 January 2005 17:31 Go to next message
Eclipse UserFriend
Originally posted by: ooi.de.ibm.com

Hello,

I would like to know how do we "show" the prefixes in the schema we
generate.. for eg.

<xsd:import....> instead of <import>
<xsd:element ..> instead of <element>

thank you.
Re: showing the prefix [message #57057 is a reply to message #57003] Thu, 13 January 2005 17:06 Go to previous message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
HT Ooi wrote:
> I would like to know how do we "show" the prefixes in the schema we
> generate.. for eg.
> <xsd:import....> instead of <import>
> <xsd:element ..> instead of <element>

You can set the qname prefix used to reference the schema for schema
namespace via XSDSchema.setSchemaForSchemaQNamePrefix(). There's also a
map accesible via XSDSchema.getQNamePrefixToNamespaceMap() that defines
all of the namespace qname-namespace pairs to use in the schema. It must
have an entry that agrees with the above schema for schema namespace
prefix, too. So, for the result shown in your example:

XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();

schema.setTargetNamespace("http://www.example.com/test");
schema.setSchemaForSchemaQNamePrefix("xsd");

Map namespaceMap = schema.getQNamePrefixToNamespaceMap();
namespaceMap.put(schema.getSchemaForSchemaQNamePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);

You'd also want to set a prefix to use for the target namespace. Setting
null makes it the default namespace.

namespaceMap.put(null, schema.getTargetNamespace());

Cheers,
Dave
Re: showing the prefix [message #593566 is a reply to message #57003] Thu, 13 January 2005 17:06 Go to previous message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
HT Ooi wrote:
> I would like to know how do we "show" the prefixes in the schema we
> generate.. for eg.
> <xsd:import....> instead of <import>
> <xsd:element ..> instead of <element>

You can set the qname prefix used to reference the schema for schema
namespace via XSDSchema.setSchemaForSchemaQNamePrefix(). There's also a
map accesible via XSDSchema.getQNamePrefixToNamespaceMap() that defines
all of the namespace qname-namespace pairs to use in the schema. It must
have an entry that agrees with the above schema for schema namespace
prefix, too. So, for the result shown in your example:

XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();

schema.setTargetNamespace("http://www.example.com/test");
schema.setSchemaForSchemaQNamePrefix("xsd");

Map namespaceMap = schema.getQNamePrefixToNamespaceMap();
namespaceMap.put(schema.getSchemaForSchemaQNamePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);

You'd also want to set a prefix to use for the target namespace. Setting
null makes it the default namespace.

namespaceMap.put(null, schema.getTargetNamespace());

Cheers,
Dave
Previous Topic:complexContent
Next Topic:complexContent
Goto Forum:
  


Current Time: Thu Oct 10 22:29:56 GMT 2024

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

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

Back to the top