Search the web
Sign In
New User? Sign Up
metal-dev · MetaL Development
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
XSD schema   Message List  
Reply | Forward Message #492 of 553 |
I've been working on an XSD schema for the configuration, so that my
xml editor can do auto-completion and friendly structured editing/
validation. I've had to modify my copy of xml_parser.php to ignore
attributes since it rejects the declaration saying "Simplified XML
can not have attributes in tags".

Hopefully this idea of te XSD schema is something people will like
and you'll maintain it, or at least make it allowable to use the
schema in your xml.

Example usage:

<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://
www.w3.org/2001/XMLSchema ../../MetaL/metastorage/component.xsd ">


The XSD:


<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" xmlns="http://www.w3.org/2001/
XMLSchema">

<element name="component" type="componentDef"></element>


<complexType name="componentDef">
<sequence>
<element name="name" type="string" maxOccurs="1"
minOccurs="1">
</element>
<element name="description" type="string" maxOccurs="1"
minOccurs="0">
</element>
<element name="component" type="componentRef"
maxOccurs="unbounded" minOccurs="0">
</element>
<element name="class" type="classDef" maxOccurs="unbounded"
minOccurs="0">
</element>
<element name="factory" type="factoryDef" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
The object factory class is a special purpose class
that is meant to create new objects from scratch or
retrieve them from the persistence container.

For each component, there should be only one
factory
class. Like the data classes, the factory class may
also have customizable functions defined in a
similar
way. The only function definition attributes that
are
different are the function types and their
parameters.

The currently supported factory class function
types
are: createobject, custom, finishtransaction,
getallobjects, getobject and starttransaction.
</documentation>
</annotation>
</element>
<element name="schema" type="schemaDef" maxOccurs="1"
minOccurs="0">
</element>
</sequence>
</complexType>



<complexType name="classDef">
<sequence>
<element name="id" type="string" maxOccurs="1"
minOccurs="0">
</element>
<element name="name" type="string" maxOccurs="1"
minOccurs="1">
</element>
<element name="variable" type="variableDef"
maxOccurs="unbounded" minOccurs="0">
</element>
<element name="collection" type="classCollectionDef"
maxOccurs="unbounded" minOccurs="0">
<annotation>
<documentation>
(Optional) The relation between the objects of a
class with a group of objects of the same or
other
class is specified as a collection. A class may
specify one or more collections using separate
sections for each.
</documentation>
</annotation>
</element>
<element name="validation" type="classValidationDef"
maxOccurs="unbounded" minOccurs="0">
<annotation>
<documentation>
(Optional) Each class may have defined a set of
validation rules to determine the consistency of
the data hold in its objects.
</documentation>
</annotation>
</element>
<element name="function" type="factoryFunctionDef"
maxOccurs="unbounded" minOccurs="0"></element>
</sequence>
</complexType>

<complexType name="componentRef">
<sequence>
<element name="name" type="string" maxOccurs="1"
minOccurs="1"></element>
<element name="file" type="string" maxOccurs="1"
minOccurs="1"></element>
</sequence>
</complexType>


<complexType name="variableDef">
<sequence>
<element name="name" type="string" maxOccurs="1"
minOccurs="1">
</element>
<element name="was" type="string" maxOccurs="1"
minOccurs="0"></element>
<element name="type" maxOccurs="1" minOccurs="0">
<annotation>
<documentation>
(Required alternative) Each variable must be of a
type. The type must be either a basic data type
or
a reference to a object of the same or another
class. The type tag is used to specify the basic
data type of a variable. Supported basic data
types
are: text, integer, boolean, float, decimal,
date,
time and timestamp.
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="text"></enumeration>
<enumeration value="integer"></enumeration>
<enumeration value="boolean"></enumeration>
<enumeration value="float"></enumeration>
<enumeration value="decimal"></enumeration>
<enumeration value="date"></enumeration>
<enumeration value="time"></enumeration>
<enumeration value="timestamp"></enumeration>
</restriction>
</simpleType>
</element>
<element name="initialvalue" type="string" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
A variable of a basic data type may have an initial
value. That value is automatically assigned to the
variable when the object is created.

Also, when a new basic data type variable is added
to
a class, the initial value is automatically stored
in
the variable for all the previously persisted
objects. This is not the case for large data
variables.

The initialvalue tag is used to specify the initial
value of a variable.
</documentation>
</annotation>
</element>
<element name="length" type="int" maxOccurs="1"
minOccurs="0">
</element>
<element name="multiline" type="boolean" maxOccurs="1"
minOccurs="0">
</element>
<element name="binary" type="boolean" maxOccurs="1"
minOccurs="0">
</element>
<element name="autocreate" type="string" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
A variable may be set to be initialized
automatically
with a special value using the autocreate attribute
tag. This attribute determines that the variable
will
be created with an automatic initial value and will
never be changed in subsequent updates of the
object
done using a class persist type function.

