Re: [xml] General XML Schema question



On Fri, 2007-12-21 at 11:57 +0000, Pete Cordell wrote:
Now I would like to create a rule which says for example if the user
chose the enumerator MY_SPECIAL_TYPE_STRING than the type of "Value" has
to be "xsd:string". If the enumerator was MY_SPECIAL_TYPE_INTEGER than
the type of "Value" should be "xsd:integer". And maybe if this is even
possible create my own type for "Value".

Better places to ask this sort of question are xmlschema-dev w3 org, 
xml-dev lists xml org and the comp.text.xml newsgroup.  You may have to do a 
bit of detective work to find out how to subscribe to these.

Nice tip I will have a try.


To answer your question, you can't use XML schema to do this.  (I'm not sure 
even if RelaxNG can do this.)

A more schema friendly way of do this would be to do:

<xsd:complexType>
  <xsd:choice>
    <xsd:element name="MY_SPECIAL_TYPE_STRING" type="xsd:string"/>
    <xsd:element name="MY_SPECIAL_TYPE_INTEGER" type="xsd:int"/>
    <xsd:element name="MY_SPECIAL_TYPE_OF_WHATEVER" type="???"/>
  </xsd:choice>
</xsd:complexType>

Your XML instance then looks like:

<MY_SPECIAL_TYPE_STRING>MyString</MY_SPECIAL_TYPE_STRING>

That's a brilliant idea. Easy to solve and I can use it right now.
Thanks for your help!

Best regards
Stefan

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]