473,399 Members | 3,832 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,399 software developers and data experts.

About usage of maxOccurs

Hi,

I have the following XSD file (XML Schema 1.0):

<xs:element maxOccurs="1" minOccurs="1" name="header">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="xs:positiveInteger"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="parentId" type="xs:positiveInteger"/>
<xs:element name="parentName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

As the name says this should be the header for some kind of element. As it is a
header, it should only occur in the XML document ones. Therefore I added the
minOccurs and maxOccurs attributes. However, the xsv online validation check
(http://www.w3.org/2001/03/webdata/xsv) says:

Invalid per cvc-complex-type.1.3: undeclared attribute {None}:maxOccurs
Invalid per cvc-complex-type.1.3: undeclared attribute {None}:minOccurs

So I guess I'm not allowed to use those attributes at this point. How should I
proceed to fix this but also to note that this element is only allowed to occur
exactly one time in the XML document?!
Sebastian
Aug 14 '06 #1
3 1721


Sebastian Stein wrote:

So I guess I'm not allowed to use those attributes at this point. How should I
proceed to fix this but also to note that this element is only allowed to occur
exactly one time in the XML document?!
Put that element definition in the right context e.g. of a sequence of
the root element (just an example)
<xsl:element name="root">
<xsl:complexType>
<xs:sequence>
<xs:element name="header">
The defaults for min/maxOccurs are 1 so there is no need to specify that
explictly.

You can also define that element standalone as a top level element as
you seem to have but then you need to specify minOccurs/maxOccurs where
you reference the element e.g.
<xsl:element name="root">
<xsl:complexType>
<xs:sequence>
<xs:element ref="header">
again you only need to specify min/maxOccurs if they are supposed to be
different from 1.

Also note that a top level element definition means any XML instance
document checked against the schema can have such an element as the root
element. That is usually not what you want.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 14 '06 #2
Hi Sebastian,

It looks like you define "header" as a global element. If this is the case,
it can only occur once in your instance document. Because of this,
minOccurs/maxOccurs attributes are not allowed on the global elements.

If this is not a global element, it needs to be inside a
sequence/choice/all.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Sebastian Stein" <se*******@gmx.dewrote in message
news:cc************@ID-116864.user.uni-berlin.de...
Hi,

I have the following XSD file (XML Schema 1.0):

<xs:element maxOccurs="1" minOccurs="1" name="header">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="xs:positiveInteger"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="parentId" type="xs:positiveInteger"/>
<xs:element name="parentName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

As the name says this should be the header for some kind of element. As it
is a
header, it should only occur in the XML document ones. Therefore I added
the
minOccurs and maxOccurs attributes. However, the xsv online validation
check
(http://www.w3.org/2001/03/webdata/xsv) says:

Invalid per cvc-complex-type.1.3: undeclared attribute {None}:maxOccurs
Invalid per cvc-complex-type.1.3: undeclared attribute {None}:minOccurs

So I guess I'm not allowed to use those attributes at this point. How
should I
proceed to fix this but also to note that this element is only allowed to
occur
exactly one time in the XML document?!
Sebastian

Aug 14 '06 #3
Stan Kitsis [MSFT] <sk***@microsoft.comwrote:
It looks like you define "header" as a global element. If this is the case,
it can only occur once in your instance document. Because of this,
minOccurs/maxOccurs attributes are not allowed on the global elements.

If this is not a global element, it needs to be inside a
sequence/choice/all.
Yes, you both are correct. I forgot to put a root element around my document.

Thanks for spotting this!

Sebastian
Aug 15 '06 #4

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

Similar topics

0
by: GB | last post by:
If I define the following schema which allows either a tag element OR an tag and origin_system elements I get an error. Same thing happens when I use groups. Is this because tag is defined twice?...
0
by: Kurt | last post by:
Hi, (sorry if I'm cross posting - not quite sure where to put) I am basically trying to force the user of my web service to only send a valid dataset that is based on a schema I have created. ...
0
by: Robert Rae | last post by:
Does anyone know of a way to set minoccurs and maxoccurs from an attribute. An example would be: public string HelloWorld(DataInput dataInput) { return "Hello World"; } public class...
3
by: Amol | last post by:
Hi all, I have a case where I have a element that can appear under multiple elements e.g. <AppFunctions> <UseTemplate name="1"/> <MethodSet name="2"> <UseTemplate name="3" /> <MethodCall...
2
by: mavis | last post by:
The usage of <xs:choice maxOccurs="unbounded"> When we want to define a set of elements that could be in any order and with any occurences (0-unbounded), we can use <xs:choice...
2
by: hooomee | last post by:
Given: <xs:choice maxOccurs=5> <xs:element name="Foo" type="bar" /> <xs:element name="Foo1" type="bar" /> <xs:element name="Foo2" type="bar" /> </xs:choice> Is the choice made once and then...
3
by: jlauman | last post by:
I'm getting an error on line 6 of the code shown below. The error is: Value 'unbounded' is not allowed for attribute 'maxOccurs' I'd appreciate any help in resolving this. Thanks, Jack ...
3
by: foolproofplan | last post by:
Maybe I am looking to far into a simple problem, but I am having quite a hard time figuring this out: I am currently trying to create a schema to represent an Element which contains other...
2
by: =?Utf-8?B?QW5keSBD?= | last post by:
Hi, I'm trying to load some XML into a dataset with C# but I have an issue with the schema. I'm using exactly the same code to successfully load other XML. The only difference is in the XML...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.