471,078 Members | 792 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,078 software developers and data experts.

SQL 2005 AND SQLXMLBulkLoad

Hi, Am I right in saying that by default, an element of complex type
in an XSD annotated schema maps to the table with the same name in the
specified database. If so does anyone have any idea why my app runs
with no errors, but doesn't add anything to the table in the DB. I was
hoping to find the value 'GDS-2392265' in the table.

Any Ideas?
Thanks in advance.
Rich
vb.net code
-----------------

Dim objBL
objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data source=xxx
\SQLEXPRESS;database=xxx;uid=sa;pwd=xxxxx"
objBL.ErrorLogFile = "c:\error.log"
objBL.KeepIdentity = False
objBL.Execute("c:\SCHEMA.XML", "c:\INPUT.XML")
objBL = Nothing

Me.Enabled = True
DB Table Def
-------------------

CREATE TABLE [dbo].[FeatureCollection](
[fid] [nchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
Schema File
------------------

<?xml version="1.0" ?>
<xsd:schema xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:osgb="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<xsd:element name="FeatureCollection">
<xsd:complexType>
<xsd:attribute name="fid" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

</xsd:schema>
XML File
------------

<?xml version='1.0' encoding='UTF-8'?>
<osgb:FeatureCollection
xmlns:osgb='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb'
xmlns:gml='http://www.opengis.net/gml'
xmlns:xlink='http://www.w3.org/1999/xlink'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://www.ordnancesurvey.co.uk/xml/namespaces/
osgb http://www.ordnancesurvey.co.uk/xml/schema/v5/OSDNFFeatures.xsd'
fid='GDS-2392265'>
</osgb:FeatureCollection>

Feb 20 '07 #1
1 5366
On Feb 19, 5:02 pm, "rrowles2000" <rich...@rowles.co.ukwrote:
Hi, Am I right in saying that by default, an element of complex type
in an XSD annotated schema maps to the table with the same name in the
specified database. If so does anyone have any idea why my app runs
with no errors, but doesn't add anything to the table in the DB. I was
hoping to find the value 'GDS-2392265' in the table.

Any Ideas?
Thanks in advance.
Rich

vb.net code
-----------------

Dim objBL
objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data source=xxx
\SQLEXPRESS;database=xxx;uid=sa;pwd=xxxxx"
objBL.ErrorLogFile = "c:\error.log"
objBL.KeepIdentity = False
objBL.Execute("c:\SCHEMA.XML", "c:\INPUT.XML")
objBL = Nothing

Me.Enabled = True

DB Table Def
-------------------

CREATE TABLE [dbo].[FeatureCollection](
[fid] [nchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]

Schema File
------------------

<?xml version="1.0" ?>
<xsd:schema xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:osgb="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<xsd:element name="FeatureCollection">
<xsd:complexType>
<xsd:attribute name="fid" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

</xsd:schema>

XML File
------------

<?xml version='1.0' encoding='UTF-8'?>
<osgb:FeatureCollection
xmlns:osgb='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb'
xmlns:gml='http://www.opengis.net/gml'
xmlns:xlink='http://www.w3.org/1999/xlink'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://www.ordnancesurvey.co.uk/xml/namespaces/
osgbhttp://www.ordnancesurvey.co.uk/xml/schema/v5/OSDNFFeatures.xsd'
fid='GDS-2392265'>
</osgb:FeatureCollection>
Hi -

Got this information from a GML guru. Not sure if it helps, but
perhaps worth a try:

Looks like the SQLXMLBulkLoad utility only wants to load the
"default"
namespace (i.e. no prefix). So, simply make GML the the default
namespace:

<MyFeatureCollection xmlns="http://www.opengis.org/gml" ... >
....
</MyFeatureCollection>

This way any "unqualified" elements are assumed to be in the gml
namespace and, presumably, SQLXMLBulkLoad would load the data.

Regards

Carl

Feb 20 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.