Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Some Basic Qs
Some Basic Qs [message #62730] Tue, 09 August 2005 15:26 Go to next message
Eclipse UserFriend
Originally posted by: gsounds.infotec.de

I'm a newbie to XSD and have some questions:

1.
I have an XML Schema document that I want to parse and extract data from,
e.g. What is the root element, List all the complex types, What time is
the simply type X, etc....

Is XSD the only way to go about this, or is it possible to achieve this by
using DOM alone or using some other method?


2.
Using XSD, you can retrieve the XSDSchema as follows:
XSDSchema xsdSchema = xsdResource.getSchema();

Is it possible to access the DOMTree as you would with a regular XML file
(e.g. using element.getChildNodes() etc..), or do you have to go down the
route of XSDParticles and XSDElementDeclarations.


3.
I've been reading about 'concrete' and 'abstract'. What exactly is the
difference and what impact does this have if I only want to access the
data from the schema and not actually modify it.


Ultimately, what I want to do is extract data from the Schema, so that I
can generate a basic XML doc. What is the relation between the DOM tree
that XSD builds to represent a schema and a DOM tree that models an XML
file instance that is valid according to the aforementioned schema.




I understand that these are basic questions, but I appreciate your
patience and helping me to start off.

Gary
Re: Some Basic Qs [message #62754 is a reply to message #62730] Tue, 09 August 2005 18:47 Go to previous message
Elena Litani is currently offline Elena LitaniFriend
Messages: 18
Registered: July 2009
Junior Member
Hi,

> I have an XML Schema document that I want to parse and extract data from,
> e.g. What is the root element, List all the complex types, What time is
> the simply type X, etc....
>
> Is XSD the only way to go about this, or is it possible to achieve this by
> using DOM alone or using some other method?

While it is possible to do it with DOM it is not practical. For example, if
your complex type has reference to global element declaration, the DOM will
only give you name and you will have to resolve it yourself - with XSD you
get the reference right away. It becomes even more complicated when your
schemas have <include>, <import>, <redefine>, and other schema components
that require some kind of computation and resolution. XSD does it all for
you -- you have XML Schema component model in memory which can be easily
queried.


> 2.
> Using XSD, you can retrieve the XSDSchema as follows:
> XSDSchema xsdSchema = xsdResource.getSchema();
>
> Is it possible to access the DOMTree as you would with a regular XML file
> (e.g. using element.getChildNodes() etc..), or do you have to go down the
> route of XSDParticles and XSDElementDeclarations.

The XSD model supports both a syntactic view of the schema as well as the
abstract component model defined in the XML Schema specification. For
example, XSDSchema.getContents() will get you what's physically in the
schema whereas something like XSDSchema.getElementDeclarations will get you
all the elements logically part of the schema (via includes and imports).
So in the end it is up to you how you traverse the model - it could be
either using syntax structure and then you might perform additional
calculations to resolve components, or using abstract component model - in
this case all elements are resolved.

> 3.
> I've been reading about 'concrete' and 'abstract'. What exactly is the
> difference and what impact does this have if I only want to access the
> data from the schema and not actually modify it.

I believe concrete refers to syntactic view and abstract refers to abstract
component model defined in the XML Schema specification.


> Ultimately, what I want to do is extract data from the Schema, so that I
> can generate a basic XML doc. What is the relation between the DOM tree
> that XSD builds to represent a schema and a DOM tree that models an XML
> file instance that is valid according to the aforementioned schema.

As I said above, imports, includes and other components are not resolved in
DOM. You would need to add lots of special handling, for example, to make
sure that you for example retrieve all elements allowed as content of a
complex type if this complex type restricts or extends another complex type.

Thank you,
Elena.
Re: Some Basic Qs [message #596206 is a reply to message #62730] Tue, 09 August 2005 18:47 Go to previous message
Elena Litani is currently offline Elena LitaniFriend
Messages: 18
Registered: July 2009
Junior Member
Hi,

> I have an XML Schema document that I want to parse and extract data from,
> e.g. What is the root element, List all the complex types, What time is
> the simply type X, etc....
>
> Is XSD the only way to go about this, or is it possible to achieve this by
> using DOM alone or using some other method?

While it is possible to do it with DOM it is not practical. For example, if
your complex type has reference to global element declaration, the DOM will
only give you name and you will have to resolve it yourself - with XSD you
get the reference right away. It becomes even more complicated when your
schemas have <include>, <import>, <redefine>, and other schema components
that require some kind of computation and resolution. XSD does it all for
you -- you have XML Schema component model in memory which can be easily
queried.


> 2.
> Using XSD, you can retrieve the XSDSchema as follows:
> XSDSchema xsdSchema = xsdResource.getSchema();
>
> Is it possible to access the DOMTree as you would with a regular XML file
> (e.g. using element.getChildNodes() etc..), or do you have to go down the
> route of XSDParticles and XSDElementDeclarations.

The XSD model supports both a syntactic view of the schema as well as the
abstract component model defined in the XML Schema specification. For
example, XSDSchema.getContents() will get you what's physically in the
schema whereas something like XSDSchema.getElementDeclarations will get you
all the elements logically part of the schema (via includes and imports).
So in the end it is up to you how you traverse the model - it could be
either using syntax structure and then you might perform additional
calculations to resolve components, or using abstract component model - in
this case all elements are resolved.

> 3.
> I've been reading about 'concrete' and 'abstract'. What exactly is the
> difference and what impact does this have if I only want to access the
> data from the schema and not actually modify it.

I believe concrete refers to syntactic view and abstract refers to abstract
component model defined in the XML Schema specification.


> Ultimately, what I want to do is extract data from the Schema, so that I
> can generate a basic XML doc. What is the relation between the DOM tree
> that XSD builds to represent a schema and a DOM tree that models an XML
> file instance that is valid according to the aforementioned schema.

As I said above, imports, includes and other components are not resolved in
DOM. You would need to add lots of special handling, for example, to make
sure that you for example retrieve all elements allowed as content of a
complex type if this complex type restricts or extends another complex type.

Thank you,
Elena.
Previous Topic:Some Basic Qs
Next Topic:finding enclosed type of soap-encoded arrays
Goto Forum:
  


Current Time: Wed Apr 24 22:55:28 GMT 2024

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

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

Back to the top