I have multiple XML-files, that can have on the lowest level a HTML b
or i
Tag and or text, like the following examples.
<root>
<text> Hallo Welt, wie geht es so? </text>
<text> <i>Hallo Welt, wie geht es so?</i> </text>
<text> Hallo <i>Welt, wie geht es so?</i> </text>
<text> <b>Hallo Welt, wie geht es so?</b> </text>
<text> Hallo <b>Welt, wie geht es so?</b> </text>
<text> <b>Hallo Welt</b>, <i>wie geht es so?</i> </text>
<text> <b>Hallo Welt</b>, <i>wie geht es so</i>? </text>
<text> <i>Hallo Welt</i>, <b>wie geht es so?</b> </text>
<text> <i>Hallo Welt</i>, <b>wie geht es so</b>? </text>
<text> <i>Hallo Welt, <b>wie geht es so</b>?</i> </text>
<text> <b>Hallo Welt, <i>wie geht es so</i>?</b> </text>
<text> Hallo <i>Welt, <b>wie geht es so</b>?</i> </text>
<text> Hallo <b>Welt, <i>wie geht es so</i>?</b> </text>
<text> <b>Hallo <i>Welt</i></b>, <i>wie <b>geht </b></i>es so? </text>
</root>
You can mix up i
with b
and the other way, you can have just text oder text in just one of the b
or i
Tag.
I tried the following:
<xs:complexType name="articleType">
<xs:sequence>
<xs:element name="author" type="textType" />
<xs:element name="title" type="textType" />
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="required" />
</xs:complexType>
<!-- TEXT -->
<xs:complexType name="textType">
<xs:sequence>
<xs:element name="i" type="iType" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="b" type="bType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<!-- I -->
<xs:complexType name="iType">
<xs:sequence>
<xs:element name="b" type="bType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<!-- B -->
<xs:complexType name="bType">
<xs:sequence>
<xs:element name="i" type="iType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
Sadly, this validation site http://www.utilities-online.info/xsdvalidation/
tells me the following error:
Error - Line 7, 50: org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 50; cvc-complex-type.2.3: Element 'author' cannot have character [children], because the type's content type is element-only.
Kind Regards
Mario
XML Schema provides limited support for mixed content by declaring a complexType
with mixed="true"
, but you can't further constrain the text nodes in mixed content with types. You can only apply simple types to simple content.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.