Home > Archive > MS SQL XML > July 2005 > SQLXML Namespaces









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SQLXML Namespaces
aowen355

2005-07-05, 8:24 pm

I am trying to extract information from an SQL database and convert it
to an XML file. The schema for this xml file is defined in an xsd
document.

For some reason though the outputted XML information looks like this
<y0:Name xmlns:y0="http://www.ns.com/3.0">Test Text</y0:Name>

I dont understand why it is ammending the y0: information, I just want
it to look like this
<Name>Test Text</Name>

I know this must have something to do with my xmlns definitions in the
xsd file but i dont know how to correct this, can someone point me in
the right direction please??

--
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/XML-SQL-Nam...pict237713.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbforumz.com/eform.php?p=826230
Graeme Malcolm

2005-07-06, 3:23 am

Your schema must have a default or target namespace declaration for the
http://www.ns.com/3.0 namespace. Semantically,
<y0:Name xmlns:y0="http://www.ns.com/3.0">Test Text</y0:Name>
is exactly the same as:
<Name xmlns="http://www.ns.com/3.0">Test Text</Name>
or even:
<mydata xmlns="http://www.ns.com/3.0">
<Name>Test Text</Name>
</mydata>

The way to "Fix" the namespace issue depends on how you're extracting the
data from SQL Server. Can you post a little more information, such as the
schema, the table defs, and any script you're using?

--
Graeme Malcolm
Principal Technologist
Content Master
- a member of CM Group Ltd.
www.contentmaster.com


"aowen355" < UseLinkToEmail@dbFor
umz.com> wrote in message
news:4_826230_972918
b7e86b589084aea48a16
79c9d8@dbforumz.com...
I am trying to extract information from an SQL database and convert it
to an XML file. The schema for this xml file is defined in an xsd
document.

For some reason though the outputted XML information looks like this
<y0:Name xmlns:y0="http://www.ns.com/3.0">Test Text</y0:Name>

I dont understand why it is ammending the y0: information, I just want
it to look like this
<Name>Test Text</Name>

I know this must have something to do with my xmlns definitions in the
xsd file but i dont know how to correct this, can someone point me in
the right direction please??

--
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/XML-SQL-Nam...pict237713.html
Visit Topic URL to contact author (reg. req'd). Report abuse:
http://www.dbforumz.com/eform.php?p=826230


aowen355

2005-07-06, 8:24 pm

"" wrote:
> Your schema must have a default or target namespace
> declaration for the
> http://www.ns.com/3.0 namespace. Semantically,
> <y0:Name xmlns:y0="http://www.ns.com/3.0">Test Text</y0:Name>
> is exactly the same as:
> <Name xmlns="http://www.ns.com/3.0">Test Text</Name>
> or even:
> <mydata xmlns="http://www.ns.com/3.0">
> <Name>Test Text</Name>
> </mydata>
>
> The way to "Fix" the namespace issue depends on how you're
> extracting the
> data from SQL Server. Can you post a little more information,
> such as the
> schema, the table defs, and any script you're using?
>
> --
> Graeme Malcolm
> Principal Technologist
> Content Master
> - a member of CM Group Ltd.
> www.contentmaster.com
>
>
> "aowen355" < UseLinkToEmail@dbFor
umz.com> wrote in message
> news:4_826230_972918
b7e86b589084aea48a16
79c9d8@dbforumz.com...
> I am trying to extract information from an SQL database and
> convert it
> to an XML file. The schema for this xml file is defined in an
> xsd
> document.
>
> For some reason though the outputted XML information looks
> like this
> <y0:Name xmlns:y0="http://www.ns.com/3.0">Test Text</y0:Name>
>
> I dont understand why it is ammending the y0: information, I
> just want
> it to look like this
> <Name>Test Text</Name>
>
> I know this must have something to do with my xmlns
> definitions in the
> xsd file but i dont know how to correct this, can someone
> point me in
> the right direction please??
>
> --
> Posted using the http://www.dbforumz.com interface, at
> author's request
> Articles individually checked for conformance to usenet
> standards
> Topic URL:
> http://www.dbforumz.com/XML-SQL-Nam...pict237713.html
> Visit Topic URL to contact author (reg. req'd). Report abuse:
>
> http://www.dbforumz.com/eform.php?p=826230


ok, here is more information:

<xsd:schema xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:j="http://www.ns.com/3.0" elementFormDefault="unqualified"
attributeFormDefault
="unqualified">

<xsd:annotation>
<xsd:appinfo>
<!--to keep this short, i am only showing one relationship, my file
has several-->
<sql:relationship name="MasterData" parent="P_INCID_ENTITY_TAB"
parent-key="MSTR_NO" child="P_MSTR_TAB" child-key="MSTR_NO"/>
</xsd:annotation>
</xsd:appinfo>
<xsd:import namespace="http://www.ns.com/3.0"
schemaLocation="ao/3.0/sch1.xsd"/>

<xsd:element name="I_REPORT" sql:relation="P_INCID_ENTITY_TAB" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name="LocationStreet" sql:is-constant="1">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="j:StreetNumberText"
sql:field="Primary_Street_Num" sql:relation="P_INCID_TAB"
sql:relationship="MasterData"/>
<xsd:element ref="j:StreetName"
sql:field="Primary_Street_Name" sql:relation="P_INCID_TAB"
sql:relationship="MasterData"/> </xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complex type>

The place where I am having the problem is the output from the two
element ref lines. (j:StreetNumberText and j:StreetName)
There is more to this code, but i think this shows the needed info,
let me know if you need more.
Thank you so very much

-Andrew
Graeme Malcolm

2005-07-07, 7:24 am

So, actually the results are correct - you've returned elements in the
http://www.ns.com/3.0 namespace in the midst of elements in no specific
namespace, so SQLXML has declared an arbitrary prefix for the namespace and
used it. The actual prefix is irrelevant - You've used "j" in the schema,
SQLXML has used "y0" in the results, and in any code that you use to process
the results you can declare any prefix you like and the XML parser will
match the elements based on the namespace.

Cheers,
Graeme
--
Graeme Malcolm
Principal Technologist
Content Master
- a member of CM Group Ltd.
www.contentmaster.com


"aowen355" <DoNotEmail@dbForumz.com> wrote in message
news:4_827127_fc06dd
1e6a5dbca855cb665b09
a575ca@dbforumz.com...
"" wrote:
> Your schema must have a default or target namespace
> declaration for the
> http://www.ns.com/3.0 namespace. Semantically,
> <y0:Name xmlns:y0="http://www.ns.com/3.0">Test Text</y0:Name>
> is exactly the same as:
> <Name xmlns="http://www.ns.com/3.0">Test Text</Name>
> or even:
> <mydata xmlns="http://www.ns.com/3.0">
> <Name>Test Text</Name>
> </mydata>
>
> The way to "Fix" the namespace issue depends on how you're
> extracting the
> data from SQL Server. Can you post a little more information,
> such as the
> schema, the table defs, and any script you're using?
>
> --
> Graeme Malcolm
> Principal Technologist
> Content Master
> - a member of CM Group Ltd.
> www.contentmaster.com
>
>
> "aowen355" < UseLinkToEmail@dbFor
umz.com> wrote in message
> news:4_826230_972918
b7e86b589084aea48a16
79c9d8@dbforumz.com...
> I am trying to extract information from an SQL database and
> convert it
> to an XML file. The schema for this xml file is defined in an
> xsd
> document.
>
> For some reason though the outputted XML information looks
> like this
> <y0:Name xmlns:y0="http://www.ns.com/3.0">Test Text</y0:Name>
>
> I dont understand why it is ammending the y0: information, I
> just want
> it to look like this
> <Name>Test Text</Name>
>
> I know this must have something to do with my xmlns
> definitions in the
> xsd file but i dont know how to correct this, can someone
> point me in
> the right direction please??
>
> --
> Posted using the http://www.dbforumz.com interface, at
> author's request
> Articles individually checked for conformance to usenet
> standards
> Topic URL:
> http://www.dbforumz.com/XML-SQL-Nam...pict237713.html
> Visit Topic URL to contact author (reg. req'd). Report abuse:
>
> http://www.dbforumz.com/eform.php?p=826230


ok, here is more information:

<xsd:schema xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:j="http://www.ns.com/3.0" elementFormDefault="unqualified"
attributeFormDefault
="unqualified">

<xsd:annotation>
<xsd:appinfo>
<!--to keep this short, i am only showing one relationship, my file
has several-->
<sql:relationship name="MasterData" parent="P_INCID_ENTITY_TAB"
parent-key="MSTR_NO" child="P_MSTR_TAB" child-key="MSTR_NO"/>
</xsd:annotation>
</xsd:appinfo>
<xsd:import namespace="http://www.ns.com/3.0"
schemaLocation="ao/3.0/sch1.xsd"/>

<xsd:element name="I_REPORT" sql:relation="P_INCID_ENTITY_TAB" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name="LocationStreet" sql:is-constant="1">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="j:StreetNumberText"
sql:field="Primary_Street_Num" sql:relation="P_INCID_TAB"
sql:relationship="MasterData"/>
<xsd:element ref="j:StreetName"
sql:field="Primary_Street_Name" sql:relation="P_INCID_TAB"
sql:relationship="MasterData"/> </xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complex type>

The place where I am having the problem is the output from the two
element ref lines. (j:StreetNumberText and j:StreetName)
There is more to this code, but i think this shows the needed info,
let me know if you need more.
Thank you so very much

-Andrew


aowen355

2005-07-07, 1:23 pm

"" wrote:
> So, actually the results are correct - you've returned
> elements in the
> http://www.ns.com/3.0 namespace in the midst of elements in no
> specific
> namespace, so SQLXML has declared an arbitrary prefix for the
> namespace and
> used it. The actual prefix is irrelevant - You've used "j" in
> the schema,
> SQLXML has used "y0" in the results, and in any code that you
> use to process
> the results you can declare any prefix you like and the XML
> parser will
> match the elements based on the namespace.
>
> Cheers,
> Graeme
> --
> Graeme Malcolm
> Principal Technologist
> Content Master
> - a member of CM Group Ltd.
> www.contentmaster.com
>
>
> "aowen355" <DoNotEmail@dbForumz.com> wrote in message
> news:4_827127_fc06dd
1e6a5dbca855cb665b09
a575ca@dbforumz.com...
> "" wrote:
> information,
> an
> I
> abuse:
>
> ok, here is more information:
>
> <xsd:schema
> xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:j="http://www.ns.com/3.0"
> elementFormDefault="unqualified"
> attributeFormDefault
="unqualified">
>
> <xsd:annotation>
> <xsd:appinfo>
> <!--to keep this short, i am only showing one relationship, my
> file
> has several-->
> <sql:relationship name="MasterData"
> parent="P_INCID_ENTITY_TAB"
> parent-key="MSTR_NO" child="P_MSTR_TAB" child-key="MSTR_NO"/>
> </xsd:annotation>
> </xsd:appinfo>
> <xsd:import namespace="http://www.ns.com/3.0"
> schemaLocation="ao/3.0/sch1.xsd"/>
>
> <xsd:element name="I_REPORT" sql:relation="P_INCID_ENTITY_TAB"
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="LocationStreet" sql:is-constant="1">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element ref="j:StreetNumberText"
> sql:field="Primary_Street_Num" sql:relation="P_INCID_TAB"
> sql:relationship="MasterData"/>
> <xsd:element ref="j:StreetName"
> sql:field="Primary_Street_Name" sql:relation="P_INCID_TAB"
> sql:relationship="MasterData"/> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complex type>
>
> The place where I am having the problem is the output from the
> two
> element ref lines. (j:StreetNumberText and j:StreetName)
> There is more to this code, but i think this shows the needed
> info,
> let me know if you need more.
> Thank you so very much
>
> -Andrew


ok...i see what you are saying...
Is there a way though that I can strip the name space prefix on the
actual data, more or less for aesthetics i guess? I am trying to
create a way for interoperability. So basically this file can be sent
to anyone with the correct stylesheet and it will display the correct
results. It is kind of confusing.
I guess I am kind of confused as to why SQLXML adds the Y0, instead of
J or nothing at all.
I am using SQL 2000, if i were to get SQL2005 would this be any
different?
Maybe I am just being picky, or weird.....
aowen355

2005-07-07, 1:23 pm

"aowen355" wrote:
> ok...i see what you are saying...
> Is there a way though that I can strip the name space prefix
> on the actual data, more or less for aesthetics i guess? I am
> trying to create a way for interoperability. So basically this
> file can be sent to anyone with the correct stylesheet and it
> will display the correct results. It is kind of confusing.
> I guess I am kind of confused as to why SQLXML adds the Y0,
> instead of J or nothing at all.
> I am using SQL 2000, if i were to get SQL2005 would this be
> any different?
> Maybe I am just being picky, or weird.....


After looking this over, I better understand what is happening

Just for the fact of well-formatted XML output, i would just like a
way to get rid of the namespace info in front of the certain lines,
but i guess if theres no way to do that its ok
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com