Click to See Complete Forum and Search --> : Help an XML newbie


Justin Law
03-31-2000, 09:08 AM
I write VB code for a living, but want to explore the XML world for an application
I am writing that can either go Internet or desktop. Anyway, my business
objects retrieve data from the database and pass the recordset to the client.
I have changed this so that now the BO passes a DOMDocument. The problem
I have is that when I save the recordset as a DOMDocument, It creates the
following. This file is not at all what I expect, and none of the books
I have purchased on XML talk about this. The problem appears to be that
I have a Schema on top of my XML, and also that the information is no longer
in proper nodes. What I mean is that all of the database information is
no longer set up like <FirstName>Justin</FirstName>. I really need a pointer
in the right direction. I just can't seem to find a good resource for this
stuff. I realize that I could just save the recordset to a file and that
creates proper XML, but I would prefer the ability to pass the object from
one BO to a client side class. Any help is appreciated.

- <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
- <s:Schema id="RowsetSchema">
- <s:ElementType name="row" content="eltOnly">
- <s:AttributeType name="EmployeeID" rs:number="1" rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"
/>
</s:AttributeType>
- <s:AttributeType name="FirstName" rs:number="2" rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="50" />
</s:AttributeType>
- <s:AttributeType name="LastName" rs:number="3" rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="50" />
</s:AttributeType>
- <s:AttributeType name="Address1" rs:number="4" rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="50" />
</s:AttributeType>
- <s:AttributeType name="Address2" rs:number="5" rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="50" />
</s:AttributeType>
- <s:AttributeType name="City" rs:number="6" rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="50" />
</s:AttributeType>
- <s:AttributeType name="State" rs:number="7" rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="50" />
</s:AttributeType>
- <s:AttributeType name="Zip" rs:number="8" rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="50" />
</s:AttributeType>
- <s:AttributeType name="Phone" rs:number="9" rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="50" />
</s:AttributeType>
- <s:AttributeType name="Email" rs:number="10" rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="50" />
</s:AttributeType>
- <s:AttributeType name="Code" rs:number="11" rs:nullable="true" rs:writeunknown="true">
<s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"
/>
</s:AttributeType>
<s:extends type="rs:rowbase" />
</s:ElementType>
</s:Schema>
- <rs:data>
<z:row EmployeeID="1" FirstName="Justin" LastName="Law" Address1="3 Squire
Lane" Address2="c/o Amy Law" City="Clifton Park" State="NY" Zip="12065" Phone="5183737900"
Email="jlaw@iasystems.com" Code="5555" />
<z:row EmployeeID="2" FirstName="Amy" LastName="Law" Address1="3 Squire
Lane" City="Clifton Park" State="NY" Zip="12065" Phone="5183737900" Email="alaw@nycap.rr.com"
Code="1234" />
<z:row EmployeeID="3" FirstName="Greg" LastName="Henderson" Address1="7
Dennis Drive" City="Clifton Park" State="NY" Zip="12065" Phone="5183836170"
Email="greghen@us.ibm.com" Code="1111" />
<z:row EmployeeID="4" FirstName="Angela" LastName="Rice" Address1="10 Birch
Hill Rd." Address2="c/o Barbara Law" City="Ballston Lake" State="NY" Zip="12019"
Phone="5188777870" Email="blaw@global2000.net" Code="2222" />
<z:row EmployeeID="5" FirstName="Don" LastName="Baylor" Address1="10 Colorado
Way" City="Colorado Springs" State="CO" Zip="85261" Code="2440" />
</rs:data>
</xml>

Greg Longtin
03-31-2000, 11:04 AM
Justin,

ADO does generate valid XML. Basically, it uses attributes for data
instead of child nodes. Either style can be processed with XSLT or the
DOM.

IOW,

<person>
<first>Greg</first>
<last>Longtin</last>
</person>

contains the same data as

<person first="Greg" last="Longtin"/>

The schema is attached so that ADO can round trip XML.

FWIW,

Greg Longtin

TC
04-03-2000, 12:58 PM
Justin
I am maybe 2 mths ahead of you in doing this. My initial conclusion is that
I don't like the valid XML that ado generrates for use in BO to client when
the client is doing a data entry type screen BUT I do how ever think that it
is the cats meow, for report/List generation.

