xsl-list
[Top] [All Lists]

[xsl] Schema problem: different element types with the same name

2007-12-06 07:08:27
I accidentally sent this question as an reply to another topic.
Therefore I will repeat it here as a separate topic.
====================================================
I'm dealing with some legacy XML documents and try to develop a schema
to validate them.

They contain sequences like:

[...]
  <mmc:param name="asp.frameset">view-book</mmc:param>
  <mmc:param name="suppress.index.list.when.no.input">0</mmc:param>
[...]

The first element content must be name token (without spaces), the
second a boolean value. My first try was to define two separate types
and to apply then to the param element, like in the example below. But
obviously I cannot have two elements with the same name and different
types in a sequence. Is there a work-around?

I know that those elements should better be attributes. But changing the
legacy code before verifying it is not an option. I could also relax the
type and code both param elements as type string, but then I could not
verify the element content. How should I proceed?


[...]
<xs:complexType name="paramAspFrameset" mixed="true">
  <xs:simpleContent>
    <xs:extension base="xs:NMTOKEN">
      <xs:attribute name="name" fixed="asp.frameset" use="required"/>
    </xs:extension>
  </xs:simpleContent>
</xs:complexType>

<xs:complexType name="paramSuppressIndexListWhenNoInput" mixed="true">
  <xs:simpleContent>
    <xs:extension base="xs:boolean">
      <xs:attribute name="name"
        fixed="suppress.index.list.when.no.input"/>
    </xs:extension>
  </xs:simpleContent>
</xs:complexType>

<xs:complexType name="text2index">
  <xs:sequence>
    [...]
    <xs:element name="param" type="mmc:paramAspFrameset" 
      minOccurs="1" maxOccurs="1"/>
    <xs:element name="param"
      type="mmc:paramSuppressIndexListWhenNoInput" minOccurs="1"
      maxOccurs="1"/>
    [...]
  </xs:sequence>
</xs:complexType>
[...]



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>