|
|
|
| Re: Serializing namespaces on the xsd schema level [message #231644 is a reply to message #231482] |
Wed, 20 May 2009 01:17   |
|
Originally posted by: valentinbaciu.hotmail.com
Ravikanth, try this working example:
public class XSDSchemaPrefixSample extends TestCase
{
private static final String SCHEMA_FOR_SCHEMA_PREFIX = "xsd";
//$NON-NLS-1$
public void testSupportsSchemaPrefix() throws Exception
{
ResourceSetImpl resourceSet = new ResourceSetImpl();
WSDLResourceImpl wsdlResource =
(WSDLResourceImpl)resourceSet.createResource(URI.createFileU RI( "schemaTest.wsdl"));
WSDLFactory factory = WSDLFactory.eINSTANCE;
Definition definition = factory.createDefinition();
wsdlResource.getContents().add(definition);
definition.setTargetNamespace("http://www.example.org");
definition.addNamespace("wsdl", WSDLConstants.WSDL_NAMESPACE_URI);
Types types = factory.createTypes();
definition.setTypes(types);
XSDSchemaExtensibilityElement schemaExtensibilityElement =
factory.createXSDSchemaExtensibilityElement();
types.addExtensibilityElement(schemaExtensibilityElement);
XSDFactory xsdFactory = XSDFactory.eINSTANCE;
XSDSchema schema = xsdFactory.createXSDSchema();
schemaExtensibilityElement.setSchema(schema);
Map<String, String> qNamePrefixToNamespaceMap =
schema.getQNamePrefixToNamespaceMap();
qNamePrefixToNamespaceMap.put(SCHEMA_FOR_SCHEMA_PREFIX,
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
schema.setSchemaForSchemaQNamePrefix(SCHEMA_FOR_SCHEMA_PREFI X);
wsdlResource.save(null);
}
}
The code above produces a WSDL document that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://www.example.org">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
</wsdl:types>
</wsdl:definitions>
"Ravikanth " <ravikanth.somayaji@gmail.com> wrote in message
news:1930c4413a09c2d4e2df4ba5467377a3$1@www.eclipse.org...
> Thanks for the reply. I did try that, but it doesn't seem to serialize. It
> must be an XMLSerializer thing that restricts child elements to have
> namespaces declared if it has already been declared for the parent
> element.
>
|
|
|
|
|
| Re: Serializing namespaces on the xsd schema level [message #231933 is a reply to message #231692] |
Thu, 28 May 2009 10:22  |
Ravikanth Somayaji Messages: 39 Registered: July 2009 Location: Oxford |
Member |
|
|
I'm afraid that doesn't help much. HOwever, I've resolved it for my
re-serializer to get the namespaces from the parent, so I could consider
this resolved.
Many thanks for your assistance.
-Ravi
Valentin wrote:
> Yep, just add this line after setting the prefix for the WSDL namespace:
> definition.addNamespace(SCHEMA_FOR_SCHEMA_PREFIX,
> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>
|
|
|
Powered by
FUDForum. Page generated in 0.10132 seconds