1) for BO to client where we have a data entry screen, we wrap up a SOAP
envelope & create the XML with a combination of TagNames & attributes
wrapped around the actual payload data, & additional tags
for the BO method invocation. the entire parameter is just a valid SOAP
xml doc.

2) for reporting we pass in a valid SOAP report request that contains the
selection criteria for the rpt, we generrate a sql select pass to ado, then
depending how we have a users rpt config flags set
a) we pass back the ado xml stream & let the client do a transformNode
using the style sheet of choice with a default one suggested
b) we do a transformNode on the ado xml stream on the server & send back
a valid html rpt.

We use the M$ http request object for communication between client & server,
needless to say we are an IE5 solution only ....





Justin Law wrote in message <38e4b17a$1@news.devx.com>...
>
>I write VB code for a living, but want to explore the XML world for an
application
>I am writing that can either go Internet or desktop. Anyway, my business
>objects retrieve data from the database and pass the recordset to the
client.
> I have changed this so that now the BO passes a DOMDocument. The problem
>I have is that when I save the recordset as a DOMDocument, It creates the
>following. This file is not at all what I expect, and none of the books
>I have purchased on XML talk about this. The problem appears to be that
>I have a Schema on top of my XML, and also that the information is no
longer
>in proper nodes. What I mean is that all of the database information is
>no longer set up like <FirstName>Justin</FirstName>. I really need a
pointer
>in the right direction. I just can't seem to find a good resource for this
>stuff. I realize that I could just save the recordset to a file and that
>creates proper XML, but I would prefer the ability to pass the object from
>one BO to a client side class. Any help is appreciated.
>
>- <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
>xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
>- <s:Schema id="RowsetSchema">
>- <s:ElementType name="row" content="eltOnly">
>- <s:AttributeType name="EmployeeID" rs:number="1" rs:nullable="true"
rs:writeunknown="true">
> <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10"
rs:fixedlength="true"
>/>
> </s:AttributeType>
>- <s:AttributeType name="FirstName" rs:number="2" rs:nullable="true"
rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="LastName" rs:number="3" rs:nullable="true"
rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Address1" rs:number="4" rs:nullable="true"
rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Address2" rs:number="5" rs:nullable="true"
rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="City" rs:number="6" rs:nullable="true"
rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="State" rs:number="7" rs:nullable="true"
rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Zip" rs:number="8" rs:nullable="true"
rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Phone" rs:number="9" rs:nullable="true"
rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Email" rs:number="10" rs:nullable="true"
rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Code" rs:number="11" rs:nullable="true"
rs:writeunknown="true">
> <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10"
rs:fixedlength="true"
>/>
> </s:AttributeType>
> <s:extends type="rs:rowbase" />
> </s:ElementType>
> </s:Schema>
>- <rs:data>
> <z:row EmployeeID="1" FirstName="Justin" LastName="Law" Address1="3
Squire
>Lane" Address2="c/o Amy Law" City="Clifton Park" State="NY" Zip="12065"
Phone="5183737900"
>Email="jlaw@iasystems.com" Code="5555" />
> <z:row EmployeeID="2" FirstName="Amy" LastName="Law" Address1="3 Squire
>Lane" City="Clifton Park" State="NY" Zip="12065" Phone="5183737900"
Email="alaw@nycap.rr.com"
>Code="1234" />
> <z:row EmployeeID="3" FirstName="Greg" LastName="Henderson" Address1="7
>Dennis Drive" City="Clifton Park" State="NY" Zip="12065" Phone="5183836170"
>Email="greghen@us.ibm.com" Code="1111" />
> <z:row EmployeeID="4" FirstName="Angela" LastName="Rice" Address1="10
Birch
>Hill Rd." Address2="c/o Barbara Law" City="Ballston Lake" State="NY"
Zip="12019"
>Phone="5188777870" Email="blaw@global2000.net" Code="2222" />
> <z:row EmployeeID="5" FirstName="Don" LastName="Baylor" Address1="10
Colorado
>Way" City="Colorado Springs" State="CO" Zip="85261" Code="2440" />
> </rs:data>
> </xml>

