Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » How to copy XSDSchema object
How to copy XSDSchema object [message #77985] Wed, 01 July 2009 16:06 Go to next message
Marcin Cylke is currently offline Marcin Cylke
Messages: 61
Registered: July 2009
Member
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 #78002 is a reply to message #77985] Thu, 02 July 2009 06:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25938
Registered: July 2009
Senior Member
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
>
Re: How to copy XSDSchema object [message #78018 is a reply to message #78002] Thu, 02 July 2009 08:59 Go to previous message
Marcin Cylke is currently offline Marcin Cylke
Messages: 61
Registered: July 2009
Member
Ok, thanks for your answer, I'll rework that class.

Marcin
Re: How to copy XSDSchema object [message #604264 is a reply to message #77985] Thu, 02 July 2009 06:56 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25938
Registered: July 2009
Senior Member
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
>
Re: How to copy XSDSchema object [message #604270 is a reply to message #78002] Thu, 02 July 2009 08:59 Go to previous message
Marcin Cylke is currently offline Marcin Cylke
Messages: 61
Registered: July 2009
Member
Ok, thanks for your answer, I'll rework that class.

Marcin
Previous Topic:How to copy XSDSchema object
Next Topic:XSDSimpleTypeDefinition::facetContents not sortable?
Goto Forum:
  


Current Time: Tue Jul 29 06:49:22 EDT 2014

Powered by FUDForum. Page generated in 0.02700 seconds