Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » XMLResource with xmlns=""
XMLResource with xmlns="" [message #528628] Wed, 21 April 2010 09:38 Go to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 770
Registered: July 2009
Location: Grenoble, France
Senior Member
Hi,

I am trying to import an XML file in EMF with a factory generated with xsd2ecore:

Resource resource = new jpdl32ResourceFactoryImpl().createResource(sourceJBPMUri);
options.put(Collections.EMPTY_MAP);
resource.load(options);

However, most of targeted file have their xmlns blank (we can read the xmlns="" in the top-level element). Then the factory tells me the following:
java.lang.RuntimeException: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'null' not found.

If I set the xmlns to the right value manually, everything goes well, but I'd like to know how to ignore this xmlns (since I know the target factory and so on), or how to specify it while loading the resource, rather than altering the resource.
I've tried to load the resource with option jpdl32ResourceImpl.NO_NAMESPACE_SCHEMA_LOCATION="true", but this did not do the trick. I also tried to play with the XMLResource.OPTION_SCHEMA_LOCATION without success.

Does anybody have an idea of how to bypass this dummy xmlns value?

Regards,
--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
Re: XMLResource with xmlns="" [message #528718 is a reply to message #528628] Wed, 21 April 2010 14:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26237
Registered: July 2009
Senior Member
Mickael,

Comments below.

Mickael Istria wrote:
> Hi,
>
> I am trying to import an XML file in EMF with a factory generated with
> xsd2ecore:
>
> Resource resource = new
> jpdl32ResourceFactoryImpl().createResource(sourceJBPMUri);
> options.put(Collections.EMPTY_MAP);
> resource.load(options);
>
> However, most of targeted file have their xmlns blank (we can read the
> xmlns="" in the top-level element). Then the factory tells me the
> following:
> java.lang.RuntimeException:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package
> with uri 'null' not found.
> If I set the xmlns to the right value manually, everything goes well,
> but I'd like to know how to ignore this xmlns (since I know the target
> factory and so on), or how to specify it while loading the resource,
> rather than altering the resource.
> I've tried to load the resource with option
> jpdl32ResourceImpl.NO_NAMESPACE_SCHEMA_LOCATION="true", but this did
> not do the trick. I also tried to play with the
> XMLResource.OPTION_SCHEMA_LOCATION without success.
>
> Does anybody have an idea of how to bypass this dummy xmlns value?
It's really not a dummy value. In the end, for the instance to conform
to your schema, it must have the right namespace. If you start with a
schema with a null target namespace, you'll see the EPackage has a
special annotation on it to indicate the namespace is null and the
generated XyzResourceFactoryImpl will have the right structure to load
instances without a namespace. So try generating a model for a null
target namespace schema to see what's generated.
>
> Regards,
> --
> Mickael Istria - BonitaSoft S.A.
> http://www.bonitasoft.com/products/downloads.php
Re: XMLResource with xmlns="" [message #528750 is a reply to message #528718] Wed, 21 April 2010 16:11 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 770
Registered: July 2009
Location: Grenoble, France
Senior Member
Thanks Ed,

More questions below:

>> I am trying to import an XML file in EMF with a factory generated with
>> xsd2ecore:
>>
>> Resource resource = new
>> jpdl32ResourceFactoryImpl().createResource(sourceJBPMUri);
>> options.put(Collections.EMPTY_MAP);
>> resource.load(options);
>>
>> However, most of targeted file have their xmlns blank (we can read the
>> xmlns="" in the top-level element). Then the factory tells me the
>> following:
>> java.lang.RuntimeException:
>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package
>> with uri 'null' not found.
>> If I set the xmlns to the right value manually, everything goes well,
>> but I'd like to know how to ignore this xmlns (since I know the target
>> factory and so on), or how to specify it while loading the resource,
>> rather than altering the resource.
>> I've tried to load the resource with option
>> jpdl32ResourceImpl.NO_NAMESPACE_SCHEMA_LOCATION="true", but this did
>> not do the trick. I also tried to play with the
>> XMLResource.OPTION_SCHEMA_LOCATION without success.
>>
>> Does anybody have an idea of how to bypass this dummy xmlns value?
> It's really not a dummy value. In the end, for the instance to conform
> to your schema, it must have the right namespace. If you start with a
> schema with a null target namespace, you'll see the EPackage has a
> special annotation on it to indicate the namespace is null and the
> generated XyzResourceFactoryImpl will have the right structure to load
> instances without a namespace. So try generating a model for a null
> target namespace schema to see what's generated.

Sorry but I don't understand what I have to modify concretely on my ecore or my genmodel to make my package able to support null namespace. Indeed, Epackage does not support empty string as nsUri in ecore editor and I did not find the property to allow null package. Do I have to add an EAnnotation as a child of the EPackage? If yes, what is the ref and source to set?
Sorry for these basic questions, but I am not easy with annotations.

--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
Re: XMLResource with xmlns="" [message #528756 is a reply to message #528750] Wed, 21 April 2010 16:26 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26237
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020101030109020500000800
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Mickael,

Some things to look at:

Binding XML to Java
< http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>
XML Schema to Ecore Mapping
< http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>
Essential EMF, DZone Refcard
<http://refcardz.dzone.com/refcardz/essential-emf>

A trivial schema without a targetNamespace attribute on the xsd:schema
will generate results that show you what you need.


Mickael Istria wrote:
> Thanks Ed,
>
> More questions below:
>
>>> I am trying to import an XML file in EMF with a factory generated
>>> with xsd2ecore:
>>>
>>> Resource resource = new
>>> jpdl32ResourceFactoryImpl().createResource(sourceJBPMUri);
>>> options.put(Collections.EMPTY_MAP);
>>> resource.load(options);
>>>
>>> However, most of targeted file have their xmlns blank (we can read
>>> the xmlns="" in the top-level element). Then the factory tells me
>>> the following:
>>> java.lang.RuntimeException:
>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package
>>> with uri 'null' not found.
>>> If I set the xmlns to the right value manually, everything goes
>>> well, but I'd like to know how to ignore this xmlns (since I know
>>> the target factory and so on), or how to specify it while loading
>>> the resource, rather than altering the resource.
>>> I've tried to load the resource with option
>>> jpdl32ResourceImpl.NO_NAMESPACE_SCHEMA_LOCATION="true", but this did
>>> not do the trick. I also tried to play with the
>>> XMLResource.OPTION_SCHEMA_LOCATION without success.
>>>
>>> Does anybody have an idea of how to bypass this dummy xmlns value?
>> It's really not a dummy value. In the end, for the instance to
>> conform to your schema, it must have the right namespace. If you
>> start with a schema with a null target namespace, you'll see the
>> EPackage has a special annotation on it to indicate the namespace is
>> null and the generated XyzResourceFactoryImpl will have the right
>> structure to load instances without a namespace. So try generating a
>> model for a null target namespace schema to see what's generated.
>
> Sorry but I don't understand what I have to modify concretely on my
> ecore or my genmodel to make my package able to support null
> namespace. Indeed, Epackage does not support empty string as nsUri in
> ecore editor and I did not find the property to allow null package. Do
> I have to add an EAnnotation as a child of the EPackage? If yes, what
> is the ref and source to set?
> Sorry for these basic questions, but I am not easy with annotations.
>
> --
> Mickael Istria - BonitaSoft S.A.
> http://www.bonitasoft.com/products/downloads.php

--------------020101030109020500000800
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Mickael,<br>
<br>
Some things to look at:<br>
<blockquote><a target="_out"
href=" http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava">Binding
XML to Java</a><br>
<a
href=" http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf">XML
Schema to Ecore Mapping</a><br>
<a href="http://refcardz.dzone.com/refcardz/essential-emf">Essential
EMF, DZone Refcard</a><br>
</blockquote>
A trivial schema without a targetNamespace attribute on the xsd:schema
will generate results that show you what you need.<br>
<br>
<br>
Mickael Istria wrote:
<blockquote cite="mid:hqn831$qsf$1@build.eclipse.org" type="cite">Thanks
Ed,
<br>
<br>
More questions below:
<br>
<br>
<blockquote type="cite">
<blockquote type="cite">I am trying to import an XML file in EMF
with a factory generated with xsd2ecore:
<br>
<br>
&nbsp;&nbsp;&nbsp; Resource resource = new
jpdl32ResourceFactoryImpl().createResource(sourceJBPMUri);
<br>
&nbsp;&nbsp;&nbsp; options.put(Collections.EMPTY_MAP);
<br>
&nbsp;&nbsp;&nbsp; resource.load(options);
<br>
<br>
However, most of targeted file have their xmlns blank (we can read the
xmlns="" in the top-level element). Then the factory tells me the
following:
<br>
&nbsp;&nbsp;&nbsp; java.lang.RuntimeException:
org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package
with uri 'null' not found.
<br>
If I set the xmlns to the right value manually, everything goes well,
but I'd like to know how to ignore this xmlns (since I know the target
factory and so on), or how to specify it while loading the resource,
rather than altering the resource.
<br>
I've tried to load the resource with option
jpdl32ResourceImpl.NO_NAMESPACE_SCHEMA_LOCATION="true", but this did
not do the trick. I also tried to play with the
XMLResource.OPTION_SCHEMA_LOCATION without success.
<br>
<br>
Does anybody have an idea of how to bypass this dummy xmlns value?
<br>
</blockquote>
It's really not a dummy value.&nbsp; In the end, for the instance to conform
to your schema, it must have the right namespace.&nbsp; If you start with a
schema with a null target namespace, you'll see the EPackage has a
special annotation on it to indicate the namespace is null and the
generated XyzResourceFactoryImpl will have the right structure to load
instances without a namespace.&nbsp; So try generating a model for a null
target namespace schema to see what's generated.
<br>
</blockquote>
<br>
Sorry but I don't understand what I have to modify concretely on my
ecore or my genmodel to make my package able to support null namespace.
Indeed, Epackage does not support empty string as nsUri in ecore editor
and I did not find the property to allow null package. Do I have to add
an EAnnotation as a child of the EPackage? If yes, what is the ref and
source to set?
<br>
Sorry for these basic questions, but I am not easy with annotations.
<br>
<br>
--
<br>
Mickael Istria - BonitaSoft S.A.
<br>
<a class="moz-txt-link-freetext" href="http://www.bonitasoft.com/products/downloads.php">http://www.bonitasoft.com/products/downloads.php</a>
<br>
</blockquote>
</body>
</html>

