W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2002

Re: variable element names

From: <noah_mendelsohn@us.ibm.com>
Date: Mon, 18 Nov 2002 21:09:18 -0500
To: Mike Rothe <Mike_Rothe@actiontech.com>
Cc: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Message-ID: <OFB6519D77.C925199B-ON85256C76.000B6572@lotus.com>

Yes.  Define the "variable" element as:

<xsd:any processContents="strict"/>

What you can't do is control the order or appearance of the children. What 
the above does do is make sure you have a global <xsd:element> declaration 
for each child, and that the contents of each child are correct.

So:

 
        <parent>
                <var>
                        <x>123</x>
                        <w><a/></w>
                        <z/>
                </var>
        <parent>

So, parent would have the <xsd:any as its content, and that would accept 
the <var>.  You can't control the order in which children of <var> appear 
(<w>. appears after <x>, and <y> is missing), but there MUST be a 
declaration for each of <w>, <x>, and <z>, and those elements must 
validate per the declarations.

If you use "lax" instead of "strict", then it's optional to provide the 
declarations for elements like <w>;  any one that doesn't have a 
declaration will be accepted, no matter what its contents.

------------------------------------------------------------------
Noah Mendelsohn                              Voice: 1-617-693-4036
IBM Corporation                                Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------







Mike Rothe <Mike_Rothe@actiontech.com>
Sent by: xmlschema-dev-request@w3.org
11/18/2002 08:36 PM

 
        To:     "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
        cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
        Subject:        variable element names



There is an element in my schema that is a variable element, meaning that 
on
the instance doc that element name could be anything. However, all the 
child
elements contained in the variable element have fixed names. I would like 
to
validate the children of the element with the variable name. Does the
standard support this?
Received on Monday, 18 November 2002 21:10:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:35 GMT