Newbie - SQL to XML

Newbie - SQL to XML

Post by Vincent Jon » Thu, 01 May 2003 07:46:18



Sorry, I know you've probably answer this one before, but I have my
.xml document and .xsl and I still can't get this to the web.  The
table is Customers and the fields are ContactTitle and Country
(Northwind database).  I'm using SQL Server 2000.

Here is my .xml document

<?xml version="1.0"?>

<customers xmlns:sql="urn:schemas-microsoft-com:xml-sql"
        sql:xsl="customers.xsl">
<sql:query>
SELECT Country, ContactTitle FROM Customers for XML auto, elements
</sql:query>
</customers>

I have my .xsl

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:template match="/">
  <HTML>
    <Title>
    DeliveryCo Web site
    </Title>
<body bgproperties="fixed" bgcolor="lightsteelblue">
  <H1>Customers Web Site</H1>
<p><font face="Arial" size="4">Outstanding Customers</font></p>

    <TABLE border="0" width="100%" bordercolor="#009900">
      <TR STYLE="font-size:12pt; font-family:Verdana;
font-weight:bold; text-decoration:underline">
        <TD>Reference</TD>
        <TD>Delivery Address</TD>
      </TR>
      <xsl:for-each select="Customers/Customer">
        <TR >

           <TD>
                <xsl:value-of select="Country"/>
          </TD>
          <TD>
            <xsl:value-of select="ContactTitle"/>
          </TD>
        </TR>
      </xsl:for-each>
    </TABLE>
</body>
</HTML>
  </xsl:template>

</xsl:stylesheet>

 
 
 

Newbie - SQL to XML

Post by Mike Shar » Thu, 01 May 2003 08:32:12


Hi Vincent,

Does your URL look like:

http://localhost/nwindLocDev/template/customer.xml?contenttype=text/html ?

Your two files work for me, as long as I add the contenttype=text/html to
the URL.  There's another way to do this, but I can't for the life of me
remember how.    Make sure you have a temlate virtual name in your virtual
folder, and also make sure the files are in it!

What exactly is the error you're getting?

Regards,
Mike Sharp


Quote:> Sorry, I know you've probably answer this one before, but I have my
> .xml document and .xsl and I still can't get this to the web.  The
> table is Customers and the fields are ContactTitle and Country
> (Northwind database).  I'm using SQL Server 2000.

> Here is my .xml document

> <?xml version="1.0"?>

> <customers xmlns:sql="urn:schemas-microsoft-com:xml-sql"
> sql:xsl="customers.xsl">
> <sql:query>
> SELECT Country, ContactTitle FROM Customers for XML auto, elements
> </sql:query>
> </customers>

> I have my .xsl

> <?xml version="1.0"?>

> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>   <xsl:template match="/">
>   <HTML>
>     <Title>
>     DeliveryCo Web site
>     </Title>
> <body bgproperties="fixed" bgcolor="lightsteelblue">
>   <H1>Customers Web Site</H1>
> <p><font face="Arial" size="4">Outstanding Customers</font></p>

>     <TABLE border="0" width="100%" bordercolor="#009900">
>       <TR STYLE="font-size:12pt; font-family:Verdana;
> font-weight:bold; text-decoration:underline">
>         <TD>Reference</TD>
> <TD>Delivery Address</TD>
>       </TR>
>       <xsl:for-each select="Customers/Customer">
>         <TR >

>    <TD>
>       <xsl:value-of select="Country"/>
>   </TD>
>   <TD>
>     <xsl:value-of select="ContactTitle"/>
>   </TD>
>         </TR>
>       </xsl:for-each>
>     </TABLE>
> </body>
> </HTML>
>   </xsl:template>

> </xsl:stylesheet>


 
 
 

Newbie - SQL to XML

Post by Mike Shar » Thu, 01 May 2003 08:35:47


Oh wait a minute, I see what you did wrong...

<xsl:for-each select="customers/Customers">

not

<xsl:for-each select="Customers/Customer">

Regards,

Mike Sharp


Quote:> Sorry, I know you've probably answer this one before, but I have my
> .xml document and .xsl and I still can't get this to the web.  The
> table is Customers and the fields are ContactTitle and Country
> (Northwind database).  I'm using SQL Server 2000.

> Here is my .xml document

> <?xml version="1.0"?>

> <customers xmlns:sql="urn:schemas-microsoft-com:xml-sql"
> sql:xsl="customers.xsl">
> <sql:query>
> SELECT Country, ContactTitle FROM Customers for XML auto, elements
> </sql:query>
> </customers>

> I have my .xsl

> <?xml version="1.0"?>

> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>   <xsl:template match="/">
>   <HTML>
>     <Title>
>     DeliveryCo Web site
>     </Title>
> <body bgproperties="fixed" bgcolor="lightsteelblue">
>   <H1>Customers Web Site</H1>
> <p><font face="Arial" size="4">Outstanding Customers</font></p>

>     <TABLE border="0" width="100%" bordercolor="#009900">
>       <TR STYLE="font-size:12pt; font-family:Verdana;
> font-weight:bold; text-decoration:underline">
>         <TD>Reference</TD>
> <TD>Delivery Address</TD>
>       </TR>
>       <xsl:for-each select="Customers/Customer">
>         <TR >

>    <TD>
>       <xsl:value-of select="Country"/>
>   </TD>
>   <TD>
>     <xsl:value-of select="ContactTitle"/>
>   </TD>
>         </TR>
>       </xsl:for-each>
>     </TABLE>
> </body>
> </HTML>
>   </xsl:template>

> </xsl:stylesheet>

 
 
 

Newbie - SQL to XML

Post by SQL » Thu, 01 May 2003 12:55:15


THANKS A TON!!!!
that worked.
vj

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!