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

Using loops in XSD?

hi @all!

i have a little problem with xsd. is it possible to define a loop in a
schema?

the xml files i want to validate look like this:

- product
-- component
--- sub-component
--- sub-component
---- sub-component
-- component
--- sub-component
---- sub-component

each (sub-)component can have one or more own sub-components and so
on... there is a static solution needed because the xml file is
usually written by hand. writing it by using to many references makes
it more likely to make a mistake and more difficult to locate an
error.

i really hope you can help me with that. i didn't find a real hint
yet. :(

Mfg,
Christian Rühl
Nov 19 '07 #1
1 4754
On 19 Nov, 14:41, "Christian Rühl" <ch...@cruehl.comwrote:
On 19 Nov., 14:57, Pavel Lepin <p.le...@ctncorp.comwrote:
Christian Rühl <ch...@cruehl.comwrote in
<72cc99e1-7a7b-4ac3-a346-7f850aa64...@p69g2000hsa.googlegroups.com>:
the xml files i want to validate look like this:
-- component
--- sub-component
--- sub-component
---- sub-component
-- component
--- sub-component
---- sub-component
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="sub">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="sub"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Another option might be:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="sub">
<xs:complexType>
<xs:sequence>
<!-- You might want some extra stuff here. -->
<xs:element ref="sub" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Or (tweak of Pavel's):

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="sub">
<xs:complexType>
<xs:choice>
<xs:element ref="subdetails" type="subdetails"/>
<xs:element ref="sub" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

The difference between the two depends on whether a sub-component with
sub-components _only_ have sub-components, or has other data plus sub-
components. (Wow - that's a lot of sub-components!)

HTH,

Pete Cordell
Codalogic
Visit http://www.codalogic.com/lmx/
for XML Schema to C++ data binding
Nov 19 '07 #2

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

Similar topics

3
by: Carlos Ribeiro | last post by:
As a side track of my latest investigations, I began to rely heavily on generators for some stuff where I would previsouly use a more conventional approach. Whenever I need to process a list, I'm...
1
by: Rudy Koento | last post by:
Hi, I've created an index but it's not being used by postgresql when doing a query. But doing an "explain analyze" shows that with index, it's faster. Here's the output: ...
7
by: Egor Shipovalov | last post by:
I'm implementing paging through search results using cursors. Is there a better way to know total number of rows under a cursor than running a separate COUNT(*) query? I think PostgreSQL is bound...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
13
by: Kartic | last post by:
Hi, Is it good practice using GOTO in .NET application? Please advice. Thanks, Kartic
17
by: John Salerno | last post by:
I'm reading Text Processing in Python right now and I came across a comment that is helping me to see for loops in a new light. I think because I'm used to the C-style for loop where you create a...
10
by: Putty | last post by:
In C and C++ and Java, the 'for' statement is a shortcut to make very concise loops. In python, 'for' iterates over elements in a sequence. Is there a way to do this in python that's more concise...
9
by: Nathan Sokalski | last post by:
I am trying to use the System.Array.ForEach method in VB.NET. The action that I want to perform on each of the Array values is: Private Function AddQuotes(ByVal value As String) As String Return...
5
by: ertis6 | last post by:
Hi all, I need to calculate a value inside 8 nested for loops. 2 additional for loops are used during calculation. It was working fine with 4 loops. My code is like this: ... for(int i1=0;...
8
by: Nathan Sokalski | last post by:
I have several nested For loops, as follows: For a As Integer = 0 To 255 For b As Integer = 0 To 255 For c As Integer = 0 To 255 If <Boolean ExpressionThen <My CodeElse Exit For Next If Not...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.