473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

recursive xml schema - going in the right direction?

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="story" 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! :)

Jul 19 '07 #1
0 1670

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rankam | last post by:
Hi There, We have a requirement for recursive elements within a XML document? Is it possible to design it through XML Schema? And what are implications using recursive elements when using DOM...
7
by: Jon Slaughter | last post by:
#pragma once #include <vector> class empty_class { }; template <int _I, int _J, class _element, class _property> class RDES_T {
1
by: Novitas | last post by:
I would like to perform a schema validation of a DOM tree that is already assembled in memory with as little fuss and setup as possible. I see support in the Xerces documentation to perform...
1
by: Dale | last post by:
I am desiging validation method for our application. The application stores configuration and other data in the XML file. I want each time app opens XML file to validate the file against scheme. ...
2
by: PeterW | last post by:
I have an xml file from which I want to generate an xsd schema and at a later stage a cs class. The xml file has a mix of defined namespaces and also an empty namespace. These are defined as...
25
by: Mike MacSween | last post by:
Regular viewers may want to turn off now. This will be an orchestral management system. Musicians and other staff being booked/paid for jobs. A job may contain other jobs, e.g: World Tour...
9
by: Bill Borg | last post by:
Hello, I call a function recursively to find an item that exists *anywhere* down the chain. Let's say I find it five layers deep. Now I've got what I need and want to break out of that whole...
16
by: Indy | last post by:
Hi, I have a XHTML input file with custom tag which specifies html fragments to include For example: <html> .... <include frag1="frag1.html" frag2="frag2.html"> More html here </include>...
1
by: a_valued_employee | last post by:
My data model has many tables in many hierarchies. I believe that by using recursion, I can check for all invalid codes in the working tables that do not exist in the code tables. For example, I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.