Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Possible to restrict top-level xs:element names?

From: Kevin Braun <kbraun@-------.--->
To: kennardconsulting <richard@-----------------.--->
Date: 11/6/2009 7:33:00 PM
I'm not quite sure what you are asking.  Are you trying to restrict how 
your schema can be extended, or are you trying to restrict what is 
allowed in an instance document?  

Perhaps you have a conceptual misunderstanding?  Note that

<xs:schema ...>
   <xs:element name="foo"/>
   <xs:element name="bar"/>
</xs:schema>

is not the same as

<xs:schema ...>
   <xs:choice>
      <xs:element name="foo"/>
      <xs:element name="bar"/>
   </xs:choice>
</xs:schema>

(which isn't legal btw).

That is, the children of your <schema> element do not represent a model 
for your instance documents, which is perhaps how you are thinking of 
it?  Rather, they declare the elements, attributes, and types according 
to which an instance document may be validated.  (Note by the way, that 
there are different approaches to validating documents against schemas, 
see 
http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html#validation_outcome).

I don't believe you can prevent someone from including your schema 
document into theirs while at the same time adding more global elements, 
if that's what you are trying to avoid.

Kevin

-- 
Objective Systems, Inc.
REAL WORLD ASN.1 AND XML SOLUTIONS
Tel: +1 (484) 875-9841
Fax: +1 (484) 875-9830
Toll-free: (877) 307-6855 (USA only)
http://www.obj-sys.com



On 11/6/2009 1:58 AM, kennardconsulting wrote:
> Hi guys,
>
> I'm generating a bunch of XML Schemas that look roughly like:
>
> <xs:schema ...>
>    <xs:element name="foo"/>
>    <xs:element name="bar"/>
> </xs:schema>
>
> You can see the actual ones  http://metawidget.org/xsd here . My question
> is, this schema allows me to declare 'foo' and 'bar' in my XML document, but
> doesn't restrict me declaring, say, 'baz'. I was expecting something like...
>
> <xs:schema final="#all">
>
> ....so that I could 'close' the set of possible xs:element names. Or maybe
> that the set was closed by default and I'd need...
>
> <xs:schema ...>
>    <xs:element name="foo"/>
>    <xs:element name="bar"/>
>    <xs:any />
> </xs:schema>
>
> ....to make it open. But instead the set of top-level xs:element names
> appears 'open' by default and I can't find a way to close it? I have looked
> all over the specs and in this forum, sorry if I'm being dumb.
>
> Regards,
>
> Richard.
>   



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent