Validation/element reference/default elements questions

Hi there,
I am really new to XML Schema (and XML, anyway) and I hope this is the
right place
for my questions... and forgive me for the beginner´s stuff - I guess I
understand
the Primer quite well, but Part 1 makes my head explode sometimes.

Q1: Suppose a schema declares 3 top level elements A, B, C. Can an instance
that only contains
        A be valid against that schema? If yes, are empty document
instances always valid?
        Is it even correct to say a document instance is valid, or is the
only thing you can say that
        an instance consists of elements which are all valid?

Q2: Do you need to declare top-level elements in the schema for validation,
or is it sufficient to
        define types?

Q4: Can you reference (ref=...) elements that are not top-level?

Q5: XML Schema recommendation does not allow creation of missing elements
in instances if they
       are declared with the default property.
       Is there a special reason for not allowing such behaviour?

Q6: And is a document instance without such a schema-defaulted element
valid or invalid against the schema?
       (Would be a yes if Q1 part 1 is a yes)

Here is some background for my curiosity:
What we want to do here is using XML Schemas to validate
Rendezvous-middleware messages we
are sending between various applications in a trading environment.
These are self-describing data offering name, type and value for the
message fields.
A message would look like:

msg = {  f1 = 'hello'
                 f2 = 4.7
                 f3 = { ...}
}
(carrying additional type information; actually, on the application side we
are using
class-like python RvMsg types and a python wrapper around the Rv-C/C++ API)

A straightforward translation to an XML representation would be:

<msg type="RvMsg">
  <f1 type="string">hello</f1>
  <f2 type="float">4.7</f2>
  <f3 type="RvMsg>
    ...
  </f3>
</msg>

Regarding the interfaces we are building, there might well be incoming
messages lacking one field or the other in the message. We´d like
to either reject such messages or default the missing (or empty) fields.

Of course, we could just put a field with default value into the message
if the corresponding element in the schema has the default=... property
(which feels
like cheating, as the schema does not allow element creation for document
instances).

Furthermore, translating the message to a XML doc instance, it could never
have the missing field
represented by empty tags; thus, we could not validate this
doc-created-of-a-message
with the same schema (provided the answer to Q2 is "invalid").

Though, I do not see another possibility than the "cheating" way for us
right now.

Q7: Am I on the right track at all with what I´m thinking?

Your help is greatly appreciated.
Best regards
  Holger Joukl

_________________________

Holger Joukl
LBBW
2342 Z - IT/Org II Handel
Tel. +49 (711) 124 - 7078
_________________________



______________________________________________________________________


--------------------------------------------------------------------------------------------
Bitte beachten Sie, dass der Inhalt dieser E-Mail einschließlich eventuell
angehängter Dokumente vertraulich ist. Falls Sie nicht der angegebene
Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde,
dürfen Sie die E-Mail und eventuell angehängte Dokumente weder öffnen,
lesen, kopieren, verbreiten noch ihren Inhalt in irgendeiner Weise nutzen.
Bitte verständigen Sie den Absender sofort und löschen Sie Die E-Mail
sodann.

Die Sicherheit von Übermittlungen per E-Mail kann nicht garantiert werden.
Per E-Mail übermittelte Informationen können abgefangen oder geändert
werden, verloren gehen oder zerstört werden, verspätet oder unvollständig
ankommen, oder Viren enthalten. Der Absender übernimmt daher keine Gewähr
für Irrtümer oder Auslassungen jeder Art im Inhalt sowie sonstige Risiken,
die auf die Übermittlung per E-Mail zurückzuführen sind. Falls Sie eine
Bestätigung wünschen, fordern Sie bitte den Inhalt der E-Mail als Hardcopy
an.


This e-mail and any attached files are confidential. If you are not the
named addressee or if this transmission has been addressed to you in error,
any disclosure, reproduction, copying, distrubtion, or other dissemination
or use of this communication is prohibited. If you have received this
transmission in error please notify the sender immediately and then delete
this e-mail.

E-mail transmission cannot be guaranteed to be secure or free from error as
information could be intercepted, corrupted, lost, destroyed, arrive late
or incomplete, or contain viruses. The sender therefore does not accept
liability for any errors or omissions in the contents of this message or
any other of such risks which arise as a result of e-mail transmission. If
verification is required, please request a hard copy version.
---------------------------------------------------------------------------------------------

Received on Tuesday, 3 July 2001 08:34:07 UTC