Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Annotated XSD Problem

Status
Not open for further replies.

hoochimama20

Programmer
Feb 1, 2004
2
AU
Hi,

I have the following xml file:

-----------------------------------------------------------
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<bulletin>
<story>
<category>E</category>
<storyname>53952</storyname>
<image src=&quot;N.jpg&quot; caption=&quot;A&quot; alt=&quot;As&quot; credit=&quot;AP&quot;/>
</story>
-----------------------------------------------------------

That I want to XmlBulkLoad into a database table with schema News(category, storyname, src, caption). I am trying to write an Annotated xsd to map the elements from the xml file to the columns in the database table News. This is my attempt at an xsd so far:

-----------------------------------------------------------
<?xml version=&quot;1.0&quot; encoding=&quot;windows-1252&quot; standalone=&quot;no&quot;?>
<xsd:schema xmlns:msch=&quot;urn:schemas-microsoft-com:mapping-schema&quot; xmlns:dt=&quot;urn:schemas-microsoft-com:datatypes&quot; xmlns:xsd=&quot; <xsd:element name=&quot;bulletin&quot; type=&quot;bulletin_type&quot; msch:is-constant=&quot;1&quot;/>
<xsd:complexType name=&quot;bulletin_type&quot;>
<xsd:all>
<xsd:element name=&quot;story&quot; type=&quot;story_type&quot; msch:relation=&quot;News&quot;/>
</xsd:all>
</xsd:complexType>
<xsd:element name=&quot;story&quot; type=&quot;story_type&quot; msch:relation=&quot;News&quot;/>
<xsd:complexType name=&quot;story_type&quot;>
<xsd:all>
<xsd:element name=&quot;category&quot; msch:field=&quot;Category&quot;/>
<xsd:element name=&quot;storyname&quot; msch:field=&quot;StoryName&quot;/>
<xsd:element name=&quot;image&quot; msch:relation=&quot;News&quot; type=&quot;image_type&quot;/>
</xsd:all>
</xsd:complexType>
<xsd:element name=&quot;category&quot; msch:field=&quot;category&quot;/>
<xsd:element name=&quot;storyname&quot; msch:field=&quot;storyname&quot;/>
<xsd:element name=&quot;image&quot; type=&quot;image_type&quot; msch:relation=&quot;News&quot;/>
<xsd:complexType name=&quot;image_type&quot;>
<xsd:attribute name=&quot;src&quot; msch:field=&quot;src&quot;/>
<xsd:attribute name=&quot;caption&quot; msch:field=&quot;caption&quot;/>
</xsd:complexType>
<xsd:attribute name=&quot;src&quot; msch:field=&quot;src&quot;/>
<xsd:attribute name=&quot;caption&quot; msch:field=&quot;caption&quot;/>
</xsd:schema>
-----------------------------------------------------------

Does anyone know how I can write this XSD to map the attributes of image to the 2 columns src and caption in the table News.
 
Hi,

Instead of XSD, try XSLT. You need to &quot;transform&quot; something here, and that's what XSLT is for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top