--------------020101030109020500000800--
Re: XMLResource with xmlns="" [message #528876 is a reply to message #528756] Thu, 22 April 2010 09:12 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 770
Registered: July 2009
Location: Grenoble, France
Senior Member
Ed Merks a écrit :
> Mickael,
>
> Some things to look at:
>
> Binding XML to Java
> < http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>
> XML Schema to Ecore Mapping
> < http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>
> Essential EMF, DZone Refcard
> <http://refcardz.dzone.com/refcardz/essential-emf>
>
> A trivial schema without a targetNamespace attribute on the xsd:schema
> will generate results that show you what you need.

Thanks a lot Ed, I tried with a dummy xsd without target namespace, and copied the annotation it generated and everything works well without xmlns.
However it seems to me that there can only be one namespace by Package. However I'd like my package to be mapped to 2 namespaces: blank/null and the real one from xsd, since we can find some xml files with xmlns set or not. Is this possible? Do you have another magic annotation to suggest ;) ?

--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
Re: XMLResource with xmlns="" [message #528899 is a reply to message #528876] Thu, 22 April 2010 10:41 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26237
Registered: July 2009
Senior Member
Mickael,

Comments below.

Mickael Istria wrote:
> Ed Merks a écrit :
>> Mickael,
>>
>> Some things to look at:
>>
>> Binding XML to Java
>>
>> < http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>
>> XML Schema to Ecore Mapping
>>
>> < http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>
>>
>> Essential EMF, DZone Refcard
>> <http://refcardz.dzone.com/refcardz/essential-emf>
>>
>> A trivial schema without a targetNamespace attribute on the
>> xsd:schema will generate results that show you what you need.
>
> Thanks a lot Ed, I tried with a dummy xsd without target namespace,
> and copied the annotation it generated and everything works well
> without xmlns.
Woo hoo. :-)
> However it seems to me that there can only be one namespace by Package.
Globally yes, and within any given context, yes.
> However I'd like my package to be mapped to 2 namespaces: blank/null
> and the real one from xsd, since we can find some xml files with xmlns
> set or not. Is this possible?
Yes.
> Do you have another magic annotation to suggest ;) ?
You'd need different resource factories for each case. You'd have to
specialize the BasicExtendedMetaData implementation used to make the the
package appear to have a null namespace. E.g., specialize methods like
getPackage to return the package either for null or the proper namespace
and methods like getNamespace for producing the desired serialization
with or without a namespace. You could use content types to register
the factories in each case for the same extension. If you set a content
type identifier in the GenPackage, delete the plugin.xml, and
regenerate, you'll see how the registration for those work.
>
> --
> Mickael Istria - BonitaSoft S.A.
> http://www.bonitasoft.com/products/downloads.php
Re: XMLResource with xmlns="" [message #619540 is a reply to message #528628] Wed, 21 April 2010 14:55 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26237
Registered: July 2009
Senior Member
Mickael,

Comments below.

Mickael Istria wrote:
> Hi,
>
> I am trying to import an XML file in EMF with a factory generated with
> xsd2ecore:
>
> Resource resource = new
> jpdl32ResourceFactoryImpl().createResource(sourceJBPMUri);
> options.put(Collections.EMPTY_MAP);
> resource.load(options);
>
> However, most of targeted file have their xmlns blank (we can read the
> xmlns="" in the top-level element). Then the factory tells me the
> following:
> java.lang.RuntimeException:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package
> with uri 'null' not found.
> If I set the xmlns to the right value manually, everything goes well,
> but I'd like to know how to ignore this xmlns (since I know the target
> factory and so on), or how to specify it while loading the resource,
> rather than altering the resource.
> I've tried to load the resource with option
> jpdl32ResourceImpl.NO_NAMESPACE_SCHEMA_LOCATION="true", but this did
> not do the trick. I also tried to play with the
> XMLResource.OPTION_SCHEMA_LOCATION without success.
>
> Does anybody have an idea of how to bypass this dummy xmlns value?
It's really not a dummy value. In the end, for the instance to conform
to your schema, it must have the right namespace. If you start with a
schema with a null target namespace, you'll see the EPackage has a
special annotation on it to indicate the namespace is null and the
generated XyzResourceFactoryImpl will have the right structure to load
instances without a namespace. So try generating a model for a null
target namespace schema to see what's generated.
>
> Regards,
> --
> Mickael Istria - BonitaSoft S.A.
> http://www.bonitasoft.com/products/downloads.php
Re: XMLResource with xmlns="" [message #619541 is a reply to message #528718] Wed, 21 April 2010 16:11 Go to previous message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 770
Registered: July 2009
Location: Grenoble, France
Senior Member
Thanks Ed,

More questions below:

>> I am trying to import an XML file in EMF with a factory generated with
>> xsd2ecore:
>>
>> Resource resource = new
>> jpdl32ResourceFactoryImpl().createResource(sourceJBPMUri);
>> options.put(Collections.EMPTY_MAP);
>> resource.load(options);
>>
>> However, most of targeted file have their xmlns blank (we can read the
>> xmlns="" in the top-level element). Then the factory tells me the
>> following:
>> java.lang.RuntimeException:
>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package
>> with uri 'null' not found.
>> If I set the xmlns to the right value manually, everything goes well,
>> but I'd like to know how to ignore this xmlns (since I know the target
>> factory and so on), or how to specify it while loading the resource,
>> rather than altering the resource.
>> I've tried to load the resource with option
>> jpdl32ResourceImpl.NO_NAMESPACE_SCHEMA_LOCATION="true", but this did
>> not do the trick. I also tried to play with the
>> XMLResource.OPTION_SCHEMA_LOCATION without success.
>>
>> Does anybody have an idea of how to bypass this dummy xmlns value?
> It's really not a dummy value. In the end, for the instance to conform
> to your schema, it must have the right namespace. If you start with a
> schema with a null target namespace, you'll see the EPackage has a
> special annotation on it to indicate the namespace is null and the
> generated XyzResourceFactoryImpl will have the right structure to load
> instances without a namespace. So try generating a model for a null
> target namespace schema to see what's generated.

