473,809 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recursive XML Elements

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 Parser in Java?

Any samples demonstrating this concept in XSD is helpful? I need a XML
structure something like this below :

<forms>
<form-name>formName</form-name>
<form-id>1234</form-id>
<secondary>
..... other elements
<secondary>
...... Other Elements
<secondary>
..... Other Elements
</secondary>
</secondary>
</secondary>
<forms>

thanks,
Ramesh ANKAM

Jul 20 '05 #1
2 4272


ra****@rogers.c om wrote:

We have a requirement for recursive elements within a XML document? Is
it possible to design it through XML Schema?
Yes, certainly.
And what are implications
using recursive elements when using DOM Parser in Java?
None in particular, of course if you do
xmlDocument.get ElementsByTagNa me('element')
or
element.getElem entsByTagName(' element')
you could end up with elements on different nesting levels then but you
can still process them in document order.
Any samples demonstrating this concept in XSD is helpful?


Here is an XML sample:

<?xml version="1.0" encoding="UTF-8"?>
<element xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "test2005031301 Xsd.xml">
<child-element />
<element>
<childElement />
<element>
<element />
</element>
</element>
</element>

and here the schema

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">

<xs:element name="element">
<xs:complexType >
<xs:sequence>
<xs:any processContents ="skip" minOccurs="0" />
<xs:element ref="element" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>

So you can use
<xs:element ref
to refer to the element itself.

And you need to make sure that somewhere the recursion can stop, meaning
the nested element needs to be allowed to not occur where needed for
instance with minOccurs="0".

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Thanks Martin

Now using "ref" attribute I was able to design a schema with recursive elements.

thanks,
Ramesh
Martin Honnen <ma*******@yaho o.de> wrote in message news:<42******* *************** *@newsread4.arc or-online.net>...
ra****@rogers.c om wrote:

We have a requirement for recursive elements within a XML document? Is
it possible to design it through XML Schema?


Yes, certainly.
And what are implications
using recursive elements when using DOM Parser in Java?


None in particular, of course if you do
xmlDocument.get ElementsByTagNa me('element')
or
element.getElem entsByTagName(' element')
you could end up with elements on different nesting levels then but you
can still process them in document order.
Any samples demonstrating this concept in XSD is helpful?


Here is an XML sample:

<?xml version="1.0" encoding="UTF-8"?>
<element xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "test2005031301 Xsd.xml">
<child-element />
<element>
<childElement />
<element>
<element />
</element>
</element>
</element>

and here the schema

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">

<xs:element name="element">
<xs:complexType >
<xs:sequence>
<xs:any processContents ="skip" minOccurs="0" />
<xs:element ref="element" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>

So you can use
<xs:element ref
to refer to the element itself.

And you need to make sure that somewhere the recursion can stop, meaning
the nested element needs to be allowed to not occur where needed for
instance with minOccurs="0".

Jul 20 '05 #3

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

Similar topics

4
1923
by: Magnus Lie Hetland | last post by:
Hi! I've been looking at ways of dealing with nested structures in regexps (becuase I figured that would be faster than the Python parsing code I've currently got) and came across a few interesting things... First there is this, mentioning the (?<DEPTH>) and (?<-DEPTH>) constructs of the .NET regexp matcher: http://www.rassoc.com/gregr/weblog/archive.aspx?post=590
2
7034
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 NULL". Below is also current erraneous draft but it has ambigous filed name problem. CREATE TABLE icategories ( icat_id int(11) NOT NULL auto_increment, icat_parent_id int(11) default NULL, icat_name char(100) default NULL, PRIMARY KEY ...
6
2059
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 constructors) which have this base class: template<class T>
2
10855
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 it if anyone need such a function. function append_children() { var a = append_children.arguments;
25
2835
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 contains US leg and Europe leg (and others) US leg contains State tours (and others)
0
1686
by: Ultrus | last post by:
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.,.
1
7815
by: indyanguy | last post by:
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="">...
2
2319
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 2</name>
2
2496
by: felciano | last post by:
Hello -- I am trying to use XSL to process Amazon wishlist data to sort the results by type (Apparel, then Books, then DVDs, etc). Amazon's web services chunk up results in multiple pages of fixed size, e.g. 55 items gets returned in 5 XML pages of 10 items and a 6th of 5 items. Each page is returned from a distinct URL call with a PageNum parameter. I've been trying to adapt a technique described at...
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10643
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10378
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10391
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10121
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3862
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.