Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Stand-alone main application
EMF Stand-alone main application [message #423565] Thu, 02 October 2008 12:20 Go to next message
exquisitus is currently offline exquisitusFriend
Messages: 211
Registered: July 2009
Senior Member
Hi

i tried to load my XML-File which based on EMF Model in a stand-alone
apllication. The apllication is a simple Java main programm.
With EMF 2.3 all works fine now with EMF 2.4.1 it doesnt work.
What did i wrong? Big thanks for you help

Code:

URI fileURI = null;

if(file != null) {
fileURI = URI.createFileURI(new File(file).getAbsolutePath()); }else {
return null;
}

Resource poResource = null;

ResourceSet resourceSet = new ResourceSetImpl();

resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
put(Resource.Factory.Registry.DEFAULT_EXTENSION,
new XYZBuildResourceFactoryImpl());
resourceSet.getPackageRegistry().put(XYZBuildPackage.eNS_URI ,
TSMBuildPackage.eINSTANCE);

try {
poResource = resourceSet.getResource(fileURI, true);

docRoot = (DocumentRoot) poResource.getContents().get(0);

} catch (Exception ex) {
System.out.println(ex.toString());
}

I become this Exeception:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
org.xml.sax.SAXNotRecognizedException: Feature:
http://xml.org/sax/properties/lexical-handler
Re: EMF Stand-alone main application [message #423573 is a reply to message #423565] Thu, 02 October 2008 12:50 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Comments below.

exquisitus wrote:
> Hi
>
> i tried to load my XML-File which based on EMF Model in a stand-alone
> apllication. The apllication is a simple Java main programm.
Is it just like the one that's generated if you invoke "Generate Test
Code" and look at the generated XyzExample.java?
> With EMF 2.3 all works fine now with EMF 2.4.1 it doesnt work.
> What did i wrong? Big thanks for you help
>
> Code:
>
> URI fileURI = null;
>
> if(file != null) {
> fileURI = URI.createFileURI(new File(file).getAbsolutePath());
> }else {
> return null;
> }
>
> Resource poResource = null;
>
> ResourceSet resourceSet = new ResourceSetImpl();
>
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
> new XYZBuildResourceFactoryImpl());
> resourceSet.getPackageRegistry().put(XYZBuildPackage.eNS_URI ,
> TSMBuildPackage.eINSTANCE);
>
> try {
> poResource = resourceSet.getResource(fileURI, true);
>
> docRoot = (DocumentRoot) poResource.getContents().get(0);
>
> } catch (Exception ex) {
> System.out.println(ex.toString());
> }
>
> I become this Exeception:
>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
> org.xml.sax.SAXNotRecognizedException: Feature:
> http://xml.org/sax/properties/lexical-handler
This sounds like an issue related to the JRE you are using not directly
an EMF issue.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF Stand-alone main application [message #423789 is a reply to message #423573] Tue, 07 October 2008 10:55 Go to previous messageGo to next message
exquisitus is currently offline exquisitusFriend
Messages: 211
Registered: July 2009
Senior Member
Thanks for the quick answer. But I use the code from the generated
Example but it still doesnt work. I get a acception from SAX.
I my GUI all works fine. I use a xml-File with a dtd file which contains
Entities. Maybe this is the problem. How can i set some load options?

Thanks

Load:

URI fileURI fileURI = URI.createFileURI(new File(file).getAbsolutePath());

ResourceSet resourceSet = new ResourceSetImpl();

resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
put(Resource.Factory.Registry.DEFAULT_EXTENSION,
new TSMBuildResourceFactoryImpl());

resourceSet.getPackageRegistry().put(TSMBuildPackage.eNS_URI ,
TSMBuildPackage.eINSTANCE);
try {

Resource resource = resourceSet.getResource(fileURI, true);

} catch (RuntimeException exception) {
....
}

Ed Merks schrieb:
> Comments below.
>
> exquisitus wrote:
>> Hi
>>
>> i tried to load my XML-File which based on EMF Model in a stand-alone
>> apllication. The apllication is a simple Java main programm.
> Is it just like the one that's generated if you invoke "Generate Test
> Code" and look at the generated XyzExample.java?
>> With EMF 2.3 all works fine now with EMF 2.4.1 it doesnt work.
>> What did i wrong? Big thanks for you help
>>
>> Code:
>>
>> URI fileURI = null;
>> if(file != null) {
>> fileURI = URI.createFileURI(new File(file).getAbsolutePath());
>> }else {
>> return null;
>> }
>> Resource poResource = null;
>>
>> ResourceSet resourceSet = new ResourceSetImpl();
>>
>>
>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>> new XYZBuildResourceFactoryImpl());
>> resourceSet.getPackageRegistry().put(XYZBuildPackage.eNS_URI ,
>> TSMBuildPackage.eINSTANCE);
>>
>> try {
>> poResource = resourceSet.getResource(fileURI, true);
>>
>> docRoot = (DocumentRoot) poResource.getContents().get(0);
>>
>> } catch (Exception ex) {
>> System.out.println(ex.toString());
>> }
>>
>> I become this Exeception:
>>
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
>> org.xml.sax.SAXNotRecognizedException: Feature:
>> http://xml.org/sax/properties/lexical-handler
> This sounds like an issue related to the JRE you are using not directly
> an EMF issue.
Re: EMF Stand-alone main application [message #423803 is a reply to message #423789] Tue, 07 October 2008 11:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070605000009060604030405
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

As I said, the exception looks to me like an issue related to the JAXP
implementation you have installed as part of the JR. If you follow the
stack trace for this exception

org.xml.sax.SAXNotRecognizedException: Feature:
http://xml.org/sax/properties/lexical-handler

you'll see that EMF is trying to set up a lexical handler on the SAX
parser. That should just work, and clearly works most of the time (all
the time in my experience) except in this stand-alone environment your
running. What JRE are you using?


exquisitus wrote:
> Thanks for the quick answer. But I use the code from the generated
> Example but it still doesnt work. I get a acception from SAX.
> I my GUI all works fine. I use a xml-File with a dtd file which
> contains Entities. Maybe this is the problem. How can i set some load
> options?
>
> Thanks
>
> Load:
>
> URI fileURI fileURI = URI.createFileURI(new
> File(file).getAbsolutePath());
>
> ResourceSet resourceSet = new ResourceSetImpl();
>
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
> new TSMBuildResourceFactoryImpl());
>
> resourceSet.getPackageRegistry().put(TSMBuildPackage.eNS_URI ,
> TSMBuildPackage.eINSTANCE);
> try {
>
> Resource resource = resourceSet.getResource(fileURI, true);
>
> } catch (RuntimeException exception) {
> ...
> }
>
> Ed Merks schrieb:
>> Comments below.
>>
>> exquisitus wrote:
>>> Hi
>>>
>>> i tried to load my XML-File which based on EMF Model in a
>>> stand-alone apllication. The apllication is a simple Java main
>>> programm.
>> Is it just like the one that's generated if you invoke "Generate Test
>> Code" and look at the generated XyzExample.java?
>>> With EMF 2.3 all works fine now with EMF 2.4.1 it doesnt work.
>>> What did i wrong? Big thanks for you help
>>>
>>> Code:
>>>
>>> URI fileURI = null;
>>> if(file != null) {
>>> fileURI = URI.createFileURI(new File(file).getAbsolutePath());
>>> }else {
>>> return null;
>>> }
>>> Resource poResource = null;
>>>
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>
>>>
>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>> new XYZBuildResourceFactoryImpl());
>>> resourceSet.getPackageRegistry().put(XYZBuildPackage.eNS_URI ,
>>> TSMBuildPackage.eINSTANCE);
>>>
>>> try {
>>> poResource = resourceSet.getResource(fileURI, true);
>>>
>>> docRoot = (DocumentRoot) poResource.getContents().get(0);
>>>
>>> } catch (Exception ex) {
>>> System.out.println(ex.toString());
>>> }
>>>
>>> I become this Exeception:
>>>
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>> http://xml.org/sax/properties/lexical-handler
>> This sounds like an issue related to the JRE you are using not
>> directly an EMF issue.

