473,398 Members | 2,389 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,398 software developers and data experts.

How to create schema that defines value sets

RedSon
5,000 Expert 4TB
Can someone provide me with an example of how I define in a schema that I require 25 value sets?

Say in my XML I have:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <linear xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  3.     <linedata>
  4.         <line>
  5.             <rise>253</rise>
  6.             <run>446</run>
  7.         </line>
  8. ...
  9. </close tags...>
  10.  
and I have 25 "line" elements how do I enforce that in my xsd?

Thanks.
Apr 28 '10 #1
4 1646
jkmyoung
2,057 Expert 2GB
minOccurs, maxOccurs. This may be at the element level, or other level such as sequence
Expand|Select|Wrap|Line Numbers
  1. <xs:element name="lineData">
  2.     <xs:complexType>
  3.         <xs:sequence>
  4.             <xs:element name="line" maxOccurs="25" minOccurs="25"/>
  5.         </xs:sequence>
  6.     </xs:complexType>
  7. </xs:element>
  8.  
Apr 28 '10 #2
RedSon
5,000 Expert 4TB
So this statement says that the element named "line" must occur a min and max time of 25 times?

Thanks I will use that!
Apr 28 '10 #3
RedSon
5,000 Expert 4TB
The feedback I received on the schema is that I should use complex types and put them in the element attribute instead of nesting the complex type.

Do you have some reference material on how this can be accomplished. I do not understand what this means.
Apr 29 '10 #4
jkmyoung
2,057 Expert 2GB
Basically, use references everywhere to make the schema as flat as possible (1 layer at a time).
There are 2 ways:
1. Reference to elements:
2. Reference to types.

1. Only referencing elements. Notice use of the ref attribute
Expand|Select|Wrap|Line Numbers
  1. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  2. <xs:element name="lineData"> 
  3.     <xs:complexType> 
  4.         <xs:sequence> 
  5.             <xs:element ref="line" minOccurs="25" maxOccurs="25"/> 
  6.         </xs:sequence> 
  7.     </xs:complexType> 
  8. </xs:element> 
  9. <xs:element name="line">
  10.     <xs:complexType> 
  11.         <xs:sequence> 
  12.             <xs:element ref="item" minOccurs="25" maxOccurs="25"/> 
  13.         </xs:sequence> 
  14.     </xs:complexType> 
  15. </xs:element>
  16. <xs:element name="item" type="xs:string"/>
  17. </xs:schema>
Compared to 2. Only referencing types: Notice the use of the type attribute.
Expand|Select|Wrap|Line Numbers
  1. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  2. <xs:element name="lineData" type="lineDataType"/> 
  3. <xs:complexType name="lineDataType">
  4.     <xs:sequence> 
  5.         <xs:element name="line" minOccurs="25" maxOccurs="25" type="lineType"/> 
  6.     </xs:sequence> 
  7. </xs:complexType>
  8. <xs:complexType name="lineType">
  9.     <xs:sequence> 
  10.         <xs:element name="item" type="xs:string" /> 
  11.     </xs:sequence> 
  12. </xs:complexType>
  13. </xs:schema>
You can also do both 1 and 2, ...which I think is what is being asked
Apr 29 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Guy Deprez | last post by:
Hi, i'm having a problem to create indexes. STEP 1 ----------- Connection is OK (you can find the string at the end of the message) Table ("Couleurs") creation is OK STEP 2. Index Creation
2
by: Olaf Meyer | last post by:
Apprentently xerces 2.6.0 (Java) does not validate against contraints specified in the schema (e.g. constraints specified via unique element). The validation works with the XML editor I'm using...
1
by: wooks | last post by:
The schema below describes an interface to a form where the appInterface type is an extension of an abstract type called interface and it contains an appFrame element that is an extension of an...
3
by: Leonid Shprekher | last post by:
Question to the Schema pro: If nillable="False" is default for Schema element, why schema validation of my XML doesn't fail if I don't provide any value for the tag? Thanks, Leonid.
2
by: Shailendra Batham | last post by:
Hello Gurus, I want to put some restrictions on my attribute tag in my XML Schema, anyone out there have any idea how to do that. here is my XML and the XML Schema <?xml version="1.0"...
0
by: Deep Purple | last post by:
I started with the following error... ------------------------------------------------------- An error occured while loading the schema with TargetNamespace 'http://www.w3.org/2001/XMLSchema'...
1
by: deko | last post by:
I will be using the XmlDataDocument class to create a typed DataSet from an XML file and an XSD file I've created that defines a few constraints and one relationship. The initial data from the XML...
1
by: Ganesh Muthuvelu | last post by:
Hello, I have a simple schema as shown below. When I validate it, I get the error "Type 'http://www.w3.org/2001/XMLSchema:emptype' is not declared. An error occurred at , (6, 12)." ...
6
by: Grant Robertson | last post by:
If I use the 'any' element in my schema to allow elements from another schema to be used in instance documents based on my schema, is there a way to force that the contents of that element must be...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
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
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
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...
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...
0
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...

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.