Sorry but I don't understand what I have to modify concretely on my ecore or my genmodel to make my package able to support null namespace. Indeed, Epackage does not support empty string as nsUri in ecore editor and I did not find the property to allow null package. Do I have to add an EAnnotation as a child of the EPackage? If yes, what is the ref and source to set?
Sorry for these basic questions, but I am not easy with annotations.

--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
Re: XMLResource with xmlns="" [message #619543 is a reply to message #528750] Wed, 21 April 2010 16:26 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26237
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020101030109020500000800
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Mickael,

Some things to look at:

Binding XML to Java
< http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>
XML Schema to Ecore Mapping
< http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>
Essential EMF, DZone Refcard
<http://refcardz.dzone.com/refcardz/essential-emf>

A trivial schema without a targetNamespace attribute on the xsd:schema
will generate results that show you what you need.


Mickael Istria wrote:
> Thanks Ed,
>
> More questions below:
>
>>> I am trying to import an XML file in EMF with a factory generated
>>> with xsd2ecore:
>>>
>>> Resource resource = new
>>> jpdl32ResourceFactoryImpl().createResource(sourceJBPMUri);
>>> options.put(Collections.EMPTY_MAP);
>>> resource.load(options);
>>>
>>> However, most of targeted file have their xmlns blank (we can read
>>> the xmlns="" in the top-level element). Then the factory tells me
>>> the following:
>>> java.lang.RuntimeException:
>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package
>>> with uri 'null' not found.
>>> If I set the xmlns to the right value manually, everything goes
>>> well, but I'd like to know how to ignore this xmlns (since I know
>>> the target factory and so on), or how to specify it while loading
>>> the resource, rather than altering the resource.
>>> I've tried to load the resource with option
>>> jpdl32ResourceImpl.NO_NAMESPACE_SCHEMA_LOCATION="true", but this did
>>> not do the trick. I also tried to play with the
>>> XMLResource.OPTION_SCHEMA_LOCATION without success.
>>>
>>> Does anybody have an idea of how to bypass this dummy xmlns value?
>> It's really not a dummy value. In the end, for the instance to
>> conform to your schema, it must have the right namespace. If you
>> start with a schema with a null target namespace, you'll see the
>> EPackage has a special annotation on it to indicate the namespace is
>> null and the generated XyzResourceFactoryImpl will have the right
>> structure to load instances without a namespace. So try generating a
>> model for a null target namespace schema to see what's generated.
>
> Sorry but I don't understand what I have to modify concretely on my
> ecore or my genmodel to make my package able to support null
> namespace. Indeed, Epackage does not support empty string as nsUri in
> ecore editor and I did not find the property to allow null package. Do
> I have to add an EAnnotation as a child of the EPackage? If yes, what
> is the ref and source to set?
> Sorry for these basic questions, but I am not easy with annotations.
>
> --
> Mickael Istria - BonitaSoft S.A.
> http://www.bonitasoft.com/products/downloads.php