Alternatively, a variable may be set to be
initialized and updated automatically with a
special
value using the autoupdate attribute tag. This
attribute determines that the variable will be set
with an automatic value every time the object is
updated using a class persist type function,
including when the object is created and stored for
the first time.

Either autocreate and autoupdate variables may not
be
changed directly by the applications access the
objects of their classes.

Currently, only the variables of the types date,
time
and timestamp may be defined as autocreate or
autoupdate. The values of either of these
attributes
may be either localdate and utcdate for date
variables, and localtime and utctime for time or
timestamp variables. localdate and localtime
represent the current date and time in the local
time
zone and utcdate and utctime represent the current
date and time in the UTC (Universal Time) time
zone.
</documentation>
</annotation>
</element>
<element name="autoupdate" type="string" maxOccurs="1"
minOccurs="0">
</element>
<element name="class" type="string" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
(Required alternative) Variables may contain
references to objects of the same or other classes.
The class tag is used to specify the class of
object
reference variable. This attribute must contain the
name of a class specified in the same component
definition or in from another component specified
by
the component attribute.
</documentation>
</annotation>
</element>
<element name="component" type="string" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
A variable may contain a reference to an object of
a
class of another component. The component tag is
used
to specify the external component that defines the
reference class. The specified external component
must be previously declared in the current
component
definition.
</documentation>
</annotation>
</element>
</sequence>
</complexType>

<complexType name="classCollectionDef">
<sequence>
<element name="name" type="string" maxOccurs="1"
minOccurs="1">
<annotation>
<documentation>
(Required) Each collection must have a unique name
that may not be the same as of any variables of the
class.
</documentation>
</annotation>
</element>
<element name="was" type="string" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
(Required when renaming a collection) The was
tag
must be used to specify the previous name of a
collection when it is renamed.
</documentation>
</annotation>
</element>
<element name="class" type="string" maxOccurs="1"
minOccurs="1">
<annotation>
<documentation>
(Required) A collection references objects a of
a
specified class.
</documentation>
</annotation>
</element>
<element name="component" type="string" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
A collection may contain objects of a class of
another component. The component tag is used to
specify the external component that defines the
collection class. The specified external
component
must be previously declared in the current
component definition.
</documentation>
</annotation>
</element>
<element name="reference" type="string" maxOccurs="1"
minOccurs="1">
<annotation>
<documentation>
(Required) A collection reference specifies a
variable or another collection of the referenced
class.
</documentation>
</annotation></element>
</sequence>
</complexType>

<complexType name="classValidationDef">
<sequence>
<element name="type" type="string" maxOccurs="1"
minOccurs="1">
<annotation>
<documentation>
(Required) Each validation must be of a specific
type. Currently the types of validation that are
supported are: notempty and unique.
</documentation>
</annotation>
</element>
<element name="errorcode" type="string" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
(Optional) A class may verify several types of
validation rules at once. If one validation rule
does
not verify, applications may need to know which
rule
has failed. An errorcode maybe associated with each
validation rule to let applications act upon the
rule
that failed.
</documentation>
</annotation>
</element>
<element name="parameters"
type="classValidationParametersDef" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
(Required depending on rule type) Each type of
validation may need additional parameters that
define the details of the scope of the
validation.

notempty rule

The notempty validation verifies that one or
more
text specified class variables are set to a non
empty string.

The validation specific parameters consist of
the
list of variables specified using the variable
tag
for each variable to be checked.

unique rule

The unique validation verifies that there is no
other stored object with the same combination of
values of a group of class variables of a given
object.

The validation specific parameters consist of
the
list of variables specified using the variable
tag
with the combination of values to be verified as
unique.
</documentation>
</annotation>
</element>
</sequence>
</complexType>

<complexType name="classFunctionDef">
<sequence>
<element name="name" type="string" maxOccurs="1"
minOccurs="1">
</element>
<element name="type" maxOccurs="1" minOccurs="1">
<annotation>
<documentation>
(Required) Each data class function is of a
specified
type defined according to the function purpose.
Currently the types of functions that are supported
are: addtocollection, delete, custom,
getcollection,
getlargedata, getreference, persist,
removefromcollection, setlargedata, setreference
and
validate.
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="addtocollection"></enumeration>
<enumeration value="delete"></enumeration>
<enumeration value="custom"></enumeration>
<enumeration value="getcollection"></enumeration>
<enumeration value="getlargedata"></enumeration>
<enumeration value="getreference"></enumeration>
<enumeration value="persist"></enumeration>
<enumeration value="removefromcollection"></
enumeration>
<enumeration value="setlargedata"></enumeration>
<enumeration value="setreference"></enumeration>
<enumeration value="validate"></enumeration>
</restriction>
</simpleType>
</element>
<element name="argument" type="classFunctionArgumentDef"
maxOccurs="unbounded" minOccurs="0">
<annotation>
<documentation>
(Optional) Some types of function may take
additional
arguments that can be used to configure details of
the function behavior using values that are only be
defined at run time by the application that calls
the
function.

