Wednesday, March 28, 2012

Mapping database in XSD

I have an xsd document that I want to map to a database.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/
XMLSchema">
<xs:element name="ComputerScan">
<xs:complexType>
<xs:sequence>
<xs:element name="scanheader">
<xs:complexType>
<xs:sequence>
<xs:element name="ScanDate" type="xs:string" />
<xs:element name="UniqueID" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="computer">
<xs:complexType>
<xs:sequence>
<xs:element name="ComputerName" type="xs:string" />
<xs:element name="ClientID" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="scans">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="scan">
<xs:complexType>
<xs:sequence>
<xs:element name="scanattributes">
<xs:complexType>
<xs:sequence minOccurs="0">
<xs:element maxOccurs="unbounded"
name="scanattribute">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="GUID"
type="xs:string" use="required" />
<xs:attribute name="GUParentID"
type="xs:string" use="required" />
<xs:attribute name="Name"
type="xs:string" use="required" />
<xs:attribute name="LastModified"
type="xs:dateTime" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="ID" type="xs:decimal"
use="required" />
<xs:attribute name="Section" type="xs:string"
use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Here is a snippet of the xml this applies to(not whole thing because
it is very large)
<?xml version="1.0" encoding="utf-8"?>
<ComputerScan>
<scanheader>
<ScanDate>6/13/2007 8:00:10 AM</ScanDate>
<UniqueID>20:41:53:59:4E:FF</UniqueID>
</scanheader>
<computer>
<ComputerName>DSSESCDVLPR02</ComputerName>
<ClientID>New Client</ClientID>
</computer>
<scans>
<scan ID="1.0" Section="Drives">
<scanattributes>
<scanattribute GUID="baacad7f-dd5b-4883-a24e-1d4d66a32345"
GUParentID="" Name="Letter"
LastModified="2007-06-13T08:00:54.937888-04:00">C:</scanattribute>
<scanattribute GUID="9b393147-9085-4068-9ce4-fd65209b5d02"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Drive Type"
LastModified="2007-06-13T08:00:54.9679312-04:00">Local Disk</
scanattribute>
<scanattribute GUID="2ab90c79-9baa-49a7-8065-dae46b3b1727"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Percent Used"
LastModified="2007-06-13T08:00:54.9679312-04:00">97%</scanattribute>
<scanattribute GUID="5d327b08-6bde-4102-9aaa-b86024ab61e8"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Used Space"
LastModified="2007-06-13T08:00:54.9679312-04:00">22.89 GB</
scanattribute>
<scanattribute GUID="7f685ca6-fec2-476e-bad9-7348eea24ba6"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Free Space"
LastModified="2007-06-13T08:00:54.9679312-04:00">0.54 GB</
scanattribute>
<scanattribute GUID="24dee5e9-4b94-44ff-825e-a257c8f92786"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Total Space"
LastModified="2007-06-13T08:00:54.9679312-04:00">23.44 GB</
scanattribute>
<scanattribute GUID="b1963c6a-f77e-43f6-a86c-ca6453ab6d8f"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Drive Name"
LastModified="2007-06-13T08:00:54.9679312-04:00">C:</scanattribute>
<scanattribute GUID="e4a816a7-c62f-45a4-bb0c-ffe5e1cb67a9"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="File System
Type" LastModified="2007-06-13T08:00:54.9679312-04:00">NTFS</
scanattribute>
<scanattribute GUID="0b9d5e25-dd91-4e96-bf18-59f0b42f71eb"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Drive Serial
Number" LastModified="2007-06-13T08:00:54.9679312-04:00">7468D306</
scanattribute>
<scanattribute GUID="dfed9095-1e25-4789-bdae-4b7b51502170"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Sectors Per
Cluster" LastModified="2007-06-13T08:00:54.9679312-04:00">8</
scanattribute>
<scanattribute GUID="59c3b840-c2f6-4ced-a1ac-604e117f5ef4"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Bytes Per
Cluster" LastModified="2007-06-13T08:00:54.9679312-04:00">512</
scanattribute>
<scanattribute GUID="f2165a88-35ca-4507-a3eb-4bb36c386d68"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Free Clusters"
LastModified="2007-06-13T08:00:54.9679312-04:00">141935</
scanattribute>
<scanattribute GUID="cfaf034a-517c-46c1-b327-e9f41293d417"
GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Total
Clusters" LastModified="2007-06-13T08:00:54.9679312-04:00">6144854</
scanattribute>
<scanattribute GUID="bab83616-3e69-4a28-9bb3-c59508fcdc72"
GUParentID="" Name="Letter"
LastModified="2007-06-13T08:00:54.9679312-04:00">D:</scanattribute>
<scanattribute GUID="078da3b2-1895-4e5c-9dbf-971d95267099"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Drive Type"
LastModified="2007-06-13T08:00:54.9679312-04:00">Local Disk</
scanattribute>
<scanattribute GUID="1dbd0b90-006c-40a1-a828-182a32579e35"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Percent Used"
LastModified="2007-06-13T08:00:54.9679312-04:00">82%</scanattribute>
<scanattribute GUID="e94dbfb9-b15c-4382-a98b-2cfc8b6a5a68"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Used Space"
LastModified="2007-06-13T08:00:54.9679312-04:00">11.46 GB</
scanattribute>
<scanattribute GUID="5cab4178-9f86-4ca8-8c22-23a4b1b99ffa"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Free Space"
LastModified="2007-06-13T08:00:54.9679312-04:00">2.35 GB</
scanattribute>
<scanattribute GUID="ad5621c1-72f8-4d23-9be1-d7d90bc5fa07"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Total Space"
LastModified="2007-06-13T08:00:54.9679312-04:00">13.81 GB</
scanattribute>
<scanattribute GUID="43e63657-7436-4b65-b178-2ce839c2d204"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Drive Name"
LastModified="2007-06-13T08:00:54.9679312-04:00">D:</scanattribute>
<scanattribute GUID="4cb8a3e9-6a03-42d2-b2e8-90e59ccbced1"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="File System
Type" LastModified="2007-06-13T08:00:54.9679312-04:00">NTFS</
scanattribute>
<scanattribute GUID="31c7f4e0-2730-4e46-b5d1-92f9c60a5472"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Drive Serial
Number" LastModified="2007-06-13T08:00:54.9679312-04:00">B4289EC3</
scanattribute>
<scanattribute GUID="4c52feba-a62b-42f5-9241-3bacc9ccb773"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Sectors Per
Cluster" LastModified="2007-06-13T08:00:54.9679312-04:00">8</
scanattribute>
<scanattribute GUID="a53d3df3-f935-4300-ba1b-59d5dcc406f1"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Bytes Per
Cluster" LastModified="2007-06-13T08:00:54.9679312-04:00">512</
scanattribute>
<scanattribute GUID="299b062c-6246-401d-8ac4-9d73c6556825"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Free Clusters"
LastModified="2007-06-13T08:00:54.9679312-04:00">141935</
scanattribute>
<scanattribute GUID="8665555b-e8be-44e5-814d-1ed781cb2fd7"
GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Total
Clusters" LastModified="2007-06-13T08:00:54.9679312-04:00">6144854</
scanattribute>
<scanattribute GUID="5827ab65-10ba-4630-a3d5-917e3b160c06"
GUParentID="" Name="Letter"
LastModified="2007-06-13T08:00:54.9679312-04:00">E:</scanattribute>
<scanattribute GUID="30e4cb79-d178-4126-980a-7d954bcf535b"
GUParentID="5827ab65-10ba-4630-a3d5-917e3b160c06" Name="Drive Type"
LastModified="2007-06-13T08:00:54.9679312-04:00">Compact Disc</
scanattribute>
</scanattributes>
</scan>
<scan ID="2.0" Section="Error Logs">
<scanattributes>
.....................
I have three tables I need information from my xml mapped to.
tblAsset has columns for ComputerName, ScanDate, and UniqueID
tblScan has columns for the exact same data.
tblScanDetails has columns for UniqueID, GUID, GUParentID, Name,
LastModified, and the text for all the scanattributes.
How would I change my xsd to map these tables and columns'On Jul 11, 11:31 am, rhaazy <rha...@.gmail.com> wrote:
> I have an xsd document that I want to map to a database.
> <?xml version="1.0" encoding="utf-8"?>
> <xs:schema attributeFormDefault="unqualified"
> elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/
> XMLSchema">
> <xs:element name="ComputerScan">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="scanheader">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="ScanDate" type="xs:string" />
> <xs:element name="UniqueID" type="xs:string" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="computer">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="ComputerName" type="xs:string" />
> <xs:element name="ClientID" type="xs:string" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="scans">
> <xs:complexType>
> <xs:sequence>
> <xs:element maxOccurs="unbounded" name="scan">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="scanattributes">
> <xs:complexType>
> <xs:sequence minOccurs="0">
> <xs:element maxOccurs="unbounded"
> name="scanattribute">
> <xs:complexType>
> <xs:simpleContent>
> <xs:extension base="xs:string">
> <xs:attribute name="GUID"
> type="xs:string" use="required" />
> <xs:attribute name="GUParentID"
> type="xs:string" use="required" />
> <xs:attribute name="Name"
> type="xs:string" use="required" />
> <xs:attribute name="LastModified"
> type="xs:dateTime" use="required" />
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> <xs:attribute name="ID" type="xs:decimal"
> use="required" />
> <xs:attribute name="Section" type="xs:string"
> use="required" />
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema>
> Here is a snippet of the xml this applies to(not whole thing because
> it is very large)
> <?xml version="1.0" encoding="utf-8"?>
> <ComputerScan>
> <scanheader>
> <ScanDate>6/13/2007 8:00:10 AM</ScanDate>
> <UniqueID>20:41:53:59:4E:FF</UniqueID>
> </scanheader>
> <computer>
> <ComputerName>DSSESCDVLPR02</ComputerName>
> <ClientID>New Client</ClientID>
> </computer>
> <scans>
> <scan ID="1.0" Section="Drives">
> <scanattributes>
> <scanattribute GUID="baacad7f-dd5b-4883-a24e-1d4d66a32345"
> GUParentID="" Name="Letter"
> LastModified="2007-06-13T08:00:54.937888-04:00">C:</scanattribute>
> <scanattribute GUID="9b393147-9085-4068-9ce4-fd65209b5d02"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Drive Type"
> LastModified="2007-06-13T08:00:54.9679312-04:00">Local Disk</
> scanattribute>
> <scanattribute GUID="2ab90c79-9baa-49a7-8065-dae46b3b1727"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Percent Used"
> LastModified="2007-06-13T08:00:54.9679312-04:00">97%</scanattribute>
> <scanattribute GUID="5d327b08-6bde-4102-9aaa-b86024ab61e8"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Used Space"
> LastModified="2007-06-13T08:00:54.9679312-04:00">22.89 GB</
> scanattribute>
> <scanattribute GUID="7f685ca6-fec2-476e-bad9-7348eea24ba6"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Free Space"
> LastModified="2007-06-13T08:00:54.9679312-04:00">0.54 GB</
> scanattribute>
> <scanattribute GUID="24dee5e9-4b94-44ff-825e-a257c8f92786"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Total Space"
> LastModified="2007-06-13T08:00:54.9679312-04:00">23.44 GB</
> scanattribute>
> <scanattribute GUID="b1963c6a-f77e-43f6-a86c-ca6453ab6d8f"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Drive Name"
> LastModified="2007-06-13T08:00:54.9679312-04:00">C:</scanattribute>
> <scanattribute GUID="e4a816a7-c62f-45a4-bb0c-ffe5e1cb67a9"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="File System
> Type" LastModified="2007-06-13T08:00:54.9679312-04:00">NTFS</
> scanattribute>
> <scanattribute GUID="0b9d5e25-dd91-4e96-bf18-59f0b42f71eb"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Drive Serial
> Number" LastModified="2007-06-13T08:00:54.9679312-04:00">7468D306</
> scanattribute>
> <scanattribute GUID="dfed9095-1e25-4789-bdae-4b7b51502170"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Sectors Per
> Cluster" LastModified="2007-06-13T08:00:54.9679312-04:00">8</
> scanattribute>
> <scanattribute GUID="59c3b840-c2f6-4ced-a1ac-604e117f5ef4"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Bytes Per
> Cluster" LastModified="2007-06-13T08:00:54.9679312-04:00">512</
> scanattribute>
> <scanattribute GUID="f2165a88-35ca-4507-a3eb-4bb36c386d68"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Free Clusters"
> LastModified="2007-06-13T08:00:54.9679312-04:00">141935</
> scanattribute>
> <scanattribute GUID="cfaf034a-517c-46c1-b327-e9f41293d417"
> GUParentID="baacad7f-dd5b-4883-a24e-1d4d66a32345" Name="Total
> Clusters" LastModified="2007-06-13T08:00:54.9679312-04:00">6144854</
> scanattribute>
> <scanattribute GUID="bab83616-3e69-4a28-9bb3-c59508fcdc72"
> GUParentID="" Name="Letter"
> LastModified="2007-06-13T08:00:54.9679312-04:00">D:</scanattribute>
> <scanattribute GUID="078da3b2-1895-4e5c-9dbf-971d95267099"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Drive Type"
> LastModified="2007-06-13T08:00:54.9679312-04:00">Local Disk</
> scanattribute>
> <scanattribute GUID="1dbd0b90-006c-40a1-a828-182a32579e35"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Percent Used"
> LastModified="2007-06-13T08:00:54.9679312-04:00">82%</scanattribute>
> <scanattribute GUID="e94dbfb9-b15c-4382-a98b-2cfc8b6a5a68"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Used Space"
> LastModified="2007-06-13T08:00:54.9679312-04:00">11.46 GB</
> scanattribute>
> <scanattribute GUID="5cab4178-9f86-4ca8-8c22-23a4b1b99ffa"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Free Space"
> LastModified="2007-06-13T08:00:54.9679312-04:00">2.35 GB</
> scanattribute>
> <scanattribute GUID="ad5621c1-72f8-4d23-9be1-d7d90bc5fa07"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Total Space"
> LastModified="2007-06-13T08:00:54.9679312-04:00">13.81 GB</
> scanattribute>
> <scanattribute GUID="43e63657-7436-4b65-b178-2ce839c2d204"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Drive Name"
> LastModified="2007-06-13T08:00:54.9679312-04:00">D:</scanattribute>
> <scanattribute GUID="4cb8a3e9-6a03-42d2-b2e8-90e59ccbced1"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="File System
> Type" LastModified="2007-06-13T08:00:54.9679312-04:00">NTFS</
> scanattribute>
> <scanattribute GUID="31c7f4e0-2730-4e46-b5d1-92f9c60a5472"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Drive Serial
> Number" LastModified="2007-06-13T08:00:54.9679312-04:00">B4289EC3</
> scanattribute>
> <scanattribute GUID="4c52feba-a62b-42f5-9241-3bacc9ccb773"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Sectors Per
> Cluster" LastModified="2007-06-13T08:00:54.9679312-04:00">8</
> scanattribute>
> <scanattribute GUID="a53d3df3-f935-4300-ba1b-59d5dcc406f1"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Bytes Per
> Cluster" LastModified="2007-06-13T08:00:54.9679312-04:00">512</
> scanattribute>
> <scanattribute GUID="299b062c-6246-401d-8ac4-9d73c6556825"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Free Clusters"
> LastModified="2007-06-13T08:00:54.9679312-04:00">141935</
> scanattribute>
> <scanattribute GUID="8665555b-e8be-44e5-814d-1ed781cb2fd7"
> GUParentID="bab83616-3e69-4a28-9bb3-c59508fcdc72" Name="Total
> Clusters" LastModified="2007-06-13T08:00:54.9679312-04:00">6144854</
> scanattribute>
> <scanattribute GUID="5827ab65-10ba-4630-a3d5-917e3b160c06"
> GUParentID="" Name="Letter"
> LastModified="2007-06-13T08:00:54.9679312-04:00">E:</scanattribute>
> <scanattribute GUID="30e4cb79-d178-4126-980a-7d954bcf535b"
> GUParentID="5827ab65-10ba-4630-a3d5-917e3b160c06" Name="Drive Type"
> LastModified="2007-06-13T08:00:54.9679312-04:00">Compact Disc</
> scanattribute>
> </scanattributes>
> </scan>
> <scan ID="2.0" Section="Error Logs">
> <scanattributes>
> .....................
> I have three tables I need information from my xml mapped to.
> tblAsset has columns for ComputerName, ScanDate, and UniqueID
> tblScan has columns for the exact same data.
> tblScanDetails has columns for UniqueID, GUID, GUParentID, Name,
> LastModified, and the text for all the scanattributes.
> How would I change my xsd to map these tables and columns'
please disregard this topic, i was .

No comments:

Post a Comment