473,378 Members | 1,415 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,378 software developers and data experts.

Recursive elements in XML. How do i create a XSD for this?

Hello,

I am trying to create a XML schema to validate a XML document. The XML document has recursive <Section> elements (as shown below). Can someone help me create the XSD for the recursive part (Section One and the children)

<?xml version="1.0" encoding="UTF-8"?>
<MenuHelp sectionHeading="" menuSpace="">
<Description>></Description>
<Sections>
<Section name="Application Help" url="" helpFileName="" isLegacy="1" code="">
<Section name="Section One Help" url="" helpFileName="" isLegacy="1" code="">
<Section name="Section One SubHelp" url="" helpFileName="" isLegacy="1" code="">
<Section name="Section One SubSubHelp" url="" helpFileName="" isLegacy="1" code="">
<Section name="SubSubSubHelp " url="" helpFileName="" isLegacy="1" code=""/>
</Section>
</Section>
<Section name="Header " url="" helpFileName="" isLegacy="1" code=""/>
</Section>
<Section name="Saved Search Help" url="" helpFileName="" isLegacy="1" code=""/>
<Section name="Changes Help" url="" helpFileName="" isLegacy="1" code=""/>
</Section>
<Section name="Login Help" url="" helpFileName="" isLegacy="1" code="">
<Section name="Login Sub Help" url="" helpFileName="" isLegacy="1" code=""/>
</Section>
</Sections>
</MenuHelp>
Jan 31 '08 #1
1 7787
jkmyoung
2,057 Expert 2GB
The key is to use the ref attribute.
When you initially reference the Section element inside the sections, use a ref:
Expand|Select|Wrap|Line Numbers
  1. <xs:element name="Sections">
  2.     <xs:complexType>
  3.         <xs:sequence>
  4.             <xs:element ref="Section" minOccurs="0" maxOccurs="unbounded"/>
  5.         </xs:sequence>
  6.     </xs:complexType>
  7. </xs:element>
  8.  
Then declare the Section element, and have it reference itself.
Expand|Select|Wrap|Line Numbers
  1. <xs:element name="Section">
  2.     <xs:complexType>
  3.         <xs:sequence>
  4.             <xs:element ref="Section" minOccurs="0" maxOccurs="unbounded"/>
  5.         </xs:sequence>
  6.         <xs:attribute name="code"/>
  7.         <xs:attribute name="url"/>
  8.         <xs:attribute name="isLegacy"/>
  9.         <xs:attribute name="name"/>
  10.         <xs:attribute name="helpFileName"/>
  11.     </xs:complexType>
  12. </xs:element>
  13.  
Feb 4 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Perttu Pulkkinen | last post by:
I need to find toplevel image categories and a) number of images directly in them and b) number of subcategories directly in those topcategories. In toplevel image categories "icat_parent_id IS...
0
by: inquirydog | last post by:
Hello- XML clearly allows recursive xml (ie- elements to appear in themselves- examples are in mathml- functions of functions of functions, or xhtml, tables in tables in tables). My question is...
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...
6
by: Johan Bergman | last post by:
Hi, Maybe someone can help me with this one. The following describes a somewhat simplified version of my problem, but I think it will be sufficient. I want to use class factories (virtual...
2
by: samuel.adam | last post by:
Hi all, I am coding an AJAX DHTML whatever application and I was fed up with always typing a lot of appendChild() functions. I created a custom one called append_children() and wanted to share...
9
by: Csaba Gabor | last post by:
Inside a function, I'd like to know the call stack. By this I mean that I'd like to know the function that called this one, that one's caller and so on. So I thought to do: <script...
41
by: Harry | last post by:
Hi all, 1)I need your help to solve a problem. I have a function whose prototype is int reclen(char *) This function has to find the length of the string passed to it.But the conditions...
2
by: wgarner | last post by:
I am trying to implement a two-dimensional recursive formula, g(x,y). It is sort of like multiplication. g(x,y) = 0 if either x or y is 0. g(1, y) = y and g(x, 1) = x. Those are the base...
2
by: Susan Harris | last post by:
I'm looking to define a particular kind of recursive XML Schema. It needs to describe the following kind of document: <nodes> <node> <name>Node 1</name> <item/> </node> <node> <name>Node...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.