This is the case for instance of functions that
search for objects of a given class may take
arguments that define values that can be used in a
filter condition parameters.

A class function may have multiple custom
arguments.
If there are arguments that were defined but
actually
are not used in the function, probably because they
were forgotten or for some other type of mistake,
Metastorage fails specifying which argument was
left
unused.

Each argument is defined separately in sections
that
start with the tag argument. The argument details
are
defined inside the respective section.
</documentation>
</annotation>
</element>
<element name="parameters"
type="classFunctionParametersDef"></element>
</sequence>
</complexType>

<complexType name="autofunction"></complexType>

<complexType name="classValidationParametersDef"></complexType>



<complexType name="classFunctionArgumentDef">
<sequence>
<element name="name" type="string" maxOccurs="1"
minOccurs="1">
</element>
<element name="type" maxOccurs="1" minOccurs="0">
<annotation>
<documentation>
The type of the argument is also a required
parameter
when the argument type is scalar or an array or an
hash table. Currently supported scalar argument
types
are: integer, text, float, decimal, boolean, time,
date, timestamp, array and hashtable.
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="integer"></enumeration>
<enumeration value="text"></enumeration>
<enumeration value="float"></enumeration>
<enumeration value="decimal"></enumeration>
<enumeration value="boolean"></enumeration>
<enumeration value="time"></enumeration>
<enumeration value="date"></enumeration>
<enumeration value="timestamp"></enumeration>
<enumeration value="array"></enumeration>
<enumeration value="hashtable"></enumeration>
</restriction>
</simpleType>
</element>
<element name="class" type="string" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
An argument may also be a reference to an object.
The
class parameter specifies the name of a class of
the
object argument.
</documentation>
</annotation>
</element>
<element name="oid" type="string" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
An object argument may also be passed by using its
object identifier value (oid). For object arguments
of classes with an implicit oid, the argument is an
integer number usually stored in the id class
variable. An object identifier arguments is
specified
using an empty oid parameter.
</documentation>
</annotation>
</element>
<element name="component" type="string" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
An argument may be an object of a class defined in
an
external component definition. The component
parameter specifies the name of the external
component on which the object class is defined.
</documentation>
</annotation>
</element>
</sequence>
</complexType>

<complexType name="classFunctionParametersDef">
<sequence>
<element name="collection" type="string" maxOccurs="1"
minOccurs="0">
</element>
<element name="object"
type="classFunctionParametersObjectDef"
maxOccurs="1" minOccurs="0">
</element>
<element name="do" type="string" maxOccurs="1"
minOccurs="0">
<annotation>
<documentation>
Custom code for a "custom" type function.
</documentation>
</annotation>
</element>
<element name="return"
type="classFunctionParametersReturnDef"
maxOccurs="1" minOccurs="0">
</element>
<element name="class" type="string" maxOccurs="1"
minOccurs="0">
</element>
<element name="id" type="classFunctionParametersIdDef"
maxOccurs="1" minOccurs="0"></element>
</sequence>
</complexType>

<complexType name="classFunctionParametersObjectDef">
<sequence>
<element name="argument" type="string" maxOccurs="1"
minOccurs="0"></element>
</sequence>
</complexType>

<complexType name="classFunctionParametersReturnDef">
<sequence>
<element name="type" maxOccurs="1" minOccurs="0">
<simpleType>
<restriction base="string">
<enumeration value="integer"></enumeration>
<enumeration value="text"></enumeration>
<enumeration value="float"></enumeration>
<enumeration value="decimal"></enumeration>
<enumeration value="boolean"></enumeration>
<enumeration value="time"></enumeration>
<enumeration value="date"></enumeration>
<enumeration value="timestamp"></enumeration>
<enumeration value="array"></enumeration>
<enumeration value="hashtable"></enumeration>
</restriction>
</simpleType>
</element>
<element name="class" type="string" maxOccurs="1"
minOccurs="0">
</element>
<element name="oid" type="string" maxOccurs="1"
minOccurs="0">
</element>
<element name="component" type="string" maxOccurs="1"
minOccurs="0"></element>
</sequence>
</complexType>