--------------070605000009060604030405
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
As I said, the exception looks to me like an issue related to the JAXP
implementation you have installed as part of the JR.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF Stand-alone main application [message #423805 is a reply to message #423803] Tue, 07 October 2008 11:30 Go to previous messageGo to next message
exquisitus is currently offline exquisitusFriend
Messages: 211
Registered: July 2009
Senior Member
My Enviorment is

Eclipse 3.4 with EMF 2.4.1
Java Version is latest 1.5 Version (1.5.0_15-b04)


Ed Merks schrieb:
> As I said, the exception looks to me like an issue related to the JAXP
> implementation you have installed as part of the JR. If you follow the
> stack trace for this exception
>
> org.xml.sax.SAXNotRecognizedException: Feature:
> http://xml.org/sax/properties/lexical-handler
>
> you'll see that EMF is trying to set up a lexical handler on the SAX
> parser. That should just work, and clearly works most of the time (all
> the time in my experience) except in this stand-alone environment your
> running. What JRE are you using?
>
>
> exquisitus wrote:
>> Thanks for the quick answer. But I use the code from the generated
>> Example but it still doesnt work. I get a acception from SAX.
>> I my GUI all works fine. I use a xml-File with a dtd file which
>> contains Entities. Maybe this is the problem. How can i set some load
>> options?
>>
>> Thanks
>>
>> Load:
>>
>> URI fileURI fileURI = URI.createFileURI(new
>> File(file).getAbsolutePath());
>>
>> ResourceSet resourceSet = new ResourceSetImpl();
>>
>>
>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>> new TSMBuildResourceFactoryImpl());
>>
>> resourceSet.getPackageRegistry().put(TSMBuildPackage.eNS_URI ,
>> TSMBuildPackage.eINSTANCE);
>> try {
>>
>> Resource resource = resourceSet.getResource(fileURI, true);
>>
>> } catch (RuntimeException exception) {
>> ...
>> }
>>
>> Ed Merks schrieb:
>>> Comments below.
>>>
>>> exquisitus wrote:
>>>> Hi
>>>>
>>>> i tried to load my XML-File which based on EMF Model in a
>>>> stand-alone apllication. The apllication is a simple Java main
>>>> programm.
>>> Is it just like the one that's generated if you invoke "Generate Test
>>> Code" and look at the generated XyzExample.java?
>>>> With EMF 2.3 all works fine now with EMF 2.4.1 it doesnt work.
>>>> What did i wrong? Big thanks for you help
>>>>
>>>> Code:
>>>>
>>>> URI fileURI = null;
>>>> if(file != null) {
>>>> fileURI = URI.createFileURI(new File(file).getAbsolutePath());
>>>> }else {
>>>> return null;
>>>> }
>>>> Resource poResource = null;
>>>>
>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>
>>>>
>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>> new XYZBuildResourceFactoryImpl());
>>>> resourceSet.getPackageRegistry().put(XYZBuildPackage.eNS_URI ,
>>>> TSMBuildPackage.eINSTANCE);
>>>>
>>>> try {
>>>> poResource = resourceSet.getResource(fileURI, true);
>>>>
>>>> docRoot = (DocumentRoot) poResource.getContents().get(0);
>>>>
>>>> } catch (Exception ex) {
>>>> System.out.println(ex.toString());
>>>> }
>>>>
>>>> I become this Exeception:
>>>>
>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
>>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>>> http://xml.org/sax/properties/lexical-handler
>>> This sounds like an issue related to the JRE you are using not
>>> directly an EMF issue.
Re: EMF Stand-alone main application [message #423807 is a reply to message #423805] Tue, 07 October 2008 11:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020301020201050608050200
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

It sounds like it should be fine, but clearly it isn't. Given you have
both a context where it works and one where it doesn't, and you have a
stack trace for the point of failure, you're the one in the best
position to figure out why it would work in one case but not the other.
I seems to me this exception implies your JAXP implementation doesn't
support lexical handlers so you might look at the implement class being
used to implement the SAXParser interface in each case. You might try
this option to avoid needing lexical handler support:

/**
* Determines whether comments and CDATA will be preserved in any
mixed text processing.
* This option is applicable for loading XML resources (from DOM
node or an InputStream)
*/
String OPTION_USE_LEXICAL_HANDLER = "USE_LEXICAL_HANDLER";


exquisitus wrote:
> My Enviorment is
>
> Eclipse 3.4 with EMF 2.4.1
> Java Version is latest 1.5 Version (1.5.0_15-b04)
>
>
> Ed Merks schrieb:
>> As I said, the exception looks to me like an issue related to the
>> JAXP implementation you have installed as part of the JR. If you
>> follow the stack trace for this exception
>>
>> org.xml.sax.SAXNotRecognizedException: Feature:
>> http://xml.org/sax/properties/lexical-handler
>>
>> you'll see that EMF is trying to set up a lexical handler on the SAX
>> parser. That should just work, and clearly works most of the time
>> (all the time in my experience) except in this stand-alone
>> environment your running. What JRE are you using?
>>
>> exquisitus wrote:
>>> Thanks for the quick answer. But I use the code from the generated
>>> Example but it still doesnt work. I get a acception from SAX.
>>> I my GUI all works fine. I use a xml-File with a dtd file which
>>> contains Entities. Maybe this is the problem. How can i set some
>>> load options?
>>>
>>> Thanks
>>>
>>> Load:
>>>
>>> URI fileURI fileURI = URI.createFileURI(new
>>> File(file).getAbsolutePath());
>>>
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>
>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>> new TSMBuildResourceFactoryImpl());
>>>
>>> resourceSet.getPackageRegistry().put(TSMBuildPackage.eNS_URI ,
>>> TSMBuildPackage.eINSTANCE);
>>> try {
>>>
>>> Resource resource = resourceSet.getResource(fileURI, true);
>>> } catch (RuntimeException exception) {
>>> ...
>>> }
>>>
>>> Ed Merks schrieb:
>>>> Comments below.
>>>>
>>>> exquisitus wrote:
>>>>> Hi
>>>>>
>>>>> i tried to load my XML-File which based on EMF Model in a
>>>>> stand-alone apllication. The apllication is a simple Java main
>>>>> programm.
>>>> Is it just like the one that's generated if you invoke "Generate
>>>> Test Code" and look at the generated XyzExample.java?
>>>>> With EMF 2.3 all works fine now with EMF 2.4.1 it doesnt work.
>>>>> What did i wrong? Big thanks for you help
>>>>>
>>>>> Code:
>>>>>
>>>>> URI fileURI = null;
>>>>> if(file != null) {
>>>>> fileURI = URI.createFileURI(new
>>>>> File(file).getAbsolutePath()); }else {
>>>>> return null;
>>>>> }
>>>>> Resource poResource = null;
>>>>>
>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>
>>>>>
>>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>>> new XYZBuildResourceFactoryImpl());
>>>>> resourceSet.getPackageRegistry().put(XYZBuildPackage.eNS_URI ,
>>>>> TSMBuildPackage.eINSTANCE);
>>>>>
>>>>> try {
>>>>> poResource = resourceSet.getResource(fileURI, true);
>>>>>
>>>>> docRoot = (DocumentRoot) poResource.getContents().get(0);
>>>>>
>>>>> } catch (Exception ex) {
>>>>> System.out.println(ex.toString());
>>>>> }
>>>>>
>>>>> I become this Exeception:
>>>>>
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
>>>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>>>> http://xml.org/sax/properties/lexical-handler
>>>> This sounds like an issue related to the JRE you are using not
>>>> directly an EMF issue.

