'Choice between two elements with same name

I am struggling with a choice between an element that is mixed and one that is not.

    <xs:group name="code">
        <xs:choice>
            <xs:element name="code" type="multiLineCode"/>
            <xs:element name="code" type="code"/>
        </xs:choice>
    </xs:group>
    <xs:complexType name="code" mixed="true">
        <xs:group ref="htmlInlineElements" minOccurs="0" maxOccurs="unbounded"/>
    </xs:complexType>
    <xs:complexType name="multiLineCode">
        <xs:sequence>
            <xs:element name="line" maxOccurs="unbounded">
                <xs:complexType mixed="true">
                    <xs:group ref="htmlInlineElements" minOccurs="0" maxOccurs="unbounded"/>
                    <xs:attribute name="indentation" use="required"/>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

Why do I want to do this crazy move?

The background is that mixed text in the <code> element is reformatted by the IDE so far. Since the content later moves to an HTML <pre> element there are display problems here.

existing <code> example:

<code>
    if (<function>ParseInt</function>("42") === 42)
        <function>doSomething</function>();
</code>

<code> example for multiline:

<code>
    <line indentation="0">if (<function>ParseInt</function>("42") === 42)</line>
    <line indentation="1"><function>doSomething</function>();</line>
</code>

So i want either a <code> element that's not multiline but has <line> elements or a multiline code element. As there are 670 code examples out i cannot change them all. Do you have a solution for my choice-problem? And in general: Am i on the right way solving this problem?

Thank you very much!

xsd


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source