U
Ultrus
Hello XML gurus,
After much reading, I made my first XML Schema! May I trouble you all
for your thoughts? Perhaps there is a better way to go about it, or I
did something totally wrong without knowing.
My project goal is to make a randomly generated story generator using
recursive xml. There will be random elements within random elements,
within random elements, etc.,.
Here is sample xml:
<randomstory>
<settings />
<story>
Once upon a time...
<random>
<i>A man was born. No one knew what became of him.</i>
<i>
A man was born.
<random>
<i>He grew up, lived long, prospered, then died.</i>
<i>He joined the Navy, fell off the boat, then died.</i>
</random>
</i>
</random>
The end.
</story>
</randomstory>
Here is sample output:
Once upon a time... A man was born. He joined the Navy, fell off the
boat, then died. The end.
Here is the schema:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="randomstory">
<xs:complexType>
<xs:all>
<xs:element name="settings" minOccurs="0" maxOccurs="1" />
<xs:element name="show" minOccurs="1" maxOccurs="1">
<xs:complexType mixed="true">
<xs:all>
<xs:element name="random" type="randomType"
minOccurs="0" maxOccurs="unbounded"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:complexType name="randomType">
<xs:sequence>
<xs:element name="i" type="iType" minOccurs="1"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="iType" mixed="true">
<xs:all>
<xs:element name="random" type="randomType" minOccurs="0"
maxOccurs="unbounded"/>
</xs:all>
</xs:complexType>
Pardon any odd line breaks. Any thoughts? Much appreciated!
After much reading, I made my first XML Schema! May I trouble you all
for your thoughts? Perhaps there is a better way to go about it, or I
did something totally wrong without knowing.
My project goal is to make a randomly generated story generator using
recursive xml. There will be random elements within random elements,
within random elements, etc.,.
Here is sample xml:
<randomstory>
<settings />
<story>
Once upon a time...
<random>
<i>A man was born. No one knew what became of him.</i>
<i>
A man was born.
<random>
<i>He grew up, lived long, prospered, then died.</i>
<i>He joined the Navy, fell off the boat, then died.</i>
</random>
</i>
</random>
The end.
</story>
</randomstory>
Here is sample output:
Once upon a time... A man was born. He joined the Navy, fell off the
boat, then died. The end.
Here is the schema:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="randomstory">
<xs:complexType>
<xs:all>
<xs:element name="settings" minOccurs="0" maxOccurs="1" />
<xs:element name="show" minOccurs="1" maxOccurs="1">
<xs:complexType mixed="true">
<xs:all>
<xs:element name="random" type="randomType"
minOccurs="0" maxOccurs="unbounded"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:complexType name="randomType">
<xs:sequence>
<xs:element name="i" type="iType" minOccurs="1"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="iType" mixed="true">
<xs:all>
<xs:element name="random" type="randomType" minOccurs="0"
maxOccurs="unbounded"/>
</xs:all>
</xs:complexType>
Pardon any odd line breaks. Any thoughts? Much appreciated!