--------------020301020201050608050200
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
It sounds like it should be fine, but clearly it isn't.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF Stand-alone main application [message #423811 is a reply to message #423807] Tue, 07 October 2008 12:13 Go to previous messageGo to next message
exquisitus is currently offline exquisitusFriend
Messages: 211
Registered: July 2009
Senior Member
First big big thanks. I tried to use my load options for the
editingDomain but i dont know to get it run?

try {

Resource resource = null;

Map options = new HashMap();

options.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
options.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
options.put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);

try {

resource.load(options);
resource.resourceSet.getResource(fileURI, true);

} catch (IOException e) {
...
}
}
....

This wont work because resource is null. So how can i set the load
options? Must i use a XMLMap?

Ed Merks schrieb:
> It sounds like it should be fine, but clearly it isn't. Given you have
> both a context where it works and one where it doesn't, and you have a
> stack trace for the point of failure, you're the one in the best
> position to figure out why it would work in one case but not the other.
> I seems to me this exception implies your JAXP implementation doesn't
> support lexical handlers so you might look at the implement class being
> used to implement the SAXParser interface in each case. You might try
> this option to avoid needing lexical handler support:
>
> /**
> * Determines whether comments and CDATA will be preserved in any
> mixed text processing.
> * This option is applicable for loading XML resources (from DOM
> node or an InputStream)
> */
> String OPTION_USE_LEXICAL_HANDLER = "USE_LEXICAL_HANDLER";
>
>
> exquisitus wrote:
>> My Enviorment is
>>
>> Eclipse 3.4 with EMF 2.4.1
>> Java Version is latest 1.5 Version (1.5.0_15-b04)
>>
>>
>> Ed Merks schrieb:
>>> As I said, the exception looks to me like an issue related to the
>>> JAXP implementation you have installed as part of the JR. If you
>>> follow the stack trace for this exception
>>>
>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>> http://xml.org/sax/properties/lexical-handler
>>>
>>> you'll see that EMF is trying to set up a lexical handler on the SAX
>>> parser. That should just work, and clearly works most of the time
>>> (all the time in my experience) except in this stand-alone
>>> environment your running. What JRE are you using?
>>>
>>> exquisitus wrote:
>>>> Thanks for the quick answer. But I use the code from the generated
>>>> Example but it still doesnt work. I get a acception from SAX.
>>>> I my GUI all works fine. I use a xml-File with a dtd file which
>>>> contains Entities. Maybe this is the problem. How can i set some
>>>> load options?
>>>>
>>>> Thanks
>>>>
>>>> Load:
>>>>
>>>> URI fileURI fileURI = URI.createFileURI(new
>>>> File(file).getAbsolutePath());
>>>>
>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>
>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>> new TSMBuildResourceFactoryImpl());
>>>>
>>>> resourceSet.getPackageRegistry().put(TSMBuildPackage.eNS_URI ,
>>>> TSMBuildPackage.eINSTANCE);
>>>> try {
>>>>
>>>> Resource resource = resourceSet.getResource(fileURI, true);
>>>> } catch (RuntimeException exception) {
>>>> ...
>>>> }
>>>>
>>>> Ed Merks schrieb:
>>>>> Comments below.
>>>>>
>>>>> exquisitus wrote:
>>>>>> Hi
>>>>>>
>>>>>> i tried to load my XML-File which based on EMF Model in a
>>>>>> stand-alone apllication. The apllication is a simple Java main
>>>>>> programm.
>>>>> Is it just like the one that's generated if you invoke "Generate
>>>>> Test Code" and look at the generated XyzExample.java?
>>>>>> With EMF 2.3 all works fine now with EMF 2.4.1 it doesnt work.
>>>>>> What did i wrong? Big thanks for you help
>>>>>>
>>>>>> Code:
>>>>>>
>>>>>> URI fileURI = null;
>>>>>> if(file != null) {
>>>>>> fileURI = URI.createFileURI(new
>>>>>> File(file).getAbsolutePath()); }else {
>>>>>> return null;
>>>>>> }
>>>>>> Resource poResource = null;
>>>>>>
>>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>
>>>>>>
>>>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>>>> new XYZBuildResourceFactoryImpl());
>>>>>> resourceSet.getPackageRegistry().put(XYZBuildPackage.eNS_URI ,
>>>>>> TSMBuildPackage.eINSTANCE);
>>>>>>
>>>>>> try {
>>>>>> poResource = resourceSet.getResource(fileURI, true);
>>>>>>
>>>>>> docRoot = (DocumentRoot) poResource.getContents().get(0);
>>>>>>
>>>>>> } catch (Exception ex) {
>>>>>> System.out.println(ex.toString());
>>>>>> }
>>>>>>
>>>>>> I become this Exeception:
>>>>>>
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
>>>>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>>>>> http://xml.org/sax/properties/lexical-handler
>>>>> This sounds like an issue related to the JRE you are using not
>>>>> directly an EMF issue.
Re: EMF Stand-alone main application [message #423812 is a reply to message #423811] Tue, 07 October 2008 12:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Mike,

Typically you set options in the resource factory that's used to create
the resource, but a resource set also getLoadOptions that will be
applied to all resources demand loaded in that resource set. Don't
specify more options than you actually need. You wanted to try
Boolean.FALSE for the lexical handler right?


exquisitus wrote:
> First big big thanks. I tried to use my load options for the
> editingDomain but i dont know to get it run?
>
> try {
>
> Resource resource = null;
>
> Map options = new HashMap();
>
> options.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
> options.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
> Boolean.TRUE);
> options.put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
>
> try {
>
> resource.load(options);
> resource.resourceSet.getResource(fileURI, true);
>
> } catch (IOException e) {
> ...
> }
> }
> ...
>
> This wont work because resource is null. So how can i set the load
> options? Must i use a XMLMap?
>
> Ed Merks schrieb:
>> It sounds like it should be fine, but clearly it isn't. Given you
>> have both a context where it works and one where it doesn't, and you
>> have a stack trace for the point of failure, you're the one in the
>> best position to figure out why it would work in one case but not the
>> other. I seems to me this exception implies your JAXP implementation
>> doesn't support lexical handlers so you might look at the implement
>> class being used to implement the SAXParser interface in each case.
>> You might try this option to avoid needing lexical handler support:
>>
>> /**
>> * Determines whether comments and CDATA will be preserved in any
>> mixed text processing.
>> * This option is applicable for loading XML resources (from DOM
>> node or an InputStream)
>> */
>> String OPTION_USE_LEXICAL_HANDLER = "USE_LEXICAL_HANDLER";
>>
>>
>> exquisitus wrote:
>>> My Enviorment is
>>>
>>> Eclipse 3.4 with EMF 2.4.1
>>> Java Version is latest 1.5 Version (1.5.0_15-b04)
>>>
>>>
>>> Ed Merks schrieb:
>>>> As I said, the exception looks to me like an issue related to the
>>>> JAXP implementation you have installed as part of the JR. If you
>>>> follow the stack trace for this exception
>>>>
>>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>>> http://xml.org/sax/properties/lexical-handler
>>>>
>>>> you'll see that EMF is trying to set up a lexical handler on the
>>>> SAX parser. That should just work, and clearly works most of the
>>>> time (all the time in my experience) except in this stand-alone
>>>> environment your running. What JRE are you using?
>>>>
>>>> exquisitus wrote:
>>>>> Thanks for the quick answer. But I use the code from the generated
>>>>> Example but it still doesnt work. I get a acception from SAX.
>>>>> I my GUI all works fine. I use a xml-File with a dtd file which
>>>>> contains Entities. Maybe this is the problem. How can i set some
>>>>> load options?
>>>>>
>>>>> Thanks
>>>>>
>>>>> Load:
>>>>>
>>>>> URI fileURI fileURI = URI.createFileURI(new
>>>>> File(file).getAbsolutePath());
>>>>>
>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>
>>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>>> new TSMBuildResourceFactoryImpl());
>>>>>
>>>>> resourceSet.getPackageRegistry().put(TSMBuildPackage.eNS_URI ,
>>>>> TSMBuildPackage.eINSTANCE);
>>>>> try {
>>>>>
>>>>> Resource resource = resourceSet.getResource(fileURI, true);
>>>>> } catch (RuntimeException exception) {
>>>>> ...
>>>>> }
>>>>>
>>>>> Ed Merks schrieb:
>>>>>> Comments below.
>>>>>>
>>>>>> exquisitus wrote:
>>>>>>> Hi
>>>>>>>
>>>>>>> i tried to load my XML-File which based on EMF Model in a
>>>>>>> stand-alone apllication. The apllication is a simple Java main
>>>>>>> programm.
>>>>>> Is it just like the one that's generated if you invoke "Generate
>>>>>> Test Code" and look at the generated XyzExample.java?
>>>>>>> With EMF 2.3 all works fine now with EMF 2.4.1 it doesnt work.
>>>>>>> What did i wrong? Big thanks for you help
>>>>>>>
>>>>>>> Code:
>>>>>>>
>>>>>>> URI fileURI = null;
>>>>>>> if(file != null) {
>>>>>>> fileURI = URI.createFileURI(new
>>>>>>> File(file).getAbsolutePath()); }else {
>>>>>>> return null;
>>>>>>> }
>>>>>>> Resource poResource = null;
>>>>>>>
>>>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>>
>>>>>>>
>>>>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>>>>>
>>>>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>>>>> new XYZBuildResourceFactoryImpl());
>>>>>>>
>>>>>>> resourceSet.getPackageRegistry().put(XYZBuildPackage.eNS_URI ,
>>>>>>> TSMBuildPackage.eINSTANCE);
>>>>>>>
>>>>>>> try {
>>>>>>> poResource = resourceSet.getResource(fileURI, true);
>>>>>>>
>>>>>>> docRoot = (DocumentRoot) poResource.getContents().get(0);
>>>>>>>
>>>>>>> } catch (Exception ex) {
>>>>>>> System.out.println(ex.toString());
>>>>>>> }
>>>>>>>
>>>>>>> I become this Exeception:
>>>>>>>
>>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
>>>>>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>>>>>> http://xml.org/sax/properties/lexical-handler
>>>>>> This sounds like an issue related to the JRE you are using not
>>>>>> directly an EMF issue.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF Stand-alone main application [message #423814 is a reply to message #423812] Tue, 07 October 2008 12:44 Go to previous messageGo to next message
exquisitus is currently offline exquisitusFriend
Messages: 211
Registered: July 2009
Senior Member
I change OPTION_USE_LEXICAL_HANDLER in the
XYZBuildResourceFactoryImpl() to False. Works fine now. Thanks.

But cant i set the load optins in my Standalone Application? A
code Example would be useful?

Again big thanks

Ed Merks schrieb:
> Mike,
>
> Typically you set options in the resource factory that's used to create
> the resource, but a resource set also getLoadOptions that will be
> applied to all resources demand loaded in that resource set. Don't
> specify more options than you actually need. You wanted to try
> Boolean.FALSE for the lexical handler right?
>
>
> exquisitus wrote:
>> First big big thanks. I tried to use my load options for the
>> editingDomain but i dont know to get it run?
>>
>> try {
>> Resource resource = null;
>> Map options = new HashMap();
>> options.put(XMLResource.OPTION_EXTENDED_META_DATA,
>> Boolean.TRUE);
>> options.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
>> Boolean.TRUE);
>> options.put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
>> try {
>> resource.load(options);
>> resource.resourceSet.getResource(fileURI, true);
>>
>> } catch (IOException e) {
>> ...
>> }
>> }
>> ...
>>
>> This wont work because resource is null. So how can i set the load
>> options? Must i use a XMLMap?
>>
>> Ed Merks schrieb:
>>> It sounds like it should be fine, but clearly it isn't. Given you
>>> have both a context where it works and one where it doesn't, and you
>>> have a stack trace for the point of failure, you're the one in the
>>> best position to figure out why it would work in one case but not the
>>> other. I seems to me this exception implies your JAXP implementation
>>> doesn't support lexical handlers so you might look at the implement
>>> class being used to implement the SAXParser interface in each case.
>>> You might try this option to avoid needing lexical handler support:
>>>
>>> /**
>>> * Determines whether comments and CDATA will be preserved in any
>>> mixed text processing.
>>> * This option is applicable for loading XML resources (from DOM
>>> node or an InputStream)
>>> */
>>> String OPTION_USE_LEXICAL_HANDLER = "USE_LEXICAL_HANDLER";
>>>
>>>
>>> exquisitus wrote:
>>>> My Enviorment is
>>>>
>>>> Eclipse 3.4 with EMF 2.4.1
>>>> Java Version is latest 1.5 Version (1.5.0_15-b04)
>>>>
>>>>
>>>> Ed Merks schrieb:
>>>>> As I said, the exception looks to me like an issue related to the
>>>>> JAXP implementation you have installed as part of the JR. If you
>>>>> follow the stack trace for this exception
>>>>>
>>>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>>>> http://xml.org/sax/properties/lexical-handler
>>>>>
>>>>> you'll see that EMF is trying to set up a lexical handler on the
>>>>> SAX parser. That should just work, and clearly works most of the
>>>>> time (all the time in my experience) except in this stand-alone
>>>>> environment your running. What JRE are you using?
>>>>>
>>>>> exquisitus wrote:
>>>>>> Thanks for the quick answer. But I use the code from the generated
>>>>>> Example but it still doesnt work. I get a acception from SAX.
>>>>>> I my GUI all works fine. I use a xml-File with a dtd file which
>>>>>> contains Entities. Maybe this is the problem. How can i set some
>>>>>> load options?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> Load:
>>>>>>
>>>>>> URI fileURI fileURI = URI.createFileURI(new
>>>>>> File(file).getAbsolutePath());
>>>>>>
>>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>
>>>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>>>> new TSMBuildResourceFactoryImpl());
>>>>>>
>>>>>> resourceSet.getPackageRegistry().put(TSMBuildPackage.eNS_URI ,
>>>>>> TSMBuildPackage.eINSTANCE);
>>>>>> try {
>>>>>>
>>>>>> Resource resource = resourceSet.getResource(fileURI, true);
>>>>>> } catch (RuntimeException exception) {
>>>>>> ...
>>>>>> }
>>>>>>
>>>>>> Ed Merks schrieb:
>>>>>>> Comments below.
>>>>>>>
>>>>>>> exquisitus wrote:
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> i tried to load my XML-File which based on EMF Model in a
>>>>>>>> stand-alone apllication. The apllication is a simple Java main
>>>>>>>> programm.
>>>>>>> Is it just like the one that's generated if you invoke "Generate
>>>>>>> Test Code" and look at the generated XyzExample.java?
>>>>>>>> With EMF 2.3 all works fine now with EMF 2.4.1 it doesnt work.
>>>>>>>> What did i wrong? Big thanks for you help
>>>>>>>>
>>>>>>>> Code:
>>>>>>>>
>>>>>>>> URI fileURI = null;
>>>>>>>> if(file != null) {
>>>>>>>> fileURI = URI.createFileURI(new
>>>>>>>> File(file).getAbsolutePath()); }else {
>>>>>>>> return null;
>>>>>>>> }
>>>>>>>> Resource poResource = null;
>>>>>>>>
>>>>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>>>
>>>>>>>>
>>>>>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>>>>>>
>>>>>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>>>>>> new XYZBuildResourceFactoryImpl());
>>>>>>>>
>>>>>>>> resourceSet.getPackageRegistry().put(XYZBuildPackage.eNS_URI ,
>>>>>>>> TSMBuildPackage.eINSTANCE);
>>>>>>>>
>>>>>>>> try {
>>>>>>>> poResource = resourceSet.getResource(fileURI, true);
>>>>>>>>
>>>>>>>> docRoot = (DocumentRoot) poResource.getContents().get(0);
>>>>>>>>
>>>>>>>> } catch (Exception ex) {
>>>>>>>> System.out.println(ex.toString());
>>>>>>>> }
>>>>>>>>
>>>>>>>> I become this Exeception:
>>>>>>>>
>>>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
>>>>>>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>>>>>>> http://xml.org/sax/properties/lexical-handler
>>>>>>> This sounds like an issue related to the JRE you are using not
>>>>>>> directly an EMF issue.
Re: EMF Stand-alone main application [message #423815 is a reply to message #423814] Tue, 07 October 2008 12:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Mike,

Using
resourceSet.getLoadOptions().put(XMLResource.OPTION_USE_LEXI CAL_HANDLER,
Boolean.FALSE) should do the trick.



exquisitus wrote:
> I change OPTION_USE_LEXICAL_HANDLER in the
> XYZBuildResourceFactoryImpl() to False. Works fine now. Thanks.
>
> But cant i set the load optins in my Standalone Application? A
> code Example would be useful?
>
> Again big thanks
>
> Ed Merks schrieb:
>> Mike,
>>
>> Typically you set options in the resource factory that's used to
>> create the resource, but a resource set also getLoadOptions that will
>> be applied to all resources demand loaded in that resource set.
>> Don't specify more options than you actually need. You wanted to try
>> Boolean.FALSE for the lexical handler right?
>>
>>
>> exquisitus wrote:
>>> First big big thanks. I tried to use my load options for the
>>> editingDomain but i dont know to get it run?
>>>
>>> try {
>>> Resource resource = null;
>>> Map options = new HashMap();
>>> options.put(XMLResource.OPTION_EXTENDED_META_DATA,
>>> Boolean.TRUE);
>>> options.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
>>> Boolean.TRUE);
>>> options.put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
>>> try {
>>> resource.load(options);
>>> resource.resourceSet.getResource(fileURI, true);
>>>
>>> } catch (IOException e) {
>>> ...
>>> }
>>> }
>>> ...
>>>
>>> This wont work because resource is null. So how can i set the load
>>> options? Must i use a XMLMap?
>>>
>>> Ed Merks schrieb:
>>>> It sounds like it should be fine, but clearly it isn't. Given you
>>>> have both a context where it works and one where it doesn't, and
>>>> you have a stack trace for the point of failure, you're the one in
>>>> the best position to figure out why it would work in one case but
>>>> not the other. I seems to me this exception implies your JAXP
>>>> implementation doesn't support lexical handlers so you might look
>>>> at the implement class being used to implement the SAXParser
>>>> interface in each case. You might try this option to avoid
>>>> needing lexical handler support:
>>>>
>>>> /**
>>>> * Determines whether comments and CDATA will be preserved in
>>>> any
>>>> mixed text processing.
>>>> * This option is applicable for loading XML resources (from DOM
>>>> node or an InputStream)
>>>> */
>>>> String OPTION_USE_LEXICAL_HANDLER = "USE_LEXICAL_HANDLER";
>>>>
>>>>
>>>> exquisitus wrote:
>>>>> My Enviorment is
>>>>>
>>>>> Eclipse 3.4 with EMF 2.4.1
>>>>> Java Version is latest 1.5 Version (1.5.0_15-b04)
>>>>>
>>>>>
>>>>> Ed Merks schrieb:
>>>>>> As I said, the exception looks to me like an issue related to the
>>>>>> JAXP implementation you have installed as part of the JR. If you
>>>>>> follow the stack trace for this exception
>>>>>>
>>>>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>>>>> http://xml.org/sax/properties/lexical-handler
>>>>>>
>>>>>> you'll see that EMF is trying to set up a lexical handler on the
>>>>>> SAX parser. That should just work, and clearly works most of the
>>>>>> time (all the time in my experience) except in this stand-alone
>>>>>> environment your running. What JRE are you using?
>>>>>>
>>>>>> exquisitus wrote:
>>>>>>> Thanks for the quick answer. But I use the code from the
>>>>>>> generated Example but it still doesnt work. I get a acception
>>>>>>> from SAX.
>>>>>>> I my GUI all works fine. I use a xml-File with a dtd file which
>>>>>>> contains Entities. Maybe this is the problem. How can i set some
>>>>>>> load options?
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Load:
>>>>>>>
>>>>>>> URI fileURI fileURI = URI.createFileURI(new
>>>>>>> File(file).getAbsolutePath());
>>>>>>>
>>>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>>
>>>>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>>>>>
>>>>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>>>>> new TSMBuildResourceFactoryImpl());
>>>>>>>
>>>>>>> resourceSet.getPackageRegistry().put(TSMBuildPackage.eNS_URI ,
>>>>>>> TSMBuildPackage.eINSTANCE);
>>>>>>> try {
>>>>>>>
>>>>>>> Resource resource = resourceSet.getResource(fileURI, true);
>>>>>>> } catch (RuntimeException exception) {
>>>>>>> ...
>>>>>>> }
>>>>>>>
>>>>>>> Ed Merks schrieb:
>>>>>>>> Comments below.
>>>>>>>>
>>>>>>>> exquisitus wrote:
>>>>>>>>> Hi
>>>>>>>>>
>>>>>>>>> i tried to load my XML-File which based on EMF Model in a
>>>>>>>>> stand-alone apllication. The apllication is a simple Java main
>>>>>>>>> programm.
>>>>>>>> Is it just like the one that's generated if you invoke
>>>>>>>> "Generate Test Code" and look at the generated XyzExample.java?
>>>>>>>>> With EMF 2.3 all works fine now with EMF 2.4.1 it doesnt work.
>>>>>>>>> What did i wrong? Big thanks for you help
>>>>>>>>>
>>>>>>>>> Code:
>>>>>>>>>
>>>>>>>>> URI fileURI = null;
>>>>>>>>> if(file != null) {
>>>>>>>>> fileURI = URI.createFileURI(new
>>>>>>>>> File(file).getAbsolutePath()); }else {
>>>>>>>>> return null;
>>>>>>>>> }
>>>>>>>>> Resource poResource = null;
>>>>>>>>>
>>>>>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>>>>>>>
>>>>>>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>>>>>>> new XYZBuildResourceFactoryImpl());
>>>>>>>>>
>>>>>>>>> resourceSet.getPackageRegistry().put(XYZBuildPackage.eNS_URI ,
>>>>>>>>> TSMBuildPackage.eINSTANCE);
>>>>>>>>>
>>>>>>>>> try {
>>>>>>>>> poResource = resourceSet.getResource(fileURI, true);
>>>>>>>>>
>>>>>>>>> docRoot = (DocumentRoot) poResource.getContents().get(0);
>>>>>>>>>
>>>>>>>>> } catch (Exception ex) {
>>>>>>>>> System.out.println(ex.toString());
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> I become this Exeception:
>>>>>>>>>
>>>>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
>>>>>>>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>>>>>>>> http://xml.org/sax/properties/lexical-handler
>>>>>>>> This sounds like an issue related to the JRE you are using not
>>>>>>>> directly an EMF issue.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF Stand-alone main application [message #423817 is a reply to message #423815] Tue, 07 October 2008 13:02 Go to previous message
exquisitus is currently offline exquisitusFriend
Messages: 211
Registered: July 2009
Senior Member
Ok you are now my special EMF hero. Thanks. Now all works fine.

Ed Merks schrieb:
> Mike,
>
> Using
> resourceSet.getLoadOptions().put(XMLResource.OPTION_USE_LEXI CAL_HANDLER,
> Boolean.FALSE) should do the trick.
>
>
>
> exquisitus wrote:
>> I change OPTION_USE_LEXICAL_HANDLER in the
>> XYZBuildResourceFactoryImpl() to False. Works fine now. Thanks.
>>
>> But cant i set the load optins in my Standalone Application? A
>> code Example would be useful?
>>
>> Again big thanks
>>
>> Ed Merks schrieb:
>>> Mike,
>>>
>>> Typically you set options in the resource factory that's used to
>>> create the resource, but a resource set also getLoadOptions that will
>>> be applied to all resources demand loaded in that resource set.
>>> Don't specify more options than you actually need. You wanted to try
>>> Boolean.FALSE for the lexical handler right?
>>>
>>>
>>> exquisitus wrote:
>>>> First big big thanks. I tried to use my load options for the
>>>> editingDomain but i dont know to get it run?
>>>>
>>>> try {
>>>> Resource resource = null;
>>>> Map options = new HashMap();
>>>> options.put(XMLResource.OPTION_EXTENDED_META_DATA,
>>>> Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
>>>> Boolean.TRUE);
>>>> options.put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
>>>> try {
>>>> resource.load(options);
>>>> resource.resourceSet.getResource(fileURI, true);
>>>>
>>>> } catch (IOException e) {
>>>> ...
>>>> }
>>>> }
>>>> ...
>>>>
>>>> This wont work because resource is null. So how can i set the load
>>>> options? Must i use a XMLMap?
>>>>
>>>> Ed Merks schrieb:
>>>>> It sounds like it should be fine, but clearly it isn't. Given you
>>>>> have both a context where it works and one where it doesn't, and
>>>>> you have a stack trace for the point of failure, you're the one in
>>>>> the best position to figure out why it would work in one case but
>>>>> not the other. I seems to me this exception implies your JAXP
>>>>> implementation doesn't support lexical handlers so you might look
>>>>> at the implement class being used to implement the SAXParser
>>>>> interface in each case. You might try this option to avoid
>>>>> needing lexical handler support:
>>>>>
>>>>> /**
>>>>> * Determines whether comments and CDATA will be preserved in
>>>>> any
>>>>> mixed text processing.
>>>>> * This option is applicable for loading XML resources (from DOM
>>>>> node or an InputStream)
>>>>> */
>>>>> String OPTION_USE_LEXICAL_HANDLER = "USE_LEXICAL_HANDLER";
>>>>>
>>>>>
>>>>> exquisitus wrote:
>>>>>> My Enviorment is
>>>>>>
>>>>>> Eclipse 3.4 with EMF 2.4.1
>>>>>> Java Version is latest 1.5 Version (1.5.0_15-b04)
>>>>>>
>>>>>>
>>>>>> Ed Merks schrieb:
>>>>>>> As I said, the exception looks to me like an issue related to the
>>>>>>> JAXP implementation you have installed as part of the JR. If you
>>>>>>> follow the stack trace for this exception
>>>>>>>
>>>>>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>>>>>> http://xml.org/sax/properties/lexical-handler
>>>>>>>
>>>>>>> you'll see that EMF is trying to set up a lexical handler on the
>>>>>>> SAX parser. That should just work, and clearly works most of the
>>>>>>> time (all the time in my experience) except in this stand-alone
>>>>>>> environment your running. What JRE are you using?
>>>>>>>
>>>>>>> exquisitus wrote:
>>>>>>>> Thanks for the quick answer. But I use the code from the
>>>>>>>> generated Example but it still doesnt work. I get a acception
>>>>>>>> from SAX.
>>>>>>>> I my GUI all works fine. I use a xml-File with a dtd file which
>>>>>>>> contains Entities. Maybe this is the problem. How can i set some
>>>>>>>> load options?
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>> Load:
>>>>>>>>
>>>>>>>> URI fileURI fileURI = URI.createFileURI(new
>>>>>>>> File(file).getAbsolutePath());
>>>>>>>>
>>>>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>>>
>>>>>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>>>>>>
>>>>>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>>>>>> new TSMBuildResourceFactoryImpl());
>>>>>>>>
>>>>>>>> resourceSet.getPackageRegistry().put(TSMBuildPackage.eNS_URI ,
>>>>>>>> TSMBuildPackage.eINSTANCE);
>>>>>>>> try {
>>>>>>>>
>>>>>>>> Resource resource = resourceSet.getResource(fileURI, true);
>>>>>>>> } catch (RuntimeException exception) {
>>>>>>>> ...
>>>>>>>> }
>>>>>>>>
>>>>>>>> Ed Merks schrieb:
>>>>>>>>> Comments below.
>>>>>>>>>
>>>>>>>>> exquisitus wrote:
>>>>>>>>>> Hi
>>>>>>>>>>
>>>>>>>>>> i tried to load my XML-File which based on EMF Model in a
>>>>>>>>>> stand-alone apllication. The apllication is a simple Java main
>>>>>>>>>> programm.
>>>>>>>>> Is it just like the one that's generated if you invoke
>>>>>>>>> "Generate Test Code" and look at the generated XyzExample.java?
>>>>>>>>>> With EMF 2.3 all works fine now with EMF 2.4.1 it doesnt work.
>>>>>>>>>> What did i wrong? Big thanks for you help
>>>>>>>>>>
>>>>>>>>>> Code:
>>>>>>>>>>
>>>>>>>>>> URI fileURI = null;
>>>>>>>>>> if(file != null) {
>>>>>>>>>> fileURI = URI.createFileURI(new
>>>>>>>>>> File(file).getAbsolutePath()); }else {
>>>>>>>>>> return null;
>>>>>>>>>> }
>>>>>>>>>> Resource poResource = null;
>>>>>>>>>>
>>>>>>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().
>>>>>>>>>>
>>>>>>>>>> put(Resource.Factory.Registry.DEFAULT_EXTENSION,
>>>>>>>>>> new XYZBuildResourceFactoryImpl());
>>>>>>>>>>
>>>>>>>>>> resourceSet.getPackageRegistry().put(XYZBuildPackage.eNS_URI ,
>>>>>>>>>> TSMBuildPackage.eINSTANCE);
>>>>>>>>>>
>>>>>>>>>> try {
>>>>>>>>>> poResource = resourceSet.getResource(fileURI, true);
>>>>>>>>>>
>>>>>>>>>> docRoot = (DocumentRoot) poResource.getContents().get(0);
>>>>>>>>>>
>>>>>>>>>> } catch (Exception ex) {
>>>>>>>>>> System.out.println(ex.toString());
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> I become this Exeception:
>>>>>>>>>>
>>>>>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
>>>>>>>>>> org.xml.sax.SAXNotRecognizedException: Feature:
>>>>>>>>>> http://xml.org/sax/properties/lexical-handler
>>>>>>>>> This sounds like an issue related to the JRE you are using not
>>>>>>>>> directly an EMF issue.
Previous Topic:[CDO] Tutorial on writing org.eclipse.emf.cdo.server.IStore implementation?
Next Topic:Use EObject for Behavioral Extensions
Goto Forum:
  


Current Time: Thu Apr 18 13:08:52 GMT 2024

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

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

Back to the top