Stuart Dickerson
04-06-2000, 07:00 AM
I hate what Microsoft did with ADO recordsets. Sometimes what they call an
XML document is really a stretch of the imagination! You're like me, true
XML documents use elements, not attributes.

I'm doing the same thing your doing. Creating objects that are usable by
either Web or Desktop client. I have written ASP functions that take the
recordset and generate the XML or parse it. They were very simple. I'm
going to convert them to COM objects.

To save the recordset as XML: ADO will let you get both the column name
which I use for the elements and their values which is the text. I just
loop through the Fields collection, which is an array. When I have built
the document, I send it back to the client via the Response Object.

BTW: If you have MS SQL Server, you should check out the add-on for SQL
Server to genereate XML. ITS AWESOME!!! Beats Oralce by a mile!

Stuart

"Justin Law" <jlaw@iasystems.com> wrote:
>
>I write VB code for a living, but want to explore the XML world for an application
>I am writing that can either go Internet or desktop. Anyway, my business
>objects retrieve data from the database and pass the recordset to the client.
> I have changed this so that now the BO passes a DOMDocument. The problem
>I have is that when I save the recordset as a DOMDocument, It creates the
>following. This file is not at all what I expect, and none of the books
>I have purchased on XML talk about this. The problem appears to be that
>I have a Schema on top of my XML, and also that the information is no longer
>in proper nodes. What I mean is that all of the database information is
>no longer set up like <FirstName>Justin</FirstName>. I really need a pointer
>in the right direction. I just can't seem to find a good resource for this
>stuff. I realize that I could just save the recordset to a file and that
>creates proper XML, but I would prefer the ability to pass the object from
>one BO to a client side class. Any help is appreciated.
>
>- <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
>xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
>- <s:Schema id="RowsetSchema">
>- <s:ElementType name="row" content="eltOnly">
>- <s:AttributeType name="EmployeeID" rs:number="1" rs:nullable="true" rs:writeunknown="true">
> <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"
>/>
> </s:AttributeType>
>- <s:AttributeType name="FirstName" rs:number="2" rs:nullable="true" rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="LastName" rs:number="3" rs:nullable="true" rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Address1" rs:number="4" rs:nullable="true" rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Address2" rs:number="5" rs:nullable="true" rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="City" rs:number="6" rs:nullable="true" rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="State" rs:number="7" rs:nullable="true" rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Zip" rs:number="8" rs:nullable="true" rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Phone" rs:number="9" rs:nullable="true" rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Email" rs:number="10" rs:nullable="true" rs:writeunknown="true">
> <s:datatype dt:type="string" dt:maxLength="50" />
> </s:AttributeType>
>- <s:AttributeType name="Code" rs:number="11" rs:nullable="true" rs:writeunknown="true">
> <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"
>/>
> </s:AttributeType>
> <s:extends type="rs:rowbase" />
> </s:ElementType>
> </s:Schema>
>- <rs:data>
> <z:row EmployeeID="1" FirstName="Justin" LastName="Law" Address1="3 Squire
>Lane" Address2="c/o Amy Law" City="Clifton Park" State="NY" Zip="12065"
Phone="5183737900"
>Email="jlaw@iasystems.com" Code="5555" />
> <z:row EmployeeID="2" FirstName="Amy" LastName="Law" Address1="3 Squire
>Lane" City="Clifton Park" State="NY" Zip="12065" Phone="5183737900" Email="alaw@nycap.rr.com"
>Code="1234" />
> <z:row EmployeeID="3" FirstName="Greg" LastName="Henderson" Address1="7
>Dennis Drive" City="Clifton Park" State="NY" Zip="12065" Phone="5183836170"
>Email="greghen@us.ibm.com" Code="1111" />
> <z:row EmployeeID="4" FirstName="Angela" LastName="Rice" Address1="10
Birch
>Hill Rd." Address2="c/o Barbara Law" City="Ballston Lake" State="NY" Zip="12019"
>Phone="5188777870" Email="blaw@global2000.net" Code="2222" />
> <z:row EmployeeID="5" FirstName="Don" LastName="Baylor" Address1="10 Colorado
>Way" City="Colorado Springs" State="CO" Zip="85261" Code="2440" />
> </rs:data>
> </xml>