473,626 Members | 3,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create a sample XML data for XML Schema

Hello,
Let us say that I have a schema or complex type like this one below:

Is there a way programtically or a tool to create sample XML file/data for
the schema?. I have number of such complex tpyer/schemas for which I need to
create sample XMLs so I thought of doing it programatically .. Any pointers
would be appreciated.

Thanks.

*************** *******
<xs:complexTy pe name="AddReques t">
<xs:annotatio n>
<xs:documentati on>
Add a group.
The response is either a SuccessResponse or an ErrorResponse.
</xs:documentatio n>
</xs:annotation>
<xs:complexCont ent>
<xs:extension base="Request">
<xs:sequence>
<xs:element name="servicePr oviderId" type="xs:string "/>
<xs:element name="groupId" type="xs:string "/>
<xs:element name="defaultDo main" type="xs:string "/>
<xs:element name="userLimit " type="xs:string "/>
<xs:element name="groupName " type="xs:string " minOccurs="0"/>
<xs:element name="callingLi neIdName" type="xs:string "
minOccurs="0"/>
<xs:element name="timeZone" type="xs:string " minOccurs="0"/>
<xs:element name="locationD ialingCode" type="xs:string "
minOccurs="0"/>
<xs:element name="contact" type="xs:string " minOccurs="0"/>
<xs:element name="address" type="xs:string " minOccurs="0"/>
</xs:sequence>
</xs:extension>
</xs:complexConte nt>
</xs:complexType>
*************** *******

Apr 7 '06 #1
4 4533


Ganesh Muthuvelu wrote:

Let us say that I have a schema or complex type like this one below:

Is there a way programtically or a tool to create sample XML file/data for
the schema?.


Both .NET and MSXML (4 and later) provide a schema object model (SOM)
which you can use to traverse XSD schemas programmaticall y and extract
element/attribute/type declarations. But of course getting from that to
a sample document is additional work.

MSXML SOM documentation is here:
<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/xmlsdk/html/85b447ee-70d0-4456-9ad7-70b4e2d1f3fa.as p>

..NET 2.0 SOM introduction is here:
<http://msdn2.microsoft .com/en-us/library/ms255931.aspx>

..NET 1.x SOM introduction is here:
<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/cpguide/html/cpconxsdschemao bjectmodelsom.a sp>

..NET 2.0 has an API for inferring a schema from an instance document but
there is no direct API for what you want to (the other way round).

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Apr 7 '06 #2
Initially you could use a tool like Altova XML Spy (or equivalent)

It has under the DTD/Schema menu an option Generate Sample XML File...

You could use this on a schema by schema basis.

But is a bit "manual"

Perhaps you want an exe to allow you to operate on a batch of Schemas
or code from the System.XML Namespace to do a batch for you?

Apr 7 '06 #3
Not .NET so sort of the wrong group here but this may be of use.

http://www.sun.com/software/xml/deve...ancegenerator/

Dickster

Apr 7 '06 #4
The following article describes how you can use classes in the
System.XML.Sche ma namespace of the Microsoft .NET Framework to build a tool
that generates sample XML documents that conform to a given schema:
http://msdn.microsoft.com/library/en...tml/xmlgen.asp

--
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
"Ganesh Muthuvelu" <Ga************ *@discussions.m icrosoft.com> wrote in
message news:C3******** *************** ***********@mic rosoft.com...
Hello,
Let us say that I have a schema or complex type like this one below:

Is there a way programtically or a tool to create sample XML file/data for
the schema?. I have number of such complex tpyer/schemas for which I need
to
create sample XMLs so I thought of doing it programatically .. Any pointers
would be appreciated.

Thanks.

*************** *******
<xs:complexTy pe name="AddReques t">
<xs:annotatio n>
<xs:documentati on>
Add a group.
The response is either a SuccessResponse or an ErrorResponse.
</xs:documentatio n>
</xs:annotation>
<xs:complexCont ent>
<xs:extension base="Request">
<xs:sequence>
<xs:element name="servicePr oviderId" type="xs:string "/>
<xs:element name="groupId" type="xs:string "/>
<xs:element name="defaultDo main" type="xs:string "/>
<xs:element name="userLimit " type="xs:string "/>
<xs:element name="groupName " type="xs:string " minOccurs="0"/>
<xs:element name="callingLi neIdName" type="xs:string "
minOccurs="0"/>
<xs:element name="timeZone" type="xs:string " minOccurs="0"/>
<xs:element name="locationD ialingCode" type="xs:string "
minOccurs="0"/>
<xs:element name="contact" type="xs:string " minOccurs="0"/>
<xs:element name="address" type="xs:string " minOccurs="0"/>
</xs:sequence>
</xs:extension>
</xs:complexConte nt>
</xs:complexType>
*************** *******

Apr 7 '06 #5

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

Similar topics

2
4057
by: Josh Martin | last post by:
comp.text.xml - I've developed a simple XSLT program that generates a sample XML file from a schema (note, it won't work in every instance, but works for this program). My problem: how do I tell if an element encountered in the schema is recursive? Without knowing this, the sample XML is generated indefinitely. Here is a simple example: <schema> <complexType name="Package">
6
2578
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a schema for it with Visual Studio, I get the error "Failed to create a schema for this data file because:
6
1574
by: Stefano | last post by:
Hi all, I defined a XML Schema... so I've a .xsd file. I defined the schema using "default" attribute... for example: <xs:element name="color" type="xs:string" default="red"/> Now, I would like to generate an empty XML file, from the XML Schema. How can I do that?
0
1005
by: AlexAdam | last post by:
I have been trying to find a sample coding in C# of how to create the XmlDocument based on its XSD schema fixed or default element values. I could accomplisht this work somehow like this: (but want to believe that there is far more simple solution for this little problem, so any ideas?) 1) Create the empty DataSet 2) Use ReadXmlSchema methods and read the schema that contains fixed or default element values. 3) Loop each element and...
1
1172
by: Ganesh Muthuvelu | last post by:
Hello, I have data contained in different tables in the SQL Server database. Now I need to pull data from these tables (using a SP or a simple query) and then create a XML file that conforms to a particular XSD. I was just wondering if I could get any pointers on how I can use the .NET XML libraries to this. Any help will be appreciated. Thanks, Ganesh
0
1049
by: dsijta | last post by:
I am trying to load the following XML file into a database table. I receive the file from an external source exactly as follows: <list type='full' level='state' val='CA'> <ac val='714'> <ph val='2011882' /> <ph val='2013327' /> <ph val='2016543' /> <ph val='2017632' /> <ph val='2017656' />
0
1559
by: delphiconsultingguy | last post by:
Hi all, Spent WAAAYYY too much time trying to figure this out because there's not many good examples out there, so in the interest of sparing y'all from suff'rin same, I've pasted it into eternity for you. Works like a charm. (I know, I know, I love you too) Sean
4
3320
by: Jan | last post by:
Have an SQL create/import script. Running this on SQL would make it create a table with some values. Can Access2003 somehow use such and SQL script? I went into SQL query view to try it out, but the amount of data was too big to paste in according to Access. Sample data: -- -- PostgreSQL database dump
1
1193
by: donet programmer | last post by:
I have a requirement where I need to create a dataset that consists of a table inside a table ( a child table inside a parent table). I am not really familiar with the data relations and not sure how to represent this relation. I did create a schema and it looks good on paper, but when I create a dataset from this schema it does not allow me to write to the child table. I am elaborate more if required. This is what my schema looks...
0
8262
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8701
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
8502
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...
0
7192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6122
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...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2623
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
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1507
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.