How to copy XSDSchema object [message #77985] |
Wed, 01 July 2009 16:06  |
Eclipse User |
|
|
|
Hello
What I'm trying to achieve is create a class extending XSDSchema and put
some convenience functions in it. I want to have my own interface to
XSDSchema object. This part is done, but I have a hard time loading
content into such object.
Normaly I would do:
XSDParser xsdParser1 = new XSDParser(null);
xsdParser1.parse(uri);
XSDSchema schm = xsdParser1.getSchema();
But since I want to pack that schema into my own object how should I do
this?
I tried extending XSDParser to return my object when getSchema() is
called, but it just doesn't work - it returns empty XSDSchema.
It would suffice to copy one schema to another, since my object is
XSDSchema object on steroids ;-)
Do you have any ideas about this kind of problem?
Marcin
|
|
|
|
|
Re: How to copy XSDSchema object [message #604264 is a reply to message #77985] |
Thu, 02 July 2009 06:56  |
Eclipse User |
|
|
|
Marcin,
Comments below.
Marcin Cylke wrote:
> Hello
>
> What I'm trying to achieve is create a class extending XSDSchema and
> put some convenience functions in it.
That sounds like a bad idea.
> I want to have my own interface to XSDSchema object. This part is
> done, but I have a hard time loading content into such object.
> Normaly I would do:
> XSDParser xsdParser1 = new XSDParser(null);
You should load schemas using an XSDResourceImpl, not this way.
> xsdParser1.parse(uri);
> XSDSchema schm = xsdParser1.getSchema();
>
> But since I want to pack that schema into my own object how should I
> do this?
You should not want to do that. It's a bad idea and you already see
why. You can't ensure that the rest of the framework will create
instances of your derived class.
>
> I tried extending XSDParser to return my object when getSchema() is
> called, but it just doesn't work - it returns empty XSDSchema.
>
> It would suffice to copy one schema to another, since my object is
> XSDSchema object on steroids ;-)
Even the XML Schema specification makes the schema definition final, so
again, it's a really bad idea.
>
> Do you have any ideas about this kind of problem?
Yes, avoid it completely. Put your convenience functions in a
convenient separate class.
>
> Marcin
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.29074 seconds