<complexType name="factoryDef">
<sequence>
<element name="name" type="string" maxOccurs="1"
minOccurs="1">
</element>
<element name="function" type="factoryFunctionDef"
maxOccurs="unbounded" minOccurs="0"></element>
</sequence>
</complexType>

<complexType name="factoryFunctionDef">
<sequence>
<element name="name" type="string" maxOccurs="1"
minOccurs="1">
</element>
<element name="type" maxOccurs="1" minOccurs="1">
<annotation>
<documentation>
The currently supported factory class function
types
are: createobject, custom, finishtransaction,
getallobjects, getobject and starttransaction.
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="createobject"></enumeration>
<enumeration value="custom"></enumeration>
<enumeration value="finishtransaction"></
enumeration>
<enumeration value="getallobjects"></enumeration>
<enumeration value="getobject"></enumeration>
<enumeration value="starttransaction"></
enumeration>
</restriction>
</simpleType>
</element>
<element name="argument" type="classFunctionArgumentDef"
maxOccurs="unbounded" minOccurs="0">
<annotation>
<documentation>
(Optional) Some types of function may take
additional
arguments that can be used to configure details of
the function behavior using values that are only be
defined at run time by the application that calls
the
function.

This is the case for instance of functions that
search for objects of a given class may take
arguments that define values that can be used in a
filter condition parameters.

A class function may have multiple custom
arguments.
If there are arguments that were defined but
actually
are not used in the function, probably because they
were forgotten or for some other type of mistake,
Metastorage fails specifying which argument was
left
unused.

Each argument is defined separately in sections
that
start with the tag argument. The argument details
are
defined inside the respective section.
</documentation>
</annotation>
</element>
<element name="parameters"
type="classFunctionParametersDef" maxOccurs="unbounded"
minOccurs="0"></element>
</sequence>
</complexType>


<complexType name="schemaDef">
<annotation>
<documentation>
The schema setup class is also a special purpose class
that is meant to provide services to setup a data schema
to store the objects in the persistence container.

For each component, there should be only one schema
setup
class. Like the data classes and the factory class, the
schema setup class may also have customizable functions
defined in a similar way.

The only currently supported schema setup class function
types is installschema.
</documentation>
</annotation>
<sequence maxOccurs="1" minOccurs="1">
<element name="function" type="schemaFunctionDef"
maxOccurs="unbounded" minOccurs="0"></element>

</sequence>
</complexType>

<complexType name="schemaFunctionDef">
<sequence>
<element name="name" maxOccurs="1" minOccurs="1">
<annotation>
<documentation>
A installschema type function does all that is
necessary to install the data schema in the
persistence container. The meaning of this
action
depends on the type of persistence container
being
used.

Currently the only type persistence container
that
is supported are SQL based relational databases.
For this type of persistence container, this
function installs the database schema.

The generated function is of type BOOLEAN. It
returns true if it succeeded or false if there
was
an execution error. This function does not take
any parameters.
</documentation>
</annotation>
<simpleType>
<restriction base="string"></restriction>
</simpleType>
</element>
<element name="type" maxOccurs="1" minOccurs="1">
<simpleType>
<restriction base="string">
<enumeration value="installschema"></enumeration>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>

<complexType name="classFunctionParametersIdDef">
<sequence>
<element name="argument" type="string" maxOccurs="1"
minOccurs="1"></element>
</sequence>
</complexType>
</schema>




Sun Dec 3, 2006 12:43 am

dobes_vander...
Offline Offline
Send Email Send Email

Forward
Message #492 of 553 |
Expand Messages Author Sort by Date

I've been working on an XSD schema for the configuration, so that my xml editor can do auto-completion and friendly structured editing/ validation. I've had...
dobes_vandermeer
dobes_vander...
Offline Send Email
Dec 3, 2006
7:15 pm

Hello, ... Sorry for the delay. I have been at PHP Conference Brasil 2006 and I am still catching up on pending e-mail. I need to make time to look at this...
Manuel Lemos
mallemos
Offline Send Email
Dec 12, 2006
7:11 pm

Of course you're welcome to distribute the file. The point I was making about the XML parser is that it rejects the schema declaration, which must be included...
Dobes Vandermeer
dobes_vander...
Offline Send Email
Dec 12, 2006
8:11 pm

Hello, ... Oh, I see. I will look into that soon so it stops complaining. ... Ok, I do not use Eclipse because it is too heavy, but I will take a look at that...
Manuel Lemos
mallemos
Offline Send Email
Dec 14, 2006
9:19 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help