Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Serializing namespaces on the xsd schema level
Serializing namespaces on the xsd schema level [message #231372] Fri, 15 May 2009 13:44 Go to next message
Ravikanth Somayaji is currently offline Ravikanth SomayajiFriend
Messages: 49
Registered: July 2009
Location: Oxford
Member
Hi,

I've been generating a WSDL programmatically using the WSDL EMF API.
However, one of my usages requires me to serialize the wsdl this way.

<wsdl:definitions
xmlns:ns="http://www.x.com/bs3.0/_lHsqQEE3Ed6EEvHYz9LK4Q"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="ProcessPackage"
targetNamespace="http://www.x.com/y3.0/_lHsqQEE3Ed6EEvHYz9LK4Q">
<wsdl:types>
<xsd:schema xmlns="http://www.x.com/bs3.0/_lHsqQEE3Ed6EEvHYz9LK4Q"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.x.com/bs3.0/_lHsqQEE3Ed6EEvHYz9LK4Q">
<xsd:simpleType name="string_50">

However, Save does not serialize
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' in the xsd schema. I
understand this already occurs in the parenting element, but I still need
to serialize it there.

Kindly advice.

Thanks, Ravi
Re: Serializing namespaces on the xsd schema level [message #231419 is a reply to message #231372] Fri, 15 May 2009 18:08 Go to previous messageGo to next message
Gabriel Indik is currently offline Gabriel IndikFriend
Messages: 16
Registered: July 2009
Junior Member
Ravi,
Try the following: set up the prefix/namespace map information for your
schema by making the following API calls:

schema.getQNamePrefixToNamespaceMap().put("xsd",
org.eclipse.xsd.util.XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001 );

schema.setSchemaForSchemaQNamePrefix("xsd")
Re: Serializing namespaces on the xsd schema level [message #231482 is a reply to message #231419] Mon, 18 May 2009 09:58 Go to previous messageGo to next message
Ravikanth Somayaji is currently offline Ravikanth SomayajiFriend
Messages: 49
Registered: July 2009
Location: Oxford
Member
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 #231644 is a reply to message #231482] Wed, 20 May 2009 05:17 Go to previous messageGo to next message
Eclipse UserFriend
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 #231659 is a reply to message #231644] Wed, 20 May 2009 09:46 Go to previous messageGo to next message
Ravikanth Somayaji is currently offline Ravikanth SomayajiFriend
Messages: 49
Registered: July 2009
Location: Oxford
Member
Hi Valentin,

Thanks for your reply.

I tried that and that works fine, but is there any way to serialize
[xmlns:xsd="http://www.w3.org/2001/XMLSchema"] on both the root element
and the xsd:schema element?

Like, I said before, it is probably not the best of XML constructed, but
it seems to be needed for some transformation I'm writing.

-Ravi

Valentin wrote:

> Ravikanth, try this working example:

> 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>
Re: Serializing namespaces on the xsd schema level [message #231692 is a reply to message #231659] Wed, 20 May 2009 14:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: valentinbaciu.hotmail.com

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);


"Ravikanth " <ravikanth.somayaji@gmail.com> wrote in message
news:f993cef7c14c50671e824f859d18805e$1@www.eclipse.org...
> Hi Valentin,
>
> Thanks for your reply.
>
> I tried that and that works fine, but is there any way to serialize
> [xmlns:xsd="http://www.w3.org/2001/XMLSchema"] on both the root element
> and the xsd:schema element?
>
> Like, I said before, it is probably not the best of XML constructed, but
> it seems to be needed for some transformation I'm writing.
>
> -Ravi
>
> Valentin wrote:
>
>> Ravikanth, try this working example:
>
>> 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>
>
>
>
Re: Serializing namespaces on the xsd schema level [message #231933 is a reply to message #231692] Thu, 28 May 2009 14:22 Go to previous message
Ravikanth Somayaji is currently offline Ravikanth SomayajiFriend
Messages: 49
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);


>
Previous Topic:runtimePath variable in Component Core
Next Topic:Creating a new Module Type
Goto Forum:
  


Current Time: Fri Apr 26 14:50:49 GMT 2024

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

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

Back to the top