472,781 Members | 1,245 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,781 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 4649
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
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.