| 
| showing the prefix [message #57003] | Wed, 12 January 2005 12:31  |  | 
| Eclipse User  |  |  |  |  | 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 12:06  |  | 
| Eclipse User  |  |  |  |  | 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 12:06  |  | 
| Eclipse User  |  |  |  |  | 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
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.05387 seconds