Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » URIConverter question.
URIConverter question. [message #70848] Fri, 01 December 2006 16:16 Go to next message
Eclipse UserFriend
Originally posted by: ashish.deshpande.cc

Hi,
I am having trouble understanding URIConverter. I have a serialized
(XMI) file from a colleague with the following content (a string
XSDSimpleTypeDefinition):
------------------------------------------------------------ --
<typeDefinition xsi:type="xsd:XSDSimpleTypeDefinition"
href=" jar:file:/D:/Projects/eclipse-projects/frevvo/workspace/com. gauss.forms/lib/org.eclipse.xsd_2.2.0.v200606271057.jar!/cac he/www.w3.org/2001/XMLSchema.xsd#//string;XSDSimpleTypeDefin ition=7 "/>
------------------------------------------------------------ --
As you can see, the href points to a specific file (D:/....). That path
does not exist on my machine making this file non-portable. So,
1) Can I make this portable? I can put the jar file in a common relative
directory (say ../../lib, which will work on all machines for my
application). Can I force the href to point to
jar:file:../../lib/org.eclipse etc.
instead of the D:/Projects?

2) How can I use a URIConverter to affect this? I know what the
URIConverter should do but I am unable to attach my custom URIConverter
to handle this URI. Specifically, MyCustomConverter.normalize(uri) is
never called for this URI even though I have done:
------------------------------------------------------------ --
resourceSet.setURIConverter (new MyCustomConverter());
------------------------------------------------------------ --
Is it that this particular URI is loaded using a Resource from a
different ResourceSet but I don't understand how to affect that.

Thx,
-Ashish
Re: URIConverter question. [message #70871 is a reply to message #70848] Fri, 01 December 2006 18:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------090805020003010803090605
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Ashish,

Ouch. That's nasty! The built-in schema for schemas is loaded like
this in XSDSchemaImpl:

public static synchronized XSDSchema getSchemaForSchema(String
namespace)
{
if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace))
{
if (xsdSchemaForSchema2001 == null)
{
try
{
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
getMagicSchemaForSchema(namespace);

getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA ",
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
getGlobalResourceSet().getResource
(URI.createURI(baseURL +
"cache/www.w3.org/2001/XMLSchema.xsd"), true);

In an Eclipse/OSGi environment this would use
"platform:/plugin/org.eclipse.xsd/" but when running standalone, it will
reference the physical jar location and then the reference will not be
portable. :-(

I've been playing with
https://bugs.eclipse.org/bugs/show_bug.cgi?id=164597 but have not had a
chance to work on it for a while, but that could be used (instead of a
specialization of XMLHelperImpl.deresolve) to turn the non-portable
physical location into a logical URI while saving and then you could use
a URI mapping to ensure that that logical URI maps to the right physical
location. Another wrinkle though is that since this schema for schema
resource is in a separate resource set you'd need to specialize
ResourceSetImpl.delegatedGetResource to look in the special resource set
containing the schema for schemas.

Probably the simplest brute force approach is to specialize
ResourceSetImpl.delegatedGetResource to look for a URI with path
/cache/www.w3.org/2001/XMLSchema.xsd, ignoring the non-portable
authority, and redirect it to return the schema for schemas's resource.


Ashish Deshpande wrote:
> Hi,
> I am having trouble understanding URIConverter. I have a serialized
> (XMI) file from a colleague with the following content (a string
> XSDSimpleTypeDefinition):
> ------------------------------------------------------------ --
> <typeDefinition xsi:type="xsd:XSDSimpleTypeDefinition"
> href=" jar:file:/D:/Projects/eclipse-projects/frevvo/workspace/com. gauss.forms/lib/org.eclipse.xsd_2.2.0.v200606271057.jar!/cac he/www.w3.org/2001/XMLSchema.xsd#//string;XSDSimpleTypeDefin ition=7 "/>
>
> ------------------------------------------------------------ --
> As you can see, the href points to a specific file (D:/....). That
> path does not exist on my machine making this file non-portable. So,
> 1) Can I make this portable? I can put the jar file in a common
> relative directory (say ../../lib, which will work on all machines for
> my application). Can I force the href to point to
> jar:file:../../lib/org.eclipse etc.
> instead of the D:/Projects?
>
> 2) How can I use a URIConverter to affect this? I know what the
> URIConverter should do but I am unable to attach my custom
> URIConverter to handle this URI. Specifically,
> MyCustomConverter.normalize(uri) is never called for this URI even
> though I have done:
> ------------------------------------------------------------ --
> resourceSet.setURIConverter (new MyCustomConverter());
> ------------------------------------------------------------ --
> Is it that this particular URI is loaded using a Resource from a
> different ResourceSet but I don't understand how to affect that.
>
> Thx,
> -Ashish


--------------090805020003010803090605
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">
Ashish,<br>
<br>
Ouch.&nbsp; That's nasty!&nbsp; The built-in schema for schemas is loaded like
this in XSDSchemaImpl:<br>
<blockquote><small>&nbsp; public static synchronized XSDSchema
getSchemaForSchema(String namespace)</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; if
(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace))</small ><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (xsdSchemaForSchema2001 == null)</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; try</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String baseURL =
XSDPlugin.INSTANCE.getBaseURL().toString();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; getMagicSchemaForSchema(namespace);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA ",
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; getGlobalResourceSet().getResource</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (URI.createURI(baseURL +
"cache/www.w3.org/2001/XMLSchema.xsd"), true);</small><br>
</blockquote>
In an Eclipse/OSGi environment this would use
"platform:/plugin/org.eclipse.xsd/" but when running standalone, it
will reference the physical jar location and then the reference will
not be portable.&nbsp; :-(<br>
<br>
I've been playing with <a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=164597">https://bugs.eclipse.org/bugs/show_bug.cgi?id=164597</a>
but have not had a chance to work on it for a while, but that could be
used (instead of a specialization of XMLHelperImpl.deresolve) to turn
the non-portable physical location into a logical URI while saving and
then you could use a URI mapping to ensure that that logical URI maps
to the right physical location.&nbsp; Another wrinkle though is that since
this schema for schema resource is in a separate resource set you'd
need to specialize ResourceSetImpl.delegatedGetResource to look in the
special resource set containing the schema for schemas. &nbsp; <br>
<br>
Probably the simplest brute force approach is to specialize
ResourceSetImpl.delegatedGetResource to look for a URI with path
/cache/www.w3.org/2001/XMLSchema.xsd, ignoring the non-portable
authority, and redirect it to return the schema for schemas's resource.<br>
<br>
<br>
Ashish Deshpande wrote:
<blockquote cite="midekpkgi$gbi$1@utils.eclipse.org" type="cite">Hi,
<br>
I am having trouble understanding URIConverter. I have a serialized
(XMI) file from a colleague with the following content (a string
XSDSimpleTypeDefinition):
<br>
------------------------------------------------------------ --
<br>
&lt;typeDefinition xsi:type="xsd:XSDSimpleTypeDefinition"
href=<a class="moz-txt-link-rfc2396E" href=" jar:file:/D:/Projects/eclipse-projects/frevvo/workspace/com. gauss.forms/lib/org.eclipse.xsd_2.2.0.v200606271057.jar!/cac he/www.w3.org/2001/XMLSchema.xsd#//string;XSDSimpleTypeDefin ition=7 ">" jar:file:/D:/Projects/eclipse-projects/frevvo/workspace/com. gauss.forms/lib/org.eclipse.xsd_2.2.0.v200606271057.jar!/cac he/www.w3.org/2001/XMLSchema.xsd#//string;XSDSimpleTypeDefin ition=7 "</a>/&gt;
<br>
------------------------------------------------------------ --
<br>
As you can see, the href points to a specific file (D:/....). That path
does not exist on my machine making this file non-portable. So,
<br>
1) Can I make this portable? I can put the jar file in a common
relative directory (say ../../lib, which will work on all machines for
my application). Can I force the href to point to
<br>
&nbsp;&nbsp;&nbsp;&nbsp;jar:<a class="moz-txt-link-freetext" href="file:../../lib/org.eclipse">file:../../lib/org.eclipse </a> etc.
<br>
instead of the D:/Projects?
<br>
<br>
2) How can I use a URIConverter to affect this? I know what the
URIConverter should do but I am unable to attach my custom URIConverter
to handle this URI. Specifically, MyCustomConverter.normalize(uri) is
never called for this URI even though I have done:
<br>
------------------------------------------------------------ --
<br>
resourceSet.setURIConverter (new MyCustomConverter());
<br>
------------------------------------------------------------ --
<br>
Is it that this particular URI is loaded using a Resource from a
different ResourceSet but I don't understand how to affect that.
<br>
<br>
Thx,
<br>
-Ashish
<br>
</blockquote>
<br>
</body>
</html>

