RE: [xsl] Dumb questions from a newbie

Subject: RE: [xsl] Dumb questions from a newbie
From: "Ivan Pedruzzi" <ivan@xxxxxxxxxxxxxxx>
Date: Wed, 12 Dec 2001 11:38:08 -0500
I wrote again the solution incorporating Chris's suggestion

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:ado="ado">
  <xsl:output method="xml" encoding="utf-8" indent="yes"/>
  <msxml:script language="JScript" implements-prefix="ado"><![CDATA[
  function GetRecords(connection, tablename)
  {
      var field;
      var output;
      var dom, row, value, fPos, root;
      var conn = new ActiveXObject("ADODB.Connection");
      var cmd = new ActiveXObject("ADODB.Command");
      var rs = new ActiveXObject("ADODB.Recordset");
      var Err, ErrCount;
    
      conn.Open(connection);
      cmd.CommandText = "SELECT * FROM " + tablename;
      cmd.ActiveConnection = conn;
      rs = cmd.Execute();

      ErrCount = conn.errors.count;
      if(ErrCount > 0){
        for(Err = 0; Err < ErrCount; Err++){
           output += conn.errors.item(Err);
        }
      }
      else{
        dom = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
        root = dom.createNode(1, tablename, '');
        while (!rs.EOF){
     	   row = root.appendChild(dom.createNode(1, tablename, ''));
         for (fPos = 0; fPos < rs.fields.count; fPos++){
            value = rs.fields(fPos).value;
            if(value == null) value="";
            row.setAttribute(rs.fields(fPos).name , value);
         }
         rs.MoveNext;
        }
      }
      return root;
  }
  ]]>
  </msxml:script>

  <xsl:template match="/">
  <dao>
      <xsl:variable name="test" select="ado:GetRecords('Provider =
Microsoft.Jet.OLEDB.4.0;Data Source = c:\\PlatformSDK\\Bin\\nwind.Mdb;',
'Customers')"/>
      <xsl:for-each select="$test/Customers">
        <xsl:copy-of select="."/>
      </xsl:for-each>
  </dao>
  </xsl:template>
</xsl:stylesheet>

Ivan Pedruzzi
eXcelon Corporation
http://www.stylusstudio.com



> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Chris Bayes
> Sent: Wednesday, December 12, 2001 10:11 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Dumb questions from a newbie
> 
> 
> Mike,
> The thing that should have jumped out at you was accessTOxml 
> in other words convert an access database TO xml. You run it 
> cscript accesstoxml.js fullPathToAccess.mdb
> and it creates fullPathToAccess.xml which is a representation 
> of the access database with tables and rows. This can then be 
> used as an input to an xslt transform which is what you wanted.
> 
> Ciao Chris
> 
> XML/XSL Portal
> http://www.bayes.co.uk/xml
> 
> 
> > -----Original Message-----
> > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> > Mike Ferrando
> > Sent: 12 December 2001 14:06
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: RE: [xsl] Dumb questions from a newbie
> > 
> > 
> > 
> > --- Chris Bayes <chris@xxxxxxxxxxx> wrote:
> > >>I don't want to get locked into using Access
> > >>and its HTML creations. The coding seems very microsoft
> > >>dependent in their web pages. 
> > >
> > >That is why I sent you the link to accessTOxml
> > 
> > Chris,
> > I went there and looked around but nothing jumped out and bit
> > me on the nose. It is a great site, but I didn't find what I 
> > was looking for, and that may be because I don't know the 
> > terminology yet.
> > 
> > >>Thanks for the info, I will get on the list and ask about it.
> > >He didn't answer your question!!!!
> > >Well don't thank me. Or ever ask me another question!!!!
> > 
> > <xsl:for-each select="/Well don't thank me...">
> > <STRONG><xsl:text>Thanks</xsl:text></STRONG>
> > </xsl:for-each>
> > 
> > Mike F.
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Check out Yahoo! Shopping and Yahoo! Auctions for all of
> > your unique holiday gifts! Buy at http://shopping.yahoo.com 
> or bid at 
> > http://auctions.yahoo.com
> > 
> >  XSL-List info and archive:  
> http://www.mulberrytech.com/xsl/xsl-list
> > 
> > 
> 
> 
>  XSL-List 
> info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread