Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » why isn't element declaration given "anyType" type by default
why isn't element declaration given "anyType" type by default [message #65545] Fri, 23 December 2005 21:05 Go to next message
Eclipse User
Originally posted by: seely_place.yahoo.com

Hi,

I am using a schema which includes an element without a type (which
should therefore default to xsd:anyType). For example:

<xsd:element name="foo"/>

However, if I create a schema using the following code,
I get a null typeDefinition for this element declaration.

XSDParser xsdp = new XSDParser();
xsdp.parse(new ByteArrayInputStream(bytes));
XSDSchema xsdSchema = xsdp.getSchema();
List elems = xsdSchema.getElementDeclarations();
XSDTypeDefinition typeDefinition =
elems.get(0).getTypeDefinition();

The only time I get "anyType" is if I set the schemaLocation. This seems
odd.
If I create the schema using the XSDParser, and the schema doesn't have any
include/import/redefine directives, am I really required to set the
schemaLocation (with a bogus value) just to get this to work?

Regards,
Seely.
Re: why isn't element declaration given "anyType" type by default [message #65566 is a reply to message #65545] Sat, 24 December 2005 05:46 Go to previous message
Eclipse User
Originally posted by: merks.ca.ibm.com

Seely,

Yes, you need to set a schema location, or more generally put the schema
in a resource in a resource set, before the schema is considered
complete enough to do a full type analysis. Doing a full analysis is
expensive and it will tend to be incomplete unless names can all
resolve, which will tend not to be the case until the context is
complete. To write code that handles any schema in general, it's best
to assume that there will be external dependencies in it.


Seely Place wrote:

> Hi,
>
> I am using a schema which includes an element without a type (which
> should therefore default to xsd:anyType). For example:
>
> <xsd:element name="foo"/>
>
> However, if I create a schema using the following code,
> I get a null typeDefinition for this element declaration.
>
> XSDParser xsdp = new XSDParser();
> xsdp.parse(new ByteArrayInputStream(bytes));
> XSDSchema xsdSchema = xsdp.getSchema();
> List elems = xsdSchema.getElementDeclarations();
> XSDTypeDefinition typeDefinition =
> elems.get(0).getTypeDefinition();
>
> The only time I get "anyType" is if I set the schemaLocation. This
> seems odd.
> If I create the schema using the XSDParser, and the schema doesn't
> have any
> include/import/redefine directives, am I really required to set the
> schemaLocation (with a bogus value) just to get this to work?
>
> Regards,
> Seely.
>
Re: why isn't element declaration given "anyType" type by default [message #597395 is a reply to message #65545] Sat, 24 December 2005 05:46 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25950
Registered: July 2009
Senior Member
Seely,

Yes, you need to set a schema location, or more generally put the schema
in a resource in a resource set, before the schema is considered
complete enough to do a full type analysis. Doing a full analysis is
expensive and it will tend to be incomplete unless names can all
resolve, which will tend not to be the case until the context is
complete. To write code that handles any schema in general, it's best
to assume that there will be external dependencies in it.


Seely Place wrote:

> Hi,
>
> I am using a schema which includes an element without a type (which
> should therefore default to xsd:anyType). For example:
>
> <xsd:element name="foo"/>
>
> However, if I create a schema using the following code,
> I get a null typeDefinition for this element declaration.
>
> XSDParser xsdp = new XSDParser();
> xsdp.parse(new ByteArrayInputStream(bytes));
> XSDSchema xsdSchema = xsdp.getSchema();
> List elems = xsdSchema.getElementDeclarations();
> XSDTypeDefinition typeDefinition =
> elems.get(0).getTypeDefinition();
>
> The only time I get "anyType" is if I set the schemaLocation. This
> seems odd.
> If I create the schema using the XSDParser, and the schema doesn't
> have any
> include/import/redefine directives, am I really required to set the
> schemaLocation (with a bogus value) just to get this to work?
>
> Regards,
> Seely.
>
Previous Topic:why isn't element declaration given "anyType" type by default
Next Topic:XSDWildcard distingishing between an actual xs:any and an implied any
Goto Forum:
  


Current Time: Fri Aug 01 22:25:03 EDT 2014

Powered by FUDForum. Page generated in 0.01729 seconds