--------------020101030109020500000800
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Mickael,<br>
<br>
Some things to look at:<br>
<blockquote><a target="_out"
href=" http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava">Binding
XML to Java</a><br>
<a
href=" http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf">XML
Schema to Ecore Mapping</a><br>
<a href="http://refcardz.dzone.com/refcardz/essential-emf">Essential
EMF, DZone Refcard</a><br>
</blockquote>
A trivial schema without a targetNamespace attribute on the xsd:schema
will generate results that show you what you need.<br>
<br>
<br>
Mickael Istria wrote:
<blockquote cite="mid:hqn831$qsf$1@build.eclipse.org" type="cite">Thanks
Ed,
<br>
<br>
More questions below:
<br>
<br>
<blockquote type="cite">
<blockquote type="cite">I am trying to import an XML file in EMF
with a factory generated with xsd2ecore:
<br>
<br>
&nbsp;&nbsp;&nbsp; Resource resource = new
jpdl32ResourceFactoryImpl().createResource(sourceJBPMUri);
<br>
&nbsp;&nbsp;&nbsp; options.put(Collections.EMPTY_MAP);
<br>
&nbsp;&nbsp;&nbsp; resource.load(options);
<br>
<br>
However, most of targeted file have their xmlns blank (we can read the
xmlns="" in the top-level element). Then the factory tells me the
following:
<br>
&nbsp;&nbsp;&nbsp; java.lang.RuntimeException:
org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package
with uri 'null' not found.
<br>
If I set the xmlns to the right value manually, everything goes well,
but I'd like to know how to ignore this xmlns (since I know the target
factory and so on), or how to specify it while loading the resource,
rather than altering the resource.
<br>
I've tried to load the resource with option
jpdl32ResourceImpl.NO_NAMESPACE_SCHEMA_LOCATION="true", but this did
not do the trick. I also tried to play with the
XMLResource.OPTION_SCHEMA_LOCATION without success.
<br>
<br>
Does anybody have an idea of how to bypass this dummy xmlns value?
<br>
</blockquote>
It's really not a dummy value.&nbsp; In the end, for the instance to conform
to your schema, it must have the right namespace.&nbsp; If you start with a
schema with a null target namespace, you'll see the EPackage has a
special annotation on it to indicate the namespace is null and the
generated XyzResourceFactoryImpl will have the right structure to load
instances without a namespace.&nbsp; So try generating a model for a null
target namespace schema to see what's generated.
<br>
</blockquote>
<br>
Sorry but I don't understand what I have to modify concretely on my
ecore or my genmodel to make my package able to support null namespace.
Indeed, Epackage does not support empty string as nsUri in ecore editor
and I did not find the property to allow null package. Do I have to add
an EAnnotation as a child of the EPackage? If yes, what is the ref and
source to set?
<br>
Sorry for these basic questions, but I am not easy with annotations.
<br>
<br>
--
<br>
Mickael Istria - BonitaSoft S.A.
<br>
<a class="moz-txt-link-freetext" href="http://www.bonitasoft.com/products/downloads.php">http://www.bonitasoft.com/products/downloads.php</a>
<br>
</blockquote>
</body>
</html>

