473,727 Members | 2,015 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 4536


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
2588
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
1577
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
1007
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
1173
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
1051
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
1567
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
3338
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
1201
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
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9260
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9185
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9120
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
8103
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
6703
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
6011
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();...
0
4521
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3228
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

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.