Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Extracting schema..

Reply
 
Old 04-16-2008   #1 (permalink)
mr t


 
 

Extracting schema..

The DataTable xml written out, produces the following xml. can anyone
show me how to extract that schema and put it in external file? the
reason for this, is that I want to apply that structure to multiple
different xml files and don't want to change the structure in each
file. thanks. I guess it would involve to putting the content from
<xs:schema to </xs:schema> into xsd file and referencing it somehow?
don't know how to do that.

<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/
XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
<xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:MainDataTable="wg_Profile" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="wg_Profile" msprop:Name="Profile"
msprop:PK="MemberID">
<xs:complexType>
<xs:sequence>
<xs:element name="DbName" type="xs:string"
minOccurs="0" />
<xs:element name="Name" type="xs:string"
minOccurs="0" />
<xs:element name="Type" type="xs:string"
minOccurs="0" />
<xs:element name="SubType" type="xs:string"
minOccurs="0" />
<xs:element name="Pos" type="xs:int" minOccurs="0" />
<xs:element name="Length" type="xs:int" default="0"
minOccurs="0" />
<xs:element name="Options" type="xs:string"
minOccurs="0" />
<xs:element name="OptionsDirection" type="xs:string"
minOccurs="0" />
<xs:element name="InputType" type="xs:string"
minOccurs="0" />
<xs:element name="Display" type="xs:boolean"
minOccurs="0" />
<xs:element name="Default" type="xs:string"
minOccurs="0" />
<xs:element name="Required" type="xs:boolean"
minOccurs="0" />
<xs:element name="RequiredError" type="xs:boolean"
minOccurs="0" />
<xs:element name="InvalidDataError" type="xs:string"
minOccurs="0" />
<xs:element name="Group" type="xs:string"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<wg_Profile>
<DbName>MemberID</DbName>
</wg_Profile>
<wg_Profile>
<DbName>LastName</DbName>
</wg_Profile>
<wg_Profile>
<DbName>FirstName</DbName>
</wg_Profile>
<wg_Profile>
<DbName>ProfileName</DbName>
</wg_Profile>
<wg_Profile>
<DbName>Birthday</DbName>
<Name>Birthday MM/DD/YYYY</Name>
<SubType>Date</SubType>
<Display>true</Display>
<Default />
<Required>true</Required>
<InvalidDataError>Invalid Date MM/DD/YYYY</InvalidDataError>
</wg_Profile>
<wg_Profile>
<DbName>Gender</DbName>
<Name>Gender</Name>
<Options>Male;Female</Options>
<OptionsDirection>0</OptionsDirection>
<InputType>RadioList</InputType>
<Display>true</Display>
<Default>Female</Default>
<Required>true</Required>
</wg_Profile>
<wg_Profile>
</NewDataSet>

My System SpecsSystem Spec
Old 04-17-2008   #2 (permalink)
John Sheppard


 
 

Re: Extracting schema..

You can use the xsd.exe file to convert an xml file into an xsd file...

Here is some VERY scrappy code I wrote to do it...it will write a dataset
schema to an xsd file...


Dim xmloutput As String

xmloutput = bigResultdata.GetXmlSchema

xmloutput = xmloutput.Replace(" encoding=""utf-16""?>", "?>")

My.Computer.FileSystem.WriteAllText(My.Application.Info.DirectoryPath & "\"
& classname & ".xml", xmloutput, False)

ShellandWait(My.Application.Info.DirectoryPath & "\xsd.exe", """" &
My.Application.Info.DirectoryPath & "\" & classname & ".xml"" /c /l:vb /d",
My.Application.Info.DirectoryPath)

My.Computer.FileSystem.CopyFile(My.Application.Info.DirectoryPath & "\" &
classname & ".xml", outputdir & "\" & classname & ".xsd", True)

Hope that helps

John Sheppard

"mr t" <tascien@xxxxxx> wrote in message
news:96d7c58c-c8a8-4d2d-ad34-944177483272@xxxxxx
Quote:

> The DataTable xml written out, produces the following xml. can anyone
> show me how to extract that schema and put it in external file? the
> reason for this, is that I want to apply that structure to multiple
> different xml files and don't want to change the structure in each
> file. thanks. I guess it would involve to putting the content from
> <xs:schema to </xs:schema> into xsd file and referencing it somehow?
> don't know how to do that.
>
> <NewDataSet>
> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/
> XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
> <xs:element name="NewDataSet" msdata:IsDataSet="true"
> msdata:MainDataTable="wg_Profile" msdata:UseCurrentLocale="true">
> <xs:complexType>
> <xs:choice minOccurs="0" maxOccurs="unbounded">
> <xs:element name="wg_Profile" msprop:Name="Profile"
> msprop:PK="MemberID">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="DbName" type="xs:string"
> minOccurs="0" />
> <xs:element name="Name" type="xs:string"
> minOccurs="0" />
> <xs:element name="Type" type="xs:string"
> minOccurs="0" />
> <xs:element name="SubType" type="xs:string"
> minOccurs="0" />
> <xs:element name="Pos" type="xs:int" minOccurs="0" />
> <xs:element name="Length" type="xs:int" default="0"
> minOccurs="0" />
> <xs:element name="Options" type="xs:string"
> minOccurs="0" />
> <xs:element name="OptionsDirection" type="xs:string"
> minOccurs="0" />
> <xs:element name="InputType" type="xs:string"
> minOccurs="0" />
> <xs:element name="Display" type="xs:boolean"
> minOccurs="0" />
> <xs:element name="Default" type="xs:string"
> minOccurs="0" />
> <xs:element name="Required" type="xs:boolean"
> minOccurs="0" />
> <xs:element name="RequiredError" type="xs:boolean"
> minOccurs="0" />
> <xs:element name="InvalidDataError" type="xs:string"
> minOccurs="0" />
> <xs:element name="Group" type="xs:string"
> minOccurs="0" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:choice>
> </xs:complexType>
> </xs:element>
> </xs:schema>
> <wg_Profile>
> <DbName>MemberID</DbName>
> </wg_Profile>
> <wg_Profile>
> <DbName>LastName</DbName>
> </wg_Profile>
> <wg_Profile>
> <DbName>FirstName</DbName>
> </wg_Profile>
> <wg_Profile>
> <DbName>ProfileName</DbName>
> </wg_Profile>
> <wg_Profile>
> <DbName>Birthday</DbName>
> <Name>Birthday MM/DD/YYYY</Name>
> <SubType>Date</SubType>
> <Display>true</Display>
> <Default />
> <Required>true</Required>
> <InvalidDataError>Invalid Date MM/DD/YYYY</InvalidDataError>
> </wg_Profile>
> <wg_Profile>
> <DbName>Gender</DbName>
> <Name>Gender</Name>
> <Options>Male;Female</Options>
> <OptionsDirection>0</OptionsDirection>
> <InputType>RadioList</InputType>
> <Display>true</Display>
> <Default>Female</Default>
> <Required>true</Required>
> </wg_Profile>
> <wg_Profile>
> </NewDataSet>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
XML with schema .NET General
Need to program it anyone know schema Live Mail
Help With Program Created XML Schema .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46