Re: restrict content to values out of a xml file

If you want to use an enumeration constraint then the fragment to be
included in your schema document must be a valid schema fragment:

The schema document would look like:

<xs:element name="bla">
  <xs:simpleType>
    <xi:include href="inc.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
   </xs:simpleType>
</xs:element>

where inc.xml looks like:

<xs:restriction base="string" xmlns:xs="http://...">
  <xs:enumeration value="1"/>
  <xs:enumeration value="2"/>
</xs:restriction>

The file inc.xml can easily be generated from another instance document
using XSLT.

The other possiblity using XInclude is to use key/keyref-constraints. The
disadvantage is that in order to validated an instance document the "value
file" must actually be included in the instance to validate. Therefore the
enumeration solution is to preferable.

Hope this helps,
--Stefan

PS: You have to make sure that your validator supports XIncludes. JBind
supports XIncludes in instance and schema documents.



> 
> hi,
> thanx for the answer! 
> how can put that XIncludes thing into the enumeration? i couldnīt find any
> examples in the net.
> i have a structure like this, now what do i have to write into the
> enumeration tags?:
> 
> <xs:element name="bla">
>      <xs:simpleType>
>          <xs:restriction base="xs:string">
>                 <xs:enumeration value="???"/>
>           </xs:restriction>
>      </xs:simpleType>
> </xs:element>
> 

Received on Friday, 28 February 2003 04:46:42 UTC