Home » Archived » XML Schema Definition (XSD) » URI converting - set resource base
|
Re: URI converting - set resource base [message #40844 is a reply to message #40810] |
Fri, 09 April 2004 12:34 |
Christian Stein Messages: 29 Registered: July 2009 |
Junior Member |
|
|
On Fri, 09 Apr 2004 12:49:38 +0200, Christian Stein <sormuras@web.de>
wrote:
> Hello NewsGroup (aka Ed...)!
>
> is it possible to set a resource base which is prepended
> to all *relative* schemaLocation tag values that *do not*
> start with "./"?
>
> The simple solution
>
> map.put(URI.createURI("./"), URI.createURI("./my/folder/"));
>
> does not always work here, as some schemaLocations just
> contain the simple file name. A possible solution could be a
> directory change to where the root schema is located. But,
> AFAIK, you can't change users' current directory "user.dir"...
>
I use this work-around(?) for now:
// String name = "main2.xsd";
// String name = "folder/textmain2.xsd";
// String name = "/my/folder/textmain2.xsd";
String name = "my/folder/textmain2.xsd";
java.io.File file = new java.io.File(name).getAbsoluteFile();
System.setProperty("user.dir", file.getParent());
set.getResource(URI.createURI(file.getName()), true);
This only works, because XSD uses System.getProperty("user.dir") or
a similiar "magic". As long it does, that's ok for me...
Sorry for bothering,
Christian
--
Still learning Java basics after 6 years... ;)
|
|
|
Re: URI converting - set resource base [message #40969 is a reply to message #40844] |
Mon, 12 April 2004 10:52 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Christian,
I'm not sure exactly what you are doing, but you can always override the
resource set's URI converter's normalize method to do additional funky
stuff. Just be aware that relative schema locations within documents,
i.e., in an include's or import's schemaLocation, typically need to be
resolved against the absolute location of the containing schema and if
that location isn't an absolute URI, resolve isn't well defined. It's
really best to ensure that each resource URI is absolute.
If you want things to be "relocatable" I would suggest something like:
map.put(URI.createURI("pathmap://base-location/",
"c:/actual-location/");
and using absolute URI's of the form "pathmap://base-location/..." for
the resources...
Christian Stein wrote:
> On Fri, 09 Apr 2004 12:49:38 +0200, Christian Stein <sormuras@web.de>
> wrote:
>
> > Hello NewsGroup (aka Ed...)!
> >
> > is it possible to set a resource base which is prepended
> > to all *relative* schemaLocation tag values that *do not*
> > start with "./"?
> >
> > The simple solution
> >
> > map.put(URI.createURI("./"), URI.createURI("./my/folder/"));
> >
> > does not always work here, as some schemaLocations just
> > contain the simple file name. A possible solution could be a
> > directory change to where the root schema is located. But,
> > AFAIK, you can't change users' current directory "user.dir"...
> >
>
> I use this work-around(?) for now:
>
> // String name = "main2.xsd";
> // String name = "folder/textmain2.xsd";
> // String name = "/my/folder/textmain2.xsd";
>
> String name = "my/folder/textmain2.xsd";
>
> java.io.File file = new java.io.File(name).getAbsoluteFile();
>
> System.setProperty("user.dir", file.getParent());
>
> set.getResource(URI.createURI(file.getName()), true);
>
> This only works, because XSD uses System.getProperty("user.dir") or
> a similiar "magic". As long it does, that's ok for me...
>
> Sorry for bothering,
> Christian
>
> --
>
> Still learning Java basics after 6 years... ;)
|
|
|
Re: URI converting - set resource base [message #585272 is a reply to message #40810] |
Fri, 09 April 2004 12:34 |
Christian Stein Messages: 29 Registered: July 2009 |
Junior Member |
|
|
On Fri, 09 Apr 2004 12:49:38 +0200, Christian Stein <sormuras@web.de>
wrote:
> Hello NewsGroup (aka Ed...)!
>
> is it possible to set a resource base which is prepended
> to all *relative* schemaLocation tag values that *do not*
> start with "./"?
>
> The simple solution
>
> map.put(URI.createURI("./"), URI.createURI("./my/folder/"));
>
> does not always work here, as some schemaLocations just
> contain the simple file name. A possible solution could be a
> directory change to where the root schema is located. But,
> AFAIK, you can't change users' current directory "user.dir"...
>
I use this work-around(?) for now:
// String name = "main2.xsd";
// String name = "folder/textmain2.xsd";
// String name = "/my/folder/textmain2.xsd";
String name = "my/folder/textmain2.xsd";
java.io.File file = new java.io.File(name).getAbsoluteFile();
System.setProperty("user.dir", file.getParent());
set.getResource(URI.createURI(file.getName()), true);
This only works, because XSD uses System.getProperty("user.dir") or
a similiar "magic". As long it does, that's ok for me...
Sorry for bothering,
Christian
--
Still learning Java basics after 6 years... ;)
|
|
|
Re: URI converting - set resource base [message #585352 is a reply to message #40844] |
Mon, 12 April 2004 10:52 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
Christian,
I'm not sure exactly what you are doing, but you can always override the
resource set's URI converter's normalize method to do additional funky
stuff. Just be aware that relative schema locations within documents,
i.e., in an include's or import's schemaLocation, typically need to be
resolved against the absolute location of the containing schema and if
that location isn't an absolute URI, resolve isn't well defined. It's
really best to ensure that each resource URI is absolute.
If you want things to be "relocatable" I would suggest something like:
map.put(URI.createURI("pathmap://base-location/",
"c:/actual-location/");
and using absolute URI's of the form "pathmap://base-location/.." for
the resources...
Christian Stein wrote:
> On Fri, 09 Apr 2004 12:49:38 +0200, Christian Stein <sormuras@web.de>
> wrote:
>
> > Hello NewsGroup (aka Ed...)!
> >
> > is it possible to set a resource base which is prepended
> > to all *relative* schemaLocation tag values that *do not*
> > start with "./"?
> >
> > The simple solution
> >
> > map.put(URI.createURI("./"), URI.createURI("./my/folder/"));
> >
> > does not always work here, as some schemaLocations just
> > contain the simple file name. A possible solution could be a
> > directory change to where the root schema is located. But,
> > AFAIK, you can't change users' current directory "user.dir"...
> >
>
> I use this work-around(?) for now:
>
> // String name = "main2.xsd";
> // String name = "folder/textmain2.xsd";
> // String name = "/my/folder/textmain2.xsd";
>
> String name = "my/folder/textmain2.xsd";
>
> java.io.File file = new java.io.File(name).getAbsoluteFile();
>
> System.setProperty("user.dir", file.getParent());
>
> set.getResource(URI.createURI(file.getName()), true);
>
> This only works, because XSD uses System.getProperty("user.dir") or
> a similiar "magic". As long it does, that's ok for me...
>
> Sorry for bothering,
> Christian
>
> --
>
> Still learning Java basics after 6 years... ;)
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Fri Apr 19 21:12:56 GMT 2024
Powered by FUDForum. Page generated in 0.03930 seconds
|