473,394 Members | 1,887 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,394 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 7789
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...

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.