-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_simple_XSD.ps1
28 lines (26 loc) · 1.03 KB
/
generate_simple_XSD.ps1
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
cls
$xsdname = Read-Host "XSD Template name"
$csv = Read-Host "List of fields (comma-separated)"
$xsddata= ""
$xsddata += "<?xml version=`"1.0`" encoding=`"UTF-8`"?>`n"
$xsddata += "<xs:schema xmlns:xs=`"http://www.w3.org/2001/XMLSchema`" elementFormDefault=`"qualified`">`n"
$xsddata += "<xs:element name=`"Records`">`n"
$xsddata += " <xs:complexType>`n"
$xsddata += " <xs:sequence>`n"
$xsddata += " <xs:element name=`"Record`" maxOccurs=`"unbounded`">`n"
$xsddata += " <xs:complexType>`n"
$xsddata += " <xs:sequence>`n"
for($f=0; $f -lt $csv.Split(",").Length;$f++){
$v = $csv.Split(",")[$f]
$xsddata += " <xs:element name=`"$v`" type=`"xs:string`" maxOccurs=`"1`" minOccurs=`"0`" />`n"
}
$xsddata += " </xs:sequence>`n"
$xsddata += " </xs:complexType>`n"
$xsddata += " </xs:element>`n"
$xsddata += " </xs:sequence>`n"
$xsddata += " </xs:complexType>`n"
$xsddata += "</xs:element>`n"
$xsddata += "</xs:schema>`n"
$p = $PSScriptRoot
$xsddata = $xsddata > ($p+'\'+$xsdname+'.xsd')