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

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:complexType name="AddRequest">
<xs:annotation>
<xs:documentation>
Add a group.
The response is either a SuccessResponse or an ErrorResponse.
</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="Request">
<xs:sequence>
<xs:element name="serviceProviderId" type="xs:string"/>
<xs:element name="groupId" type="xs:string"/>
<xs:element name="defaultDomain" type="xs:string"/>
<xs:element name="userLimit" type="xs:string"/>
<xs:element name="groupName" type="xs:string" minOccurs="0"/>
<xs:element name="callingLineIdName" type="xs:string"
minOccurs="0"/>
<xs:element name="timeZone" type="xs:string" minOccurs="0"/>
<xs:element name="locationDialingCode" 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:complexContent>
</xs:complexType>
**********************

Apr 7 '06 #1
4 4505


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 programmatically 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.asp>

..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/cpconxsdschemaobjectmodelsom.asp>

..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.Schema 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.microsoft.com> wrote in
message news:C3**********************************@microsof t.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:complexType name="AddRequest">
<xs:annotation>
<xs:documentation>
Add a group.
The response is either a SuccessResponse or an ErrorResponse.
</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="Request">
<xs:sequence>
<xs:element name="serviceProviderId" type="xs:string"/>
<xs:element name="groupId" type="xs:string"/>
<xs:element name="defaultDomain" type="xs:string"/>
<xs:element name="userLimit" type="xs:string"/>
<xs:element name="groupName" type="xs:string" minOccurs="0"/>
<xs:element name="callingLineIdName" type="xs:string"
minOccurs="0"/>
<xs:element name="timeZone" type="xs:string" minOccurs="0"/>
<xs:element name="locationDialingCode" 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:complexContent>
</xs:complexType>
**********************

Apr 7 '06 #5

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

Similar topics

2
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...
6
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...
6
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...
0
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...
1
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...
0
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...
0
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...
4
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.