--------------020101030109020500000800--
Re: XMLResource with xmlns="" [message #619545 is a reply to message #528756] Thu, 22 April 2010 09:12 Go to previous message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 770
Registered: July 2009
Location: Grenoble, France
Senior Member
Ed Merks a écrit :
> Mickael,
>
> Some things to look at:
>
> Binding XML to Java
> < http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>
> XML Schema to Ecore Mapping
> < http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>
> Essential EMF, DZone Refcard
> <http://refcardz.dzone.com/refcardz/essential-emf>
>
> A trivial schema without a targetNamespace attribute on the xsd:schema
> will generate results that show you what you need.

Thanks a lot Ed, I tried with a dummy xsd without target namespace, and copied the annotation it generated and everything works well without xmlns.
However it seems to me that there can only be one namespace by Package. However I'd like my package to be mapped to 2 namespaces: blank/null and the real one from xsd, since we can find some xml files with xmlns set or not. Is this possible? Do you have another magic annotation to suggest ;) ?

--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
Re: XMLResource with xmlns="" [message #619547 is a reply to message #528876] Thu, 22 April 2010 10:41 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26237
Registered: July 2009
Senior Member
Mickael,

Comments below.

Mickael Istria wrote:
> Ed Merks a écrit :
>> Mickael,
>>
>> Some things to look at:
>>
>> Binding XML to Java
>>
>> < http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>
>> XML Schema to Ecore Mapping
>>
>> < http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf>
>>
>> Essential EMF, DZone Refcard
>> <http://refcardz.dzone.com/refcardz/essential-emf>
>>
>> A trivial schema without a targetNamespace attribute on the
>> xsd:schema will generate results that show you what you need.
>
> Thanks a lot Ed, I tried with a dummy xsd without target namespace,
> and copied the annotation it generated and everything works well
> without xmlns.
Woo hoo. :-)
> However it seems to me that there can only be one namespace by Package.
Globally yes, and within any given context, yes.
> However I'd like my package to be mapped to 2 namespaces: blank/null
> and the real one from xsd, since we can find some xml files with xmlns
> set or not. Is this possible?
Yes.
> Do you have another magic annotation to suggest ;) ?
You'd need different resource factories for each case. You'd have to
specialize the BasicExtendedMetaData implementation used to make the the
package appear to have a null namespace. E.g., specialize methods like
getPackage to return the package either for null or the proper namespace
and methods like getNamespace for producing the desired serialization
with or without a namespace. You could use content types to register
the factories in each case for the same extension. If you set a content
type identifier in the GenPackage, delete the plugin.xml, and
regenerate, you'll see how the registration for those work.
>
> --
> Mickael Istria - BonitaSoft S.A.
> http://www.bonitasoft.com/products/downloads.php
Previous Topic:XMLResource with xmlns=""
Next Topic:getResource issue
Goto Forum:
  


Current Time: Fri Nov 28 16:13:29 GMT 2014

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

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