--------------090805020003010803090605--
Re: URIConverter question. [message #70889 is a reply to message #70871] Mon, 04 December 2006 17:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ashish.deshpande.cc

Oof! Thanks Ed for your response. I will have to parse this and play
with it a little bit but I think I understand the gist of what you're
saying.
-Ashish

Ed Merks wrote:
> Ashish,
>
> Ouch. That's nasty! The built-in schema for schemas is loaded like
> this in XSDSchemaImpl:
>
> public static synchronized XSDSchema getSchemaForSchema(String
> namespace)
> {
> if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace))
> {
> if (xsdSchemaForSchema2001 == null)
> {
> try
> {
> String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
> getMagicSchemaForSchema(namespace);
>
> getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA ",
> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
> getGlobalResourceSet().getResource
> (URI.createURI(baseURL +
> "cache/www.w3.org/2001/XMLSchema.xsd"), true);
>
> In an Eclipse/OSGi environment this would use
> "platform:/plugin/org.eclipse.xsd/" but when running standalone, it will
> reference the physical jar location and then the reference will not be
> portable. :-(
>
> I've been playing with
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=164597 but have not had a
> chance to work on it for a while, but that could be used (instead of a
> specialization of XMLHelperImpl.deresolve) to turn the non-portable
> physical location into a logical URI while saving and then you could use
> a URI mapping to ensure that that logical URI maps to the right physical
> location. Another wrinkle though is that since this schema for schema
> resource is in a separate resource set you'd need to specialize
> ResourceSetImpl.delegatedGetResource to look in the special resource set
> containing the schema for schemas.
>
> Probably the simplest brute force approach is to specialize
> ResourceSetImpl.delegatedGetResource to look for a URI with path
> /cache/www.w3.org/2001/XMLSchema.xsd, ignoring the non-portable
> authority, and redirect it to return the schema for schemas's resource.
>
>
> Ashish Deshpande wrote:
>> Hi,
>> I am having trouble understanding URIConverter. I have a serialized
>> (XMI) file from a colleague with the following content (a string
>> XSDSimpleTypeDefinition):
>> ------------------------------------------------------------ --
>> <typeDefinition xsi:type="xsd:XSDSimpleTypeDefinition"
>> href=" jar:file:/D:/Projects/eclipse-projects/frevvo/workspace/com. gauss.forms/lib/org.eclipse.xsd_2.2.0.v200606271057.jar!/cac he/www.w3.org/2001/XMLSchema.xsd#//string;XSDSimpleTypeDefin ition=7 "/>
>>
>> ------------------------------------------------------------ --
>> As you can see, the href points to a specific file (D:/....). That
>> path does not exist on my machine making this file non-portable. So,
>> 1) Can I make this portable? I can put the jar file in a common
>> relative directory (say ../../lib, which will work on all machines for
>> my application). Can I force the href to point to
>> jar:file:../../lib/org.eclipse etc.
>> instead of the D:/Projects?
>>
>> 2) How can I use a URIConverter to affect this? I know what the
>> URIConverter should do but I am unable to attach my custom
>> URIConverter to handle this URI. Specifically,
>> MyCustomConverter.normalize(uri) is never called for this URI even
>> though I have done:
>> ------------------------------------------------------------ --
>> resourceSet.setURIConverter (new MyCustomConverter());
>> ------------------------------------------------------------ --
>> Is it that this particular URI is loaded using a Resource from a
>> different ResourceSet but I don't understand how to affect that.
>>
>> Thx,
>> -Ashish
>
Re: URIConverter question. [message #70909 is a reply to message #70889] Mon, 04 December 2006 18:13 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Ashish,

I'm willing to consider making changes in XSD 2.3 that would make life
easier. For example, perhaps the URI of these special resources should
really be their physical location on the web...


Ashish Deshpande wrote:
> Oof! Thanks Ed for your response. I will have to parse this and play
> with it a little bit but I think I understand the gist of what you're
> saying.
> -Ashish
>
> Ed Merks wrote:
>> Ashish,
>>
>> Ouch. That's nasty! The built-in schema for schemas is loaded like
>> this in XSDSchemaImpl:
>>
>> public static synchronized XSDSchema getSchemaForSchema(String
>> namespace)
>> {
>> if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace))
>> {
>> if (xsdSchemaForSchema2001 == null)
>> {
>> try
>> {
>> String baseURL =
>> XSDPlugin.INSTANCE.getBaseURL().toString();
>> getMagicSchemaForSchema(namespace);
>>
>> getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA ",
>> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>> getGlobalResourceSet().getResource
>> (URI.createURI(baseURL +
>> "cache/www.w3.org/2001/XMLSchema.xsd"), true);
>>
>> In an Eclipse/OSGi environment this would use
>> "platform:/plugin/org.eclipse.xsd/" but when running standalone, it
>> will reference the physical jar location and then the reference will
>> not be portable. :-(
>>
>> I've been playing with
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=164597 but have not had
>> a chance to work on it for a while, but that could be used (instead
>> of a specialization of XMLHelperImpl.deresolve) to turn the
>> non-portable physical location into a logical URI while saving and
>> then you could use a URI mapping to ensure that that logical URI maps
>> to the right physical location. Another wrinkle though is that since
>> this schema for schema resource is in a separate resource set you'd
>> need to specialize ResourceSetImpl.delegatedGetResource to look in
>> the special resource set containing the schema for schemas.
>> Probably the simplest brute force approach is to specialize
>> ResourceSetImpl.delegatedGetResource to look for a URI with path
>> /cache/www.w3.org/2001/XMLSchema.xsd, ignoring the non-portable
>> authority, and redirect it to return the schema for schemas's resource.
>>
>>
>> Ashish Deshpande wrote:
>>> Hi,
>>> I am having trouble understanding URIConverter. I have a serialized
>>> (XMI) file from a colleague with the following content (a string
>>> XSDSimpleTypeDefinition):
>>> ------------------------------------------------------------ --
>>> <typeDefinition xsi:type="xsd:XSDSimpleTypeDefinition"
>>> href=" jar:file:/D:/Projects/eclipse-projects/frevvo/workspace/com. gauss.forms/lib/org.eclipse.xsd_2.2.0.v200606271057.jar!/cac he/www.w3.org/2001/XMLSchema.xsd#//string;XSDSimpleTypeDefin ition=7 "/>
>>>
>>> ------------------------------------------------------------ --
>>> As you can see, the href points to a specific file (D:/....). That
>>> path does not exist on my machine making this file non-portable. So,
>>> 1) Can I make this portable? I can put the jar file in a common
>>> relative directory (say ../../lib, which will work on all machines
>>> for my application). Can I force the href to point to
>>> jar:file:../../lib/org.eclipse etc.
>>> instead of the D:/Projects?
>>>
>>> 2) How can I use a URIConverter to affect this? I know what the
>>> URIConverter should do but I am unable to attach my custom
>>> URIConverter to handle this URI. Specifically,
>>> MyCustomConverter.normalize(uri) is never called for this URI even
>>> though I have done:
>>> ------------------------------------------------------------ --
>>> resourceSet.setURIConverter (new MyCustomConverter());
>>> ------------------------------------------------------------ --
>>> Is it that this particular URI is loaded using a Resource from a
>>> different ResourceSet but I don't understand how to affect that.
>>>
>>> Thx,
>>> -Ashish
>>
Re: URIConverter question. [message #599209 is a reply to message #70848] Fri, 01 December 2006 18:42 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090805020003010803090605
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Ashish,

Ouch. That's nasty! The built-in schema for schemas is loaded like
this in XSDSchemaImpl:

public static synchronized XSDSchema getSchemaForSchema(String
namespace)
{
if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace))
{
if (xsdSchemaForSchema2001 == null)
{
try
{
String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
getMagicSchemaForSchema(namespace);

getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA ",
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
getGlobalResourceSet().getResource
(URI.createURI(baseURL +
"cache/www.w3.org/2001/XMLSchema.xsd"), true);

In an Eclipse/OSGi environment this would use
"platform:/plugin/org.eclipse.xsd/" but when running standalone, it will
reference the physical jar location and then the reference will not be
portable. :-(

I've been playing with
https://bugs.eclipse.org/bugs/show_bug.cgi?id=164597 but have not had a
chance to work on it for a while, but that could be used (instead of a
specialization of XMLHelperImpl.deresolve) to turn the non-portable
physical location into a logical URI while saving and then you could use
a URI mapping to ensure that that logical URI maps to the right physical
location. Another wrinkle though is that since this schema for schema
resource is in a separate resource set you'd need to specialize
ResourceSetImpl.delegatedGetResource to look in the special resource set
containing the schema for schemas.

Probably the simplest brute force approach is to specialize
ResourceSetImpl.delegatedGetResource to look for a URI with path
/cache/www.w3.org/2001/XMLSchema.xsd, ignoring the non-portable
authority, and redirect it to return the schema for schemas's resource.


Ashish Deshpande wrote:
> Hi,
> I am having trouble understanding URIConverter. I have a serialized
> (XMI) file from a colleague with the following content (a string
> XSDSimpleTypeDefinition):
> ------------------------------------------------------------ --
> <typeDefinition xsi:type="xsd:XSDSimpleTypeDefinition"
> href=" jar:file:/D:/Projects/eclipse-projects/frevvo/workspace/com. gauss.forms/lib/org.eclipse.xsd_2.2.0.v200606271057.jar!/cac he/www.w3.org/2001/XMLSchema.xsd#//string;XSDSimpleTypeDefin ition=7 "/>
>
> ------------------------------------------------------------ --
> As you can see, the href points to a specific file (D:/....). That
> path does not exist on my machine making this file non-portable. So,
> 1) Can I make this portable? I can put the jar file in a common
> relative directory (say ../../lib, which will work on all machines for
> my application). Can I force the href to point to
> jar:file:../../lib/org.eclipse etc.
> instead of the D:/Projects?
>
> 2) How can I use a URIConverter to affect this? I know what the
> URIConverter should do but I am unable to attach my custom
> URIConverter to handle this URI. Specifically,
> MyCustomConverter.normalize(uri) is never called for this URI even
> though I have done:
> ------------------------------------------------------------ --
> resourceSet.setURIConverter (new MyCustomConverter());
> ------------------------------------------------------------ --
> Is it that this particular URI is loaded using a Resource from a
> different ResourceSet but I don't understand how to affect that.
>
> Thx,
> -Ashish


--------------090805020003010803090605
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">
Ashish,<br>
<br>
Ouch.&nbsp; That's nasty!&nbsp; The built-in schema for schemas is loaded like
this in XSDSchemaImpl:<br>
<blockquote><small>&nbsp; public static synchronized XSDSchema
getSchemaForSchema(String namespace)</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; if
(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace))</small ><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (xsdSchemaForSchema2001 == null)</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; try</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String baseURL =
XSDPlugin.INSTANCE.getBaseURL().toString();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; getMagicSchemaForSchema(namespace);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA ",
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; getGlobalResourceSet().getResource</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (URI.createURI(baseURL +
"cache/www.w3.org/2001/XMLSchema.xsd"), true);</small><br>
</blockquote>
In an Eclipse/OSGi environment this would use
"platform:/plugin/org.eclipse.xsd/" but when running standalone, it
will reference the physical jar location and then the reference will
not be portable.&nbsp; :-(<br>
<br>
I've been playing with <a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=164597">https://bugs.eclipse.org/bugs/show_bug.cgi?id=164597</a>
but have not had a chance to work on it for a while, but that could be
used (instead of a specialization of XMLHelperImpl.deresolve) to turn
the non-portable physical location into a logical URI while saving and
then you could use a URI mapping to ensure that that logical URI maps
to the right physical location.&nbsp; Another wrinkle though is that since
this schema for schema resource is in a separate resource set you'd
need to specialize ResourceSetImpl.delegatedGetResource to look in the
special resource set containing the schema for schemas. &nbsp; <br>
<br>
Probably the simplest brute force approach is to specialize
ResourceSetImpl.delegatedGetResource to look for a URI with path
/cache/www.w3.org/2001/XMLSchema.xsd, ignoring the non-portable
authority, and redirect it to return the schema for schemas's resource.<br>
<br>
<br>
Ashish Deshpande wrote:
<blockquote cite="midekpkgi$gbi$1@utils.eclipse.org" type="cite">Hi,
<br>
I am having trouble understanding URIConverter. I have a serialized
(XMI) file from a colleague with the following content (a string
XSDSimpleTypeDefinition):
<br>
------------------------------------------------------------ --
<br>
&lt;typeDefinition xsi:type="xsd:XSDSimpleTypeDefinition"
href=<a class="moz-txt-link-rfc2396E" href=" jar:file:/D:/Projects/eclipse-projects/frevvo/workspace/com. gauss.forms/lib/org.eclipse.xsd_2.2.0.v200606271057.jar!/cac he/www.w3.org/2001/XMLSchema.xsd#//string;XSDSimpleTypeDefin ition=7 ">" jar:file:/D:/Projects/eclipse-projects/frevvo/workspace/com. gauss.forms/lib/org.eclipse.xsd_2.2.0.v200606271057.jar!/cac he/www.w3.org/2001/XMLSchema.xsd#//string;XSDSimpleTypeDefin ition=7 "</a>/&gt;
<br>
------------------------------------------------------------ --
<br>
As you can see, the href points to a specific file (D:/....). That path
does not exist on my machine making this file non-portable. So,
<br>
1) Can I make this portable? I can put the jar file in a common
relative directory (say ../../lib, which will work on all machines for
my application). Can I force the href to point to
<br>
&nbsp;&nbsp;&nbsp;&nbsp;jar:<a class="moz-txt-link-freetext" href="file:../../lib/org.eclipse">file:../../lib/org.eclipse </a> etc.
<br>
instead of the D:/Projects?
<br>
<br>
2) How can I use a URIConverter to affect this? I know what the
URIConverter should do but I am unable to attach my custom URIConverter
to handle this URI. Specifically, MyCustomConverter.normalize(uri) is
never called for this URI even though I have done:
<br>
------------------------------------------------------------ --
<br>
resourceSet.setURIConverter (new MyCustomConverter());
<br>
------------------------------------------------------------ --
<br>
Is it that this particular URI is loaded using a Resource from a
different ResourceSet but I don't understand how to affect that.
<br>
<br>
Thx,
<br>
-Ashish
<br>
</blockquote>
<br>
</body>
</html>

--------------090805020003010803090605--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: URIConverter question. [message #599220 is a reply to message #70871] Mon, 04 December 2006 17:02 Go to previous message
Eclipse UserFriend
Originally posted by: ashish.deshpande.cc

Oof! Thanks Ed for your response. I will have to parse this and play
with it a little bit but I think I understand the gist of what you're
saying.
-Ashish

Ed Merks wrote:
> Ashish,
>
> Ouch. That's nasty! The built-in schema for schemas is loaded like
> this in XSDSchemaImpl:
>
> public static synchronized XSDSchema getSchemaForSchema(String
> namespace)
> {
> if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace))
> {
> if (xsdSchemaForSchema2001 == null)
> {
> try
> {
> String baseURL = XSDPlugin.INSTANCE.getBaseURL().toString();
> getMagicSchemaForSchema(namespace);
>
> getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA ",
> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
> getGlobalResourceSet().getResource
> (URI.createURI(baseURL +
> "cache/www.w3.org/2001/XMLSchema.xsd"), true);
>
> In an Eclipse/OSGi environment this would use
> "platform:/plugin/org.eclipse.xsd/" but when running standalone, it will
> reference the physical jar location and then the reference will not be
> portable. :-(
>
> I've been playing with
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=164597 but have not had a
> chance to work on it for a while, but that could be used (instead of a
> specialization of XMLHelperImpl.deresolve) to turn the non-portable
> physical location into a logical URI while saving and then you could use
> a URI mapping to ensure that that logical URI maps to the right physical
> location. Another wrinkle though is that since this schema for schema
> resource is in a separate resource set you'd need to specialize
> ResourceSetImpl.delegatedGetResource to look in the special resource set
> containing the schema for schemas.
>
> Probably the simplest brute force approach is to specialize
> ResourceSetImpl.delegatedGetResource to look for a URI with path
> /cache/www.w3.org/2001/XMLSchema.xsd, ignoring the non-portable
> authority, and redirect it to return the schema for schemas's resource.
>
>
> Ashish Deshpande wrote:
>> Hi,
>> I am having trouble understanding URIConverter. I have a serialized
>> (XMI) file from a colleague with the following content (a string
>> XSDSimpleTypeDefinition):
>> ------------------------------------------------------------ --
>> <typeDefinition xsi:type="xsd:XSDSimpleTypeDefinition"
>> href=" jar:file:/D:/Projects/eclipse-projects/frevvo/workspace/com. gauss.forms/lib/org.eclipse.xsd_2.2.0.v200606271057.jar!/cac he/www.w3.org/2001/XMLSchema.xsd#//string;XSDSimpleTypeDefin ition=7 "/>
>>
>> ------------------------------------------------------------ --
>> As you can see, the href points to a specific file (D:/....). That
>> path does not exist on my machine making this file non-portable. So,
>> 1) Can I make this portable? I can put the jar file in a common
>> relative directory (say ../../lib, which will work on all machines for
>> my application). Can I force the href to point to
>> jar:file:../../lib/org.eclipse etc.
>> instead of the D:/Projects?
>>
>> 2) How can I use a URIConverter to affect this? I know what the
>> URIConverter should do but I am unable to attach my custom
>> URIConverter to handle this URI. Specifically,
>> MyCustomConverter.normalize(uri) is never called for this URI even
>> though I have done:
>> ------------------------------------------------------------ --
>> resourceSet.setURIConverter (new MyCustomConverter());
>> ------------------------------------------------------------ --
>> Is it that this particular URI is loaded using a Resource from a
>> different ResourceSet but I don't understand how to affect that.
>>
>> Thx,
>> -Ashish
>
Re: URIConverter question. [message #599228 is a reply to message #70889] Mon, 04 December 2006 18:13 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Ashish,

I'm willing to consider making changes in XSD 2.3 that would make life
easier. For example, perhaps the URI of these special resources should
really be their physical location on the web...


Ashish Deshpande wrote:
> Oof! Thanks Ed for your response. I will have to parse this and play
> with it a little bit but I think I understand the gist of what you're
> saying.
> -Ashish
>
> Ed Merks wrote:
>> Ashish,
>>
>> Ouch. That's nasty! The built-in schema for schemas is loaded like
>> this in XSDSchemaImpl:
>>
>> public static synchronized XSDSchema getSchemaForSchema(String
>> namespace)
>> {
>> if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace))
>> {
>> if (xsdSchemaForSchema2001 == null)
>> {
>> try
>> {
>> String baseURL =
>> XSDPlugin.INSTANCE.getBaseURL().toString();
>> getMagicSchemaForSchema(namespace);
>>
>> getGlobalResourceSet().getLoadOptions().put("XSD_XML_SCHEMA ",
>> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>> getGlobalResourceSet().getResource
>> (URI.createURI(baseURL +
>> "cache/www.w3.org/2001/XMLSchema.xsd"), true);
>>
>> In an Eclipse/OSGi environment this would use
>> "platform:/plugin/org.eclipse.xsd/" but when running standalone, it
>> will reference the physical jar location and then the reference will
>> not be portable. :-(
>>
>> I've been playing with
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=164597 but have not had
>> a chance to work on it for a while, but that could be used (instead
>> of a specialization of XMLHelperImpl.deresolve) to turn the
>> non-portable physical location into a logical URI while saving and
>> then you could use a URI mapping to ensure that that logical URI maps
>> to the right physical location. Another wrinkle though is that since
>> this schema for schema resource is in a separate resource set you'd
>> need to specialize ResourceSetImpl.delegatedGetResource to look in
>> the special resource set containing the schema for schemas.
>> Probably the simplest brute force approach is to specialize
>> ResourceSetImpl.delegatedGetResource to look for a URI with path
>> /cache/www.w3.org/2001/XMLSchema.xsd, ignoring the non-portable
>> authority, and redirect it to return the schema for schemas's resource.
>>
>>
>> Ashish Deshpande wrote:
>>> Hi,
>>> I am having trouble understanding URIConverter. I have a serialized
>>> (XMI) file from a colleague with the following content (a string
>>> XSDSimpleTypeDefinition):
>>> ------------------------------------------------------------ --
>>> <typeDefinition xsi:type="xsd:XSDSimpleTypeDefinition"
>>> href=" jar:file:/D:/Projects/eclipse-projects/frevvo/workspace/com. gauss.forms/lib/org.eclipse.xsd_2.2.0.v200606271057.jar!/cac he/www.w3.org/2001/XMLSchema.xsd#//string;XSDSimpleTypeDefin ition=7 "/>
>>>
>>> ------------------------------------------------------------ --
>>> As you can see, the href points to a specific file (D:/....). That
>>> path does not exist on my machine making this file non-portable. So,
>>> 1) Can I make this portable? I can put the jar file in a common
>>> relative directory (say ../../lib, which will work on all machines
>>> for my application). Can I force the href to point to
>>> jar:file:../../lib/org.eclipse etc.
>>> instead of the D:/Projects?
>>>
>>> 2) How can I use a URIConverter to affect this? I know what the
>>> URIConverter should do but I am unable to attach my custom
>>> URIConverter to handle this URI. Specifically,
>>> MyCustomConverter.normalize(uri) is never called for this URI even
>>> though I have done:
>>> ------------------------------------------------------------ --
>>> resourceSet.setURIConverter (new MyCustomConverter());
>>> ------------------------------------------------------------ --
>>> Is it that this particular URI is loaded using a Resource from a
>>> different ResourceSet but I don't understand how to affect that.
>>>
>>> Thx,
>>> -Ashish
>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:URIConverter question.
Next Topic:annotations of schema returning null
Goto Forum:
  


Current Time: Fri Apr 19 19:35:03 GMT 2024

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

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

Back to the top