| How to: dynamically loading xmi files from a web server? [message #376727] |
Wed, 29 January 2003 14:24  |
Eclipse User |
|
|
|
I have another problem. How do I tell EMF that the resolving mechanism needs
to load the xmi files from a webserver. I currently have one xmi file that
was already successfully transfered from the server but it contains
references to other model elements stored in their own xmi file. If the
original xmi file was loaded like this from a URL:
ResourceSet set = new ResourceSetImpl();
URI uri = URI.createURI(http://www.myserver.com/MyXMIFile.suffix);
Resource res = set.getResource(uri, true);
MyModelElement el = (MyModelElement) resource.getContents().get(0);
How then does it know that a reference inside MyXMIFile.suffix points to a
file on the webserver at www.myserver.com?
--Dirk
|
|
|
| Re: How to: dynamically loading xmi files from a web server? [message #376728 is a reply to message #376727] |
Wed, 29 January 2003 14:57   |
Eclipse User |
|
|
|
--------------7C80F66B38B42E5FAA53803A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Dirk,
This works the same way as with an HTML document in a web browser, i.e., any
relative references are resolved against the URI of the containing document's
(absolute) URI to produce the absolute URI of the referenced document. The
XMLHandler (in org.eclipse.emf.ecore.xmi) has code like this:
protected void handleProxy(InternalEObject proxy, String uriLiteral)
{
if (oldStyleProxyURIs)
{
proxy.eSetProxyURI(URI.createURI(uriLiteral.startsWith("/") ?
uriLiteral : "/" + uriLiteral));
}
else
{
URI uri = URI.createDeviceURI(uriLiteral);
if (resolve && uri.isRelative() && uri.hasRelativePath() &&
!EPackage.Registry.INSTANCE.containsKey(uri.trimFragment().t oString()))
{
uri = helper.resolve(uri, resourceURI);
}
proxy.eSetProxyURI(uri);
}
}
The methods org.eclipse.emf.common.util.URI.resolve/deresolve provide the
underlying support.
This should all work transparently... What do your cross document references
look like?
Dirk Lemmermann wrote:
> I have another problem. How do I tell EMF that the resolving mechanism needs
> to load the xmi files from a webserver. I currently have one xmi file that
> was already successfully transfered from the server but it contains
> references to other model elements stored in their own xmi file. If the
> original xmi file was loaded like this from a URL:
>
> ResourceSet set = new ResourceSetImpl();
> URI uri = URI.createURI(http://www.myserver.com/MyXMIFile.suffix);
> Resource res = set.getResource(uri, true);
> MyModelElement el = (MyModelElement) resource.getContents().get(0);
>
> How then does it know that a reference inside MyXMIFile.suffix points to a
> file on the webserver at www.myserver.com?
>
> --Dirk
--------------7C80F66B38B42E5FAA53803A
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Dirk,
<p>This works the same way as with an HTML document in a web browser, i.e.,
any relative references are resolved against the URI of the containing
document's (absolute) URI to produce the absolute URI of the referenced
document. The XMLHandler (in org.eclipse.emf.ecore.xmi) has code
like this:
<blockquote><tt> protected void handleProxy(InternalEObject proxy,
String uriLiteral)</tt>
<br><tt> {</tt>
<br><tt> if (oldStyleProxyURIs)</tt>
<br><tt> {</tt>
<br><tt> proxy.eSetProxyURI(URI.createURI(uriLiteral.startsWith("/")
? uriLiteral : "/" + uriLiteral));</tt>
<br><tt> }</tt>
<br><tt> else</tt>
<br><tt> {</tt>
<br><tt> URI uri = URI.createDeviceURI(uriLiteral);</tt>
<br><tt> if (resolve && uri.isRelative()
&& uri.hasRelativePath() && !EPackage.Registry.INSTANCE.containsKey(uri.trimFragment().t oString())) </tt>
<br><tt> {</tt>
<br><tt> uri = helper.resolve(uri,
resourceURI);</tt>
<br><tt> }</tt>
<br><tt> proxy.eSetProxyURI(uri);</tt>
<br><tt> }</tt>
<br><tt> }</tt></blockquote>
The methods org.eclipse.emf.common.util.URI.resolve/deresolve provide the
underlying support.
<p>This should all work transparently... What do your cross document
references look like?
<br>
<p>Dirk Lemmermann wrote:
<blockquote TYPE=CITE>I have another problem. How do I tell EMF that the
resolving mechanism needs
<br>to load the xmi files from a webserver. I currently have one xmi file
that
<br>was already successfully transfered from the server but it contains
<br>references to other model elements stored in their own xmi file. If
the
<br>original xmi file was loaded like this from a URL:
<p> ResourceSet set = new ResourceSetImpl();
<br> URI uri = URI.createURI(<a href="http://www.myserver.com/MyXMIFile.suffix">http://www.myserver.com/MyXMIFile.suffix</a>);
<br> Resource res = set.getResource(uri, true);
<br> MyModelElement el = (MyModelElement) resource.getContents().get(0);
<p>How then does it know that a reference inside MyXMIFile.suffix points
to a
<br>file on the webserver at www.myserver.com?
<p>--Dirk</blockquote>
</html>
--------------7C80F66B38B42E5FAA53803A--
|
|
|
| Re: How to: dynamically loading xmi files from a web server? [message #376729 is a reply to message #376728] |
Wed, 29 January 2003 15:03  |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0040_01C2C7A7.A2E9C390
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Ed, thanks a lot,
that was the answer I was hoping for although it means that I must be =
doing something wrong right now :-)
--Dirk
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:3E383215.85E14DDD@ca.ibm.com...
Dirk,=20
This works the same way as with an HTML document in a web browser, =
i.e., any relative references are resolved against the URI of the =
containing document's (absolute) URI to produce the absolute URI of the =
referenced document. The XMLHandler (in org.eclipse.emf.ecore.xmi) has =
code like this:=20
protected void handleProxy(InternalEObject proxy, String =
uriLiteral)=20
{=20
if (oldStyleProxyURIs)=20
{=20
proxy.eSetProxyURI(URI.createURI(uriLiteral.startsWith("/") ? =
uriLiteral : "/" + uriLiteral));=20
}=20
else=20
{=20
URI uri =3D URI.createDeviceURI(uriLiteral);=20
if (resolve && uri.isRelative() && uri.hasRelativePath() && =
!EPackage.Registry.INSTANCE.containsKey(uri.trimFragment().t oString()))=20
{=20
uri =3D helper.resolve(uri, resourceURI);=20
}=20
proxy.eSetProxyURI(uri);=20
}=20
}
The methods org.eclipse.emf.common.util.URI.resolve/deresolve provide =
the underlying support.=20
This should all work transparently... What do your cross document =
references look like?=20
=20
Dirk Lemmermann wrote:=20
I have another problem. How do I tell EMF that the resolving =
mechanism needs=20
to load the xmi files from a webserver. I currently have one xmi =
file that=20
was already successfully transfered from the server but it contains=20
references to other model elements stored in their own xmi file. If =
the=20
original xmi file was loaded like this from a URL:=20
ResourceSet set =3D new ResourceSetImpl();=20
URI uri =3D =
URI.createURI(http://www.myserver.com/MyXMIFile.suffix);=20
Resource res =3D set.getResource(uri, true);=20
MyModelElement el =3D (MyModelElement) =
resource.getContents().get(0);=20
How then does it know that a reference inside MyXMIFile.suffix =
points to a=20
file on the webserver at www.myserver.com?=20
--Dirk
------=_NextPart_000_0040_01C2C7A7.A2E9C390
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Ed, thanks a lot,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>that was the answer I was hoping for =
although it=20
means that I must be doing something wrong right =
now :-)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>--Dirk</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" <<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>>=20
wrote in message <A=20
=
href=3D"news:3E383215.85E14DDD@ca.ibm.com">news:3E383215.85E14DDD@ca.ibm.=
com</A>...</DIV>Dirk,=20
<P>This works the same way as with an HTML document in a web browser, =
i.e.,=20
any relative references are resolved against the URI of the containing =
document's (absolute) URI to produce the absolute URI of the =
referenced=20
document. The XMLHandler (in org.eclipse.emf.ecore.xmi) has code =
like=20
this:=20
<BLOCKQUOTE><TT> protected void handleProxy(InternalEObject =
proxy,=20
String uriLiteral)</TT> <BR><TT> {</TT> =
<BR><TT> if=20
(oldStyleProxyURIs)</TT> <BR><TT> {</TT>=20
<BR><TT> =20
proxy.eSetProxyURI(URI.createURI(uriLiteral.startsWith("/") ? =
uriLiteral :=20
"/" + uriLiteral));</TT> <BR><TT> }</TT>=20
<BR><TT> else</TT> <BR><TT> =
{</TT>=20
<BR><TT> URI uri =3D=20
URI.createDeviceURI(uriLiteral);</TT> =
<BR><TT> =20
if (resolve && uri.isRelative() && =
uri.hasRelativePath()=20
&&=20
=
!EPackage.Registry.INSTANCE.containsKey(uri.trimFragment().t oString())) </=
TT>=20
<BR><TT> {</TT>=20
<BR><TT> uri =3D =
helper.resolve(uri,=20
resourceURI);</TT> <BR><TT> }</TT>=20
<BR><TT> proxy.eSetProxyURI(uri);</TT> =
<BR><TT> }</TT> <BR><TT> =
}</TT></BLOCKQUOTE>The=20
methods org.eclipse.emf.common.util.URI.resolve/deresolve provide the=20
underlying support.=20
<P>This should all work transparently... What do your cross =
document=20
references look like? <BR> =20
<P>Dirk Lemmermann wrote:=20
<BLOCKQUOTE TYPE=3D"CITE">I have another problem. How do I tell EMF =
that the=20
resolving mechanism needs <BR>to load the xmi files from a =
webserver. I=20
currently have one xmi file that <BR>was already successfully =
transfered=20
from the server but it contains <BR>references to other model =
elements=20
stored in their own xmi file. If the <BR>original xmi file was =
loaded like=20
this from a URL:=20
<P> ResourceSet set =3D new ResourceSetImpl();=20
<BR> URI uri =3D URI.createURI(<A=20
=
href=3D"http://www.myserver.com/MyXMIFile.suffix">http://www.myserver.com=
/MyXMIFile.suffix</A>);=20
<BR> Resource res =3D set.getResource(uri, true);=20
<BR> MyModelElement el =3D (MyModelElement)=20
resource.getContents().get(0);=20
<P>How then does it know that a reference inside MyXMIFile.suffix =
points to=20
a <BR>file on the webserver at www.myserver.com?=20
<P>--Dirk</P></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_0040_01C2C7A7.A2E9C390--
|
|
|
Powered by
FUDForum. Page generated in 0.03051 seconds