Home All Groups Group Topic Archive Search About

typed dataset and generating xml

Author
17 Nov 2004 2:25 PM
Usha Vas
Hi,

I had posted this question in donet.framework.adonet but thought it might
make more sense here, so I apologize for the duplicate post.

I have an XML schema with one of the elements (Sig) having an attribute
defined as such:

<xs:element name="Sig" nillable="true" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:string">
           <xs:attribute name="type" form="unqualified" type="xs:string" 
default="image"/>
      </xs:extension>
    </xs:simpleContent>
</xs:complexType>
</xs:element>

In my application, I've created a typed dataset (using my schema) and
generate the XML using the dataset.GetXML function. It creates all the
elements with data including the <Sig> element, but it does not generate the
"type" attribute with the default value "image". Do you have any idea how I
can do force the attribute to be created? I'm attaching the schema. I
couldn't attach the typed dataset code, too long, but in essence it has 2
tables, the main Letter table and a Letter_Sig table that has a relationship
with the Letter table.

The dataset is populated by a call to a stored procedure that returns one
row (including the 'Sig' column), could this be the problem? But if that's
the case, then the <Sig> element would not be populated, it is in this case,
just no attribute.
I'm guessing somehow, my stored procedure needs to return another dataset
for the Sig data, but am not sure how to do this.

Any help would be appreciated.

Usha

<?xml version="1.0"?>
<xs:schema id="NewDataSet" targetNamespace="http://mycompany.com/"
xmlns:mstns="http://mycompany.com/"
xmlns="http://mycompany.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:element name="Letter">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="Name" type="xs:string" minOccurs="0" />
        <xs:element name="Address1" type="xs:string" minOccurs="0" />
        <xs:element name="Address2" type="xs:string" minOccurs="0" />
        <xs:element name="City" type="xs:string" minOccurs="0" />
        <xs:element name="State" type="xs:string" minOccurs="0" />
        <xs:element name="Zip" type="xs:string" minOccurs="0" />
        <xs:element name="Sig" nillable="true" minOccurs="0"
maxOccurs="unbounded">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
               <xs:attribute name="type" form="unqualified" type="xs:string"
default="image"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
  <xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:EnforceConstraints="False">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element ref="Letter" />
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

Author
17 Nov 2004 8:14 PM
JoeWood
I haven't tried this for a while, but from memory the Typed Data Set
Generator creates a separate table for the attribute set for a given element.
Unfortunately your default value will only come into effect once a row has
been created in this table.  As far as I know there is no way of creating a
default new row when a parent row is created - so your routine will have to
create it manually.

JoeW

Show quote
"Usha Vas" wrote:

> Hi,
>
> I had posted this question in donet.framework.adonet but thought it might
> make more sense here, so I apologize for the duplicate post.
>
> I have an XML schema with one of the elements (Sig) having an attribute
> defined as such:
>
> <xs:element name="Sig" nillable="true" minOccurs="0" maxOccurs="unbounded">
> <xs:complexType>
>     <xs:simpleContent>
>       <xs:extension base="xs:string">
>            <xs:attribute name="type" form="unqualified" type="xs:string" 
> default="image"/>
>       </xs:extension>
>     </xs:simpleContent>
> </xs:complexType>
> </xs:element>
>
> In my application, I've created a typed dataset (using my schema) and
> generate the XML using the dataset.GetXML function. It creates all the
> elements with data including the <Sig> element, but it does not generate the
> "type" attribute with the default value "image". Do you have any idea how I
> can do force the attribute to be created? I'm attaching the schema. I
> couldn't attach the typed dataset code, too long, but in essence it has 2
> tables, the main Letter table and a Letter_Sig table that has a relationship
> with the Letter table.
>
> The dataset is populated by a call to a stored procedure that returns one
> row (including the 'Sig' column), could this be the problem? But if that's
> the case, then the <Sig> element would not be populated, it is in this case,
> just no attribute.
> I'm guessing somehow, my stored procedure needs to return another dataset
> for the Sig data, but am not sure how to do this.
>
> Any help would be appreciated.
>
> Usha
>
> <?xml version="1.0"?>
> <xs:schema id="NewDataSet" targetNamespace="http://mycompany.com/"
>  xmlns:mstns="http://mycompany.com/"
>  xmlns="http://mycompany.com"
>  xmlns:xs="http://www.w3.org/2001/XMLSchema"
>  xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> attributeFormDefault="qualified" elementFormDefault="qualified">
>   <xs:element name="Letter">
>     <xs:complexType mixed="true">
>       <xs:choice minOccurs="0" maxOccurs="unbounded">
>         <xs:element name="Name" type="xs:string" minOccurs="0" />
>         <xs:element name="Address1" type="xs:string" minOccurs="0" />
>         <xs:element name="Address2" type="xs:string" minOccurs="0" />
>         <xs:element name="City" type="xs:string" minOccurs="0" />
>         <xs:element name="State" type="xs:string" minOccurs="0" />
>         <xs:element name="Zip" type="xs:string" minOccurs="0" />
>         <xs:element name="Sig" nillable="true" minOccurs="0"
> maxOccurs="unbounded">
>           <xs:complexType>
>             <xs:simpleContent>
>               <xs:extension base="xs:string">
>                <xs:attribute name="type" form="unqualified" type="xs:string"
>  default="image"/>
>               </xs:extension>
>             </xs:simpleContent>
>           </xs:complexType>
>         </xs:element>
>       </xs:choice>
>     </xs:complexType>
>   </xs:element>
>   <xs:element name="NewDataSet" msdata:IsDataSet="true"
> msdata:EnforceConstraints="False">
>     <xs:complexType>
>       <xs:choice maxOccurs="unbounded">
>         <xs:element ref="Letter" />
>       </xs:choice>
>     </xs:complexType>
>   </xs:element>
> </xs:schema>
>
Author
17 Nov 2004 8:25 PM
Usha Vas
Thanks for the response. I'll try creating the row manually, I guess since I
know what it's supposed to do, it might make sense to that. Thanks again.

