Home » Modeling » EMF » ResourceEntityHandler
ResourceEntityHandler [message #421768] |
Wed, 13 August 2008 12:37 |
exquisitus Messages: 211 Registered: July 2009 |
Senior Member |
|
|
Hello
i go t a probelm with the ResourceEntityHandler. If i use the
ResourceEntityHandler in the open and save options, in ModelEditor
the Entities arent replaced correct;
example
DTD-File
<!ENTITY version "111">
<!ENTITY buildVersionDir "/develop/loc/v&version;/">
XML-File
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE build SYSTEM "build.dtd">
<model:Build xmlns:model="http://model.plugin.build.mainz.de.ibm.com">
<model:pathInfo>
<model:buildVersionDir>&buildCodeDir;</model:buildVersionDir >
</model:pathInfo>
</model:Build>
ModelEditor
public void createModel() {
resourceURI = EditUIUtil.getURI(getEditorInput());
// add URI to Build View Manager (for View)
ConfigurationManager.getManager().addConfiguration(resourceU RI);
Exception exception = null;
Resource resource = null;
editingDomain.getResourceSet().getResourceFactoryRegistry(). getExtensionToFactoryMap().put( "xml",
new XMLResourceFactoryImpl() {
@Override
public Resource createResource(URI uri) {
XMLResource result = (XMLResource) super.createResource(uri);
// ResourceEntityHandlerImpl resourceEntityHandler = new
// ResourceEntityHandlerImpl("_");
ResourceEntityHandlerImpl resourceEntityHandler = new
ResourceEntityHandlerImpl("_");
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA _LOCATION,
Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SAVE_D OCTYPE,
Boolean.TRUE);
//
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
//
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
//
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LE XICAL_HANDLER,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_RESOUR CE_ENTITY_HANDLER,
resourceEntityHandler);
return result;
}
});
try {
resource = editingDomain.getResourceSet().getResource(resourceURI, true);
} catch (Exception e) {
.....
So if I load the XML-File with ResourceEntityHandler in the ModelEditor
buildVersionDir = 111/
that is wrong. but if i doesnt use the ResourceEntityHandler the
buildVersionDir is correct?
I must use the ResourceEntityHandler. Any ideas?
|
|
|
Re: ResourceEntityHandler [message #421781 is a reply to message #421768] |
Wed, 13 August 2008 13:14 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------030604000800080704080609
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Comments below.
exquisitus wrote:
> Hello
>
> i go t a probelm with the ResourceEntityHandler. If i use the
> ResourceEntityHandler in the open and save options, in ModelEditor
> the Entities arent replaced correct;
>
> example
>
> DTD-File
> <!ENTITY version "111">
> <!ENTITY buildVersionDir "/develop/loc/v&version;/">
So you're using entities in the definition of other entities. I just
don't think the SAX callbacks provide enough details to try to
accurately record these things. I'll only see the expanded version and
have no idea how entity expansion arrived at the string.
>
> XML-File
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE build SYSTEM "build.dtd">
> <model:Build xmlns:model="http://model.plugin.build.mainz.de.ibm.com">
> <model:pathInfo>
> <model:buildVersionDir>&buildCodeDir;</model:buildVersionDir >
> </model:pathInfo>
> </model:Build>
>
> ModelEditor
>
> public void createModel() {
>
> resourceURI = EditUIUtil.getURI(getEditorInput());
>
> // add URI to Build View Manager (for View)
> ConfigurationManager.getManager().addConfiguration(resourceU RI);
>
> Exception exception = null;
> Resource resource = null;
>
>
> editingDomain.getResourceSet().getResourceFactoryRegistry(). getExtensionToFactoryMap().put( "xml",
> new XMLResourceFactoryImpl() {
>
> @Override
> public Resource createResource(URI uri) {
>
> XMLResource result = (XMLResource)
> super.createResource(uri);
> // ResourceEntityHandlerImpl resourceEntityHandler = new
> // ResourceEntityHandlerImpl("_");
>
> ResourceEntityHandlerImpl resourceEntityHandler = new
> ResourceEntityHandlerImpl("_");
>
>
> result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
> Boolean.TRUE);
>
> result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
> Boolean.TRUE);
>
>
> result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA _LOCATION,
> Boolean.TRUE);
>
>
> result.getDefaultSaveOptions().put(XMLResource.OPTION_SAVE_D OCTYPE,
> Boolean.TRUE);
>
> //
> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
> Boolean.TRUE);
> //
> result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
> Boolean.TRUE);
>
> //
> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LE XICAL_HANDLER,
> Boolean.TRUE);
>
>
> result.getDefaultLoadOptions().put(XMLResource.OPTION_RESOUR CE_ENTITY_HANDLER,
> resourceEntityHandler);
> return result;
> }
> });
>
> try {
>
> resource =
> editingDomain.getResourceSet().getResource(resourceURI, true);
>
> } catch (Exception e) {
> ....
>
> So if I load the XML-File with ResourceEntityHandler in the ModelEditor
> buildVersionDir = 111/
> that is wrong. but if i doesnt use the ResourceEntityHandler the
> buildVersionDir is correct?
>
> I must use the ResourceEntityHandler. Any ideas?
Not really. The only places the entity hander are used is:
public void startEntity(java.lang.String name)
{
if (resourceEntityHandler != null)
{
text = new StringBuffer();
}
}
public void endEntity(java.lang.String name)
{
if (resourceEntityHandler != null)
{
resourceEntityHandler.handleEntity(name, text.toString());
}
}
So I imagined all they'd do is record things with no other effect.
Perhaps this is being invoked recursively, but I didn't think entities
nested...
--------------030604000800080704080609
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">
Comments below.<br>
<br>
exquisitus wrote:
<blockquote cite="mid:g7uki1$ku8$1@build.eclipse.org" type="cite">Hello
<br>
<br>
i go t a probelm with the ResourceEntityHandler. If i use the
ResourceEntityHandler in the open and save options, in ModelEditor
<br>
the Entities arent replaced correct;
<br>
<br>
example
<br>
<br>
DTD-File
<br>
<!ENTITY version "111">
<br>
<!ENTITY buildVersionDir "/develop/loc/v&version;/">
<br>
</blockquote>
So you're using entities in the definition of other entities.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: ResourceEntityHandler [message #421798 is a reply to message #421781] |
Wed, 13 August 2008 17:19 |
exquisitus Messages: 211 Registered: July 2009 |
Senior Member |
|
|
Ed Merks schrieb:
> Comments below.
>
> exquisitus wrote:
>> Hello
>>
>> i go t a probelm with the ResourceEntityHandler. If i use the
>> ResourceEntityHandler in the open and save options, in ModelEditor
>> the Entities arent replaced correct;
>>
>> example
>>
>> DTD-File
>> <!ENTITY version "111">
>> <!ENTITY buildVersionDir "/develop/loc/v&version;/">
> So you're using entities in the definition of other entities. I just
> don't think the SAX callbacks provide enough details to try to
> accurately record these things. I'll only see the expanded version and
> have no idea how entity expansion arrived at the string.
>>
>> XML-File
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE build SYSTEM "build.dtd">
>> <model:Build xmlns:model="http://model.plugin.build.mainz.de.ibm.com">
>> <model:pathInfo>
>> <model:buildVersionDir>&buildCodeDir;</model:buildVersionDir >
>> </model:pathInfo>
>> </model:Build>
>>
>> ModelEditor
>>
>> public void createModel() {
>>
>> resourceURI = EditUIUtil.getURI(getEditorInput());
>>
>> // add URI to Build View Manager (for View)
>> ConfigurationManager.getManager().addConfiguration(resourceU RI);
>>
>> Exception exception = null;
>> Resource resource = null;
>>
>>
>> editingDomain.getResourceSet().getResourceFactoryRegistry(). getExtensionToFactoryMap().put( "xml",
>> new XMLResourceFactoryImpl() {
>>
>> @Override
>> public Resource createResource(URI uri) {
>>
>> XMLResource result = (XMLResource)
>> super.createResource(uri);
>> // ResourceEntityHandlerImpl resourceEntityHandler = new
>> // ResourceEntityHandlerImpl("_");
>>
>> ResourceEntityHandlerImpl resourceEntityHandler = new
>> ResourceEntityHandlerImpl("_");
>>
>>
>> result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
>> Boolean.TRUE);
>>
>> result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
>> Boolean.TRUE);
>>
>>
>> result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA _LOCATION,
>> Boolean.TRUE);
>>
>>
>> result.getDefaultSaveOptions().put(XMLResource.OPTION_SAVE_D OCTYPE,
>> Boolean.TRUE);
>>
>> //
>> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
>> Boolean.TRUE);
>> //
>> result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
>> Boolean.TRUE);
>>
>> //
>> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LE XICAL_HANDLER,
>> Boolean.TRUE);
>>
>>
>> result.getDefaultLoadOptions().put(XMLResource.OPTION_RESOUR CE_ENTITY_HANDLER,
>> resourceEntityHandler);
>> return result;
>> }
>> });
>>
>> try {
>>
>> resource =
>> editingDomain.getResourceSet().getResource(resourceURI, true);
>>
>> } catch (Exception e) {
>> ....
>>
>> So if I load the XML-File with ResourceEntityHandler in the ModelEditor
>> buildVersionDir = 111/
>> that is wrong. but if i doesnt use the ResourceEntityHandler the
>> buildVersionDir is correct?
>>
>> I must use the ResourceEntityHandler. Any ideas?
> Not really. The only places the entity hander are used is:
>
> public void startEntity(java.lang.String name)
> {
> if (resourceEntityHandler != null)
> {
> text = new StringBuffer();
> }
> }
>
> public void endEntity(java.lang.String name)
> {
> if (resourceEntityHandler != null)
> {
> resourceEntityHandler.handleEntity(name, text.toString());
> }
> }
>
> So I imagined all they'd do is record things with no other effect.
> Perhaps this is being invoked recursively, but I didn't think entities
> nested...
Ok thanks
Is there a way to get the loaded Entities without the
ResourceEntityHandler, i mean from the editingDomain or the loaded
Resource? I tried to find them with the debugger. No luck
|
|
|
Re: ResourceEntityHandler [message #421800 is a reply to message #421798] |
Wed, 13 August 2008 18:33 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
EMF just uses SAX to load so if there isn't a way to do it with SAX,
there isn't a way. I don't think you can even do what you want with DOM
for that matter, so that should be a good indication that it's a hard
problem.
exquisitus wrote:
> Ed Merks schrieb:
>> Comments below.
>>
>> exquisitus wrote:
>>> Hello
>>>
>>> i go t a probelm with the ResourceEntityHandler. If i use the
>>> ResourceEntityHandler in the open and save options, in ModelEditor
>>> the Entities arent replaced correct;
>>>
>>> example
>>>
>>> DTD-File
>>> <!ENTITY version "111">
>>> <!ENTITY buildVersionDir "/develop/loc/v&version;/">
>> So you're using entities in the definition of other entities. I just
>> don't think the SAX callbacks provide enough details to try to
>> accurately record these things. I'll only see the expanded version
>> and have no idea how entity expansion arrived at the string.
>>>
>>> XML-File
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <!DOCTYPE build SYSTEM "build.dtd">
>>> <model:Build xmlns:model="http://model.plugin.build.mainz.de.ibm.com">
>>> <model:pathInfo>
>>> <model:buildVersionDir>&buildCodeDir;</model:buildVersionDir >
>>> </model:pathInfo>
>>> </model:Build>
>>>
>>> ModelEditor
>>>
>>> public void createModel() {
>>>
>>> resourceURI = EditUIUtil.getURI(getEditorInput());
>>>
>>> // add URI to Build View Manager (for View)
>>>
>>> ConfigurationManager.getManager().addConfiguration(resourceU RI);
>>>
>>> Exception exception = null;
>>> Resource resource = null;
>>>
>>>
>>> editingDomain.getResourceSet().getResourceFactoryRegistry(). getExtensionToFactoryMap().put( "xml",
>>> new XMLResourceFactoryImpl() {
>>>
>>> @Override
>>> public Resource createResource(URI uri) {
>>>
>>> XMLResource result = (XMLResource)
>>> super.createResource(uri);
>>> // ResourceEntityHandlerImpl resourceEntityHandler =
>>> new
>>> // ResourceEntityHandlerImpl("_");
>>>
>>> ResourceEntityHandlerImpl resourceEntityHandler =
>>> new ResourceEntityHandlerImpl("_");
>>>
>>> result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
>>> Boolean.TRUE);
>>>
>>> result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
>>> Boolean.TRUE);
>>>
>>>
>>> result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA _LOCATION,
>>> Boolean.TRUE);
>>>
>>>
>>> result.getDefaultSaveOptions().put(XMLResource.OPTION_SAVE_D OCTYPE,
>>> Boolean.TRUE);
>>>
>>> //
>>> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
>>> Boolean.TRUE);
>>> //
>>> result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
>>> Boolean.TRUE);
>>>
>>> //
>>> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LE XICAL_HANDLER,
>>> Boolean.TRUE);
>>>
>>>
>>> result.getDefaultLoadOptions().put(XMLResource.OPTION_RESOUR CE_ENTITY_HANDLER,
>>> resourceEntityHandler);
>>> return result;
>>> }
>>> });
>>>
>>> try {
>>>
>>> resource =
>>> editingDomain.getResourceSet().getResource(resourceURI, true);
>>>
>>> } catch (Exception e) {
>>> ....
>>>
>>> So if I load the XML-File with ResourceEntityHandler in the ModelEditor
>>> buildVersionDir = 111/
>>> that is wrong. but if i doesnt use the ResourceEntityHandler the
>>> buildVersionDir is correct?
>>>
>>> I must use the ResourceEntityHandler. Any ideas?
>> Not really. The only places the entity hander are used is:
>>
>> public void startEntity(java.lang.String name)
>> {
>> if (resourceEntityHandler != null)
>> {
>> text = new StringBuffer();
>> }
>> }
>>
>> public void endEntity(java.lang.String name)
>> {
>> if (resourceEntityHandler != null)
>> {
>> resourceEntityHandler.handleEntity(name, text.toString());
>> }
>> }
>>
>> So I imagined all they'd do is record things with no other effect.
>> Perhaps this is being invoked recursively, but I didn't think
>> entities nested...
>
> Ok thanks
> Is there a way to get the loaded Entities without the
> ResourceEntityHandler, i mean from the editingDomain or the loaded
> Resource? I tried to find them with the debugger. No luck
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Thu Apr 25 22:43:38 GMT 2024
Powered by FUDForum. Page generated in 0.03554 seconds
|