[AccessD] How bout them apples

Jim DeMarco Jdemarco at hshhp.org
Mon Mar 17 11:59:00 CST 2003


Nice Marty.

Thanks,

Jim DeMarco


-----Original Message-----
From: MartyConnelly [mailto:martyconnelly at shaw.ca]
Sent: Monday, March 17, 2003 12:34 PM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] How bout them apples


Just add one more step using  XSLT, you can transform the XML, which 
contains schema information for row and data definitions, into XML that 
contains nothing more than the data we're interested in. Here is a  
generic XSL stylesheet for converting any simple Recordset XML into 
plain vanilla XML:
Courtesy :Phillip Perkins, Ajilon Consulting  I think I picked up this 
hint from builder.com or xml-dev list awhile ago.

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:z="#RowsetSchema">
    <s:Schema id="RowsetSchema"/>
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:template match="/">
    <xsl:apply-templates select="//z:row"/>
</xsl:template>

<xsl:template match="z:row">
    <xsl:text disable-output-escaping="yes"><row></xsl:text>
        <xsl:for-each select="@*">
            <xsl:text disable-output-escaping="yes"><</xsl:text>
            <xsl:value-of select="name()"/>
            <xsl:text disable-output-escaping="yes">></xsl:text>
            <xsl:value-of select="."/>
            <xsl:text disable-output-escaping="yes"></</xsl:text>
            <xsl:value-of select="name()"/>
            <xsl:text disable-output-escaping="yes">></xsl:text>
        </xsl:for-each>
    <xsl:text disable-output-escaping="yes"></row></xsl:text>
</xsl:template>
</xsl:stylesheet>

The stylesheet converts each z:row node into a more natural form. When 
the Recordset is saved as XML, each row is converted to a z:row node 
with a group of attributes for each field in a record. These field 
attribute values are set to the current value of the field.

The way to convert these is to take each attribute and convert it into a 
<fieldname>fieldvalue</fieldname> format. In order to prevent getting 
namespace information appended to the new nodes,  use the <xsl:text> 
element to create the < and > symbols, instead of using <xsl:element> to 
create new elements.

The attribute name is returned using the name() XPath function, and the 
value of the attribute is returned with ".". All of these new nodes are 
wrapped in a <row> element after conversion.


Jim DeMarco wrote:

>Not to belittle the powers of .NET but you can persist an ADO recordset to XML just as easily (although the XML you've displayed is quite a bit cleaner as ADO saves the table schema along with the data).
>
><snip>
>    rsSource.Save "c:\myxml.xml", adPersistXML
></snip>
>
>Thanks,
>
>Jim DeMarco
>Director of Product Development
>HealthSource/Hudson Health Plan
>
>
>-----Original Message-----
>From: John W. Colby [mailto:jcolby at colbyconsulting.com]
>Sent: Sunday, March 16, 2003 11:06 PM
>To: AccessD
>Subject: [AccessD] How bout them apples
>
>
>A single line of code to write an xml code from a dataset?
>
>DataSet11.WriteXml("c:\TestXml.xml")
>
>>From the click event of a button dumps the data in a dataset bound to a
>table in SQL Server to an XML file on the disk.
>
>This .Net is cool stuff!
>
>  <?xml version="1.0" standalone="yes" ?>
>- <dsStates xmlns="http://www.tempuri.org/DataSet1.xsd">
>- <tblState>
>  <ST_ID>2</ST_ID>
>  <ST_State>Puebla</ST_State>
>  <Active>true</Active>
>  <Trash>false</Trash>
>  </tblState>
>- <tblState>
>  <ST_ID>54</ST_ID>
>  <ST_State>Alberta</ST_State>
>  <ST_Abrev>AB</ST_Abrev>
>  <Active>true</Active>
>  <Trash>false</Trash>
>  </tblState>
>- <tblState>
>  <ST_ID>66</ST_ID>
>  <ST_State>Aguascalientes</ST_State>
>  <ST_Abrev>AGS</ST_Abrev>
>  <Active>true</Active>
>  <Trash>false</Trash>
>  </tblState>
>- <tblState>
>  <ST_ID>4</ST_ID>
>  <ST_State>Alaska</ST_State>
>  <ST_Abrev>AK</ST_Abrev>
>
>John W. Colby
>Colby Consulting
>www.ColbyConsulting.com
>
>----------------------------------------------------
>Is email taking over your day?  Manage your time with eMailBoss.
>Try it free!  http://www.eMailBoss.com
>
>
>_______________________________________________
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com
>
>
>***********************************************************************************
>"This electronic message is intended to be for the use only of the named recipient, and may contain information from HealthSource/Hudson Health Plan (HS/HHP) that is confidential or privileged.  If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited.  If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HS/HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message.  Thank You".
>***********************************************************************************
>
>_______________________________________________
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com
>
>  
>


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


***********************************************************************************
"This electronic message is intended to be for the use only of the named recipient, and may contain information from HealthSource/Hudson Health Plan (HS/HHP) that is confidential or privileged.  If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited.  If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HS/HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message.  Thank You".
***********************************************************************************




More information about the AccessD mailing list