Experience with XML Schema Ashok Malhotra

15

description

Experience with XML Schema Ashok Malhotra. Schema Usage. Mapping XML Schema and XML documents controlled by the Schema to object classes and instances. Storing XML Schemas and documents in the database. Mapping XML Schema to Object Classes. Choice Derivation by Restriction Facets - PowerPoint PPT Presentation

Transcript of Experience with XML Schema Ashok Malhotra

Page 1: Experience with XML Schema  Ashok Malhotra
Page 2: Experience with XML Schema  Ashok Malhotra

Experience with XML Schema

Ashok Malhotra

Page 3: Experience with XML Schema  Ashok Malhotra

Schema Usage

Mapping XML Schema and XML documents controlled by the Schema to object classes and instances.

Storing XML Schemas and documents in the database.

Page 4: Experience with XML Schema  Ashok Malhotra

Mapping XML Schema to Object Classes

Choice

Derivation by Restriction

Facets

Derivation Control

Namespace Restrictions

Problems with Annotations

Page 5: Experience with XML Schema  Ashok Malhotra

Mapping XML Schema to Object Classes - Choice

Choice allows variations in the content of an object.

No equivalent construct in Java.

Some languages support variant classes.

Page 6: Experience with XML Schema  Ashok Malhotra

Mapping XML Schema to Object Classes

Derivation by restriction has no object-oriented equivalent.

In the database, a restricted type is mapped to a dummy subtype with no additional fields. Restriction not enforced at SQL level.

Similarly, for datatypes, facets have no object-oriented equivalent.

Must be checked at runtime.

Page 7: Experience with XML Schema  Ashok Malhotra

Mapping XML Schema to Object Classes – fixed, final, block, etc.

Fixed and final restrict derivation from elements.

Block restricts use of derived types where the parent type is expected.

Only final #all has a Java equivalent.

Page 8: Experience with XML Schema  Ashok Malhotra

Mapping XML Schema to Object Classes – wildcard restrictions

Wildcards can be restricted to elements from a specific namespace.

No equivalent object-oriented concept.<complexType name=“test">

<sequence> <any namespace="http://www.example.org"/> </sequence> </complexType>

</complexType>

Page 9: Experience with XML Schema  Ashok Malhotra

Mapping XML Schema to Object Classes – problems with annotations

Can an annotation be added to a “ref” ?

If so, does it take precedence over an annotation of the entity referred to?

We assume annotations can be applied to a ‘ref’, and …

The annotation element on an attribute ref is associated with {Attribute Use}.

The annotation element on a model group ref or an element ref is associated with the {particle}.

Page 10: Experience with XML Schema  Ashok Malhotra

Managing XML Schemas and documents in the database

Support is provided for the following tasks:

– Registering XML Schemas. – Validating XML documents against a registered XML

Schema. – Generating XML Schema from object classes. – Generating a structured database mapping from XML

Schemas during XML Schema registration. This includes generating SQL object types, collection types, and default tables, and capturing the mapping information using special attributes.

– Performing manipulation (DML) and queries on XML Schema-based XMLType tables.

– Automatically inserting data into default tables when schema-based XML instances are inserted into Oracle XML DB repository using FTP, HTTP/WebDAV protocols and other languages.

Page 11: Experience with XML Schema  Ashok Malhotra

Managing XML Schemas and documents in the database – Substitution groups

Instance data is stored in a column/table corresponding to the head element.

Additional information includes the actual element type.

Also includes, namespace prefixes, comments, PIs.

Page 12: Experience with XML Schema  Ashok Malhotra

Managing XML Schemas and documents in the database – non-SQL datatypes

Datatypes that cannot be represented in SQL are mapped to a VARCHAR2 column.

This is also on option for datatypes that do map cleanly to SQL types e.g. integer.

Schema annotation can be used to specify storage option.

Page 13: Experience with XML Schema  Ashok Malhotra

Managing XML Schemas and documents in the database – key/keyref

Not enforced at SQL level but at the XML level.

Key/keyref apply within a document whereas, in most cases, such constraints are useful over a document collection.

Page 14: Experience with XML Schema  Ashok Malhotra

Managing XML Schemas and documents in the database – wildcard with namespace exclusion

Cannot define a wildcard that allows elements not in a specified namespace and also allows the null namespace.

Needed to add proprietary extensions to handle this case.

Page 15: Experience with XML Schema  Ashok Malhotra

Managing XML Schemas and documents in the database – redefine

Redefine is the only XML Schema feature not supported.

No customer has asked for this, yet!