xml-schema question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rudie
    New Member
    • Aug 2007
    • 3

    xml-schema question

    Hi
    I´m having trouble with my xml schema.

    My problem is that I want the element "PREMIE" to be able to occur several times. The other elements has to be independent of order. The element names are in swedish but that shouldn´t be a problem.
    Here is the .xsd-file:

    <xs:element name="BIL">
    <xs:complexType >
    <xs:all>
    <xs:element name="TRAFIKBON US" minOccurs="0">
    <xs:simpleTyp e>
    <xs:restricti on base="xs:string ">
    <xs:maxLength value="2" />
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="BILMERKES KOD" minOccurs="0">
    <xs:simpleTyp e>
    <xs:restricti on base="xs:string ">
    <xs:maxLength value="6" />
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <!-- ref -->
    <xs:element ref="PREMIE" />
    <xs:element ref="RABATT" />
    </xs:all>
    </xs:complexType>
    </xs:element>

    I really need this to work.
    Thanks!
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Can you change you <xs:all> to a <xs:sequence> instead?

    Then you can have a nested sequence
    Code:
    <xs:sequence>
       ...
       <xs:sequence>
       	<xs:element ref="PREMIE" maxOccurs="unbounded"/>
       </xs:sequence>
       <xs:element ref="RABATT" />
    </xs:sequence>
    inside this sequence.

    Comment

    • rudie
      New Member
      • Aug 2007
      • 3

      #3
      Thanks for your reply. If I do like you say the order of the elements befor the "nested sequence" will matter. That is the whole problem.
      I´d be happy for more input.

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        I was afraid you were asking for that:
        http://www.thescripts. com/forum/thread88016.htm l

        Really, the problem is that this is easier to express as a context free grammar, instead of a regular expression. The regular expression that describes your structure is ugly.
        eg, renaming the elements a, b, c, d the regular expression might look something like:
        c*dc*( (ac*)?(bc*)? | bc*ac*) |
        c*ac*bc*dc* |
        c*bc*ac*dc* |
        c*ac*dc*(bc*)? |
        c*bc*dc*(ac*)?

        If you really want to enforce this criteria, you might be better off switching to RELAX NG, or schematron, or some other tool.

        Comment

        • rudie
          New Member
          • Aug 2007
          • 3

          #5
          Ok thanx.
          I guess there´s no easy way then.

          Comment

          Working...