d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Question About Xml Shema
Add Reply New Topic New Poll
Member
Posts: 3,141
Joined: Jul 16 2005
Gold: 224,068.45
Feb 15 2015 10:56am
Hi Guys.

I have got a question about how I solve this problem.


I have got a <Description> complex type (mixed="true") and I want this to be a complex type where I can have unlimited number of <bold> and <italic> tags inside in random order


to clarify what I mean:
I have an XML like this
<Description>
hi
<bold>guys</bold>
this
<italic> must </italic>
<bold> always </bold>
hold
<bold>no matter </bold>
<italic>which tag</italic>
and how many are
<italic>used</italic>
</Description>


Really hope someone can help me out, since I can't think of (or find) a solution to this problem :)

This post was edited by R-Zenk on Feb 15 2015 11:09am
Member
Posts: 7,324
Joined: Dec 22 2002
Gold: 1,261.00
Feb 17 2015 01:52pm
Code
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="bold">
</xs:element>

<xs:element name="italic">
</xs:element>

<xs:element name="Description">
<xs:complexType mixed="true">
<xs:choice maxOccurs="unbounded">
<xs:element ref="bold"/>
<xs:element ref="italic"/>
</xs:choice>
</xs:complexType>
</xs:element>

</xs:schema>


This will validate your sample XML. You can check on http://www.utilities-online.info/xsdvalidation

This post was edited by russian on Feb 17 2015 01:59pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll