Populating Columns Based on Element Attribute?
- From: "Don Miller" <nospam@xxxxxxxxxx>
- Date: Thu, 26 Apr 2007 11:52:13 -0500
I'm trying to develop an XML View (XSD Schema) so I can bulkload
(SQLXMLBulkLoad) an XML file into a database. Based on the value of an
Element's attribute, I want to place data from the XML file into specific
columns. However, it appears I need some sort of conditional statement in
XSD that apparently does not exist.
The table (simplified) would be,
FACTS
------------------
FactID (int)
Category (varchar)
StringValue (varchar)
DateValue (date)
NumericValue (numeric)
The source XML is,
<Facts>
<Fact valueType="string">
<Category>Important Things</Category>
<Value>Christmas</Value>
</Fact>
<Fact valueType="date">
<Category>Holidays</Category>
<Value>12/25/06</Value>
</Fact>
<Fact valueType="numeric">
<Category>Academic</Category>
<Value>1.414</Value>
</Fact>
And I would like the resulting table to be filled like this with only ONE of
the columns populated with the Value:
FactID Category StringValue DateValue
NumericValue
------- ------------------ ------------- ------------ ---------------
1 Important Things Christmas NULL NULL
2 Holidays NULL 12/25/06 NULL
3 Academic NULL NULL 1.414
Is this possible with XSD? If not, will I need to first transform (somehow)
the XML to more easily map, column to column, with the database table?
Thanks for any help or direction.
.
- Follow-Ups:
- RE: Populating Columns Based on Element Attribute?
- From: Monica Frintu [MSFT]
- RE: Populating Columns Based on Element Attribute?
- Prev by Date: Re: Calling SQLXML From XSLT
- Next by Date: Re: Calling SQLXML From XSLT
- Previous by thread: MSSQL2K FOR XML Explicit help?
- Next by thread: RE: Populating Columns Based on Element Attribute?
- Index(es):
Relevant Pages
|