-Usha

Show quote
"JoeWood" wrote:

> I haven't tried this for a while, but from memory the Typed Data Set
> Generator creates a separate table for the attribute set for a given element.
> Unfortunately your default value will only come into effect once a row has
> been created in this table.  As far as I know there is no way of creating a
> default new row when a parent row is created - so your routine will have to
> create it manually.
>
> JoeW
>
> "Usha Vas" wrote:
>
> > Hi,
> >
> > I had posted this question in donet.framework.adonet but thought it might
> > make more sense here, so I apologize for the duplicate post.
> >
> > I have an XML schema with one of the elements (Sig) having an attribute
> > defined as such:
> >
> > <xs:element name="Sig" nillable="true" minOccurs="0" maxOccurs="unbounded">
> > <xs:complexType>
> >     <xs:simpleContent>
> >       <xs:extension base="xs:string">
> >            <xs:attribute name="type" form="unqualified" type="xs:string" 
> > default="image"/>
> >       </xs:extension>
> >     </xs:simpleContent>
> > </xs:complexType>
> > </xs:element>
> >
> > In my application, I've created a typed dataset (using my schema) and
> > generate the XML using the dataset.GetXML function. It creates all the
> > elements with data including the <Sig> element, but it does not generate the
> > "type" attribute with the default value "image". Do you have any idea how I
> > can do force the attribute to be created? I'm attaching the schema. I
> > couldn't attach the typed dataset code, too long, but in essence it has 2
> > tables, the main Letter table and a Letter_Sig table that has a relationship
> > with the Letter table.
> >
> > The dataset is populated by a call to a stored procedure that returns one
> > row (including the 'Sig' column), could this be the problem? But if that's
> > the case, then the <Sig> element would not be populated, it is in this case,
> > just no attribute.
> > I'm guessing somehow, my stored procedure needs to return another dataset
> > for the Sig data, but am not sure how to do this.
> >
> > Any help would be appreciated.
> >
> > Usha
> >
> > <?xml version="1.0"?>
> > <xs:schema id="NewDataSet" targetNamespace="http://mycompany.com/"
> >  xmlns:mstns="http://mycompany.com/"
> >  xmlns="http://mycompany.com"
> >  xmlns:xs="http://www.w3.org/2001/XMLSchema"
> >  xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> > attributeFormDefault="qualified" elementFormDefault="qualified">
> >   <xs:element name="Letter">
> >     <xs:complexType mixed="true">
> >       <xs:choice minOccurs="0" maxOccurs="unbounded">
> >         <xs:element name="Name" type="xs:string" minOccurs="0" />
> >         <xs:element name="Address1" type="xs:string" minOccurs="0" />
> >         <xs:element name="Address2" type="xs:string" minOccurs="0" />
> >         <xs:element name="City" type="xs:string" minOccurs="0" />
> >         <xs:element name="State" type="xs:string" minOccurs="0" />
> >         <xs:element name="Zip" type="xs:string" minOccurs="0" />
> >         <xs:element name="Sig" nillable="true" minOccurs="0"
> > maxOccurs="unbounded">
> >           <xs:complexType>
> >             <xs:simpleContent>
> >               <xs:extension base="xs:string">
> >                <xs:attribute name="type" form="unqualified" type="xs:string"
> >  default="image"/>
> >               </xs:extension>
> >             </xs:simpleContent>
> >           </xs:complexType>
> >         </xs:element>
> >       </xs:choice>
> >     </xs:complexType>
> >   </xs:element>
> >   <xs:element name="NewDataSet" msdata:IsDataSet="true"
> > msdata:EnforceConstraints="False">
> >     <xs:complexType>
> >       <xs:choice maxOccurs="unbounded">
> >         <xs:element ref="Letter" />
> >       </xs:choice>
> >     </xs:complexType>
> >   </xs:element>
> > </xs:schema>
> >

AddThis Social Bookmark Button