Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie to xml / xsl

Status
Not open for further replies.

welshone

Programmer
Jul 30, 2001
414
GB
Hello, I am trying to learn xml/xsl and am stuck with a very basic problem :

my xml page is like this :
<?xml version ='1.0' encoding='UTF-8'?>
<root xmlns:sql='urn:schemas-microsoft-com:xml-sql'>
<sql:query>
SELECT CompanyName, ContactName, Phone FROM suppliers FOR XML AUTO
</sql:query>
</root>

my xsl is like this :

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>

<xsl:template match = '*'>
<xsl:apply-templates />
</xsl:template>

<xsl:template match = 'Suppliers'>
<TR>
<TD><xsl:value-of select = '@CompanyName' /></TD>
<TD><xsl:value-of select = '@ContactName' /></TD>
<TD><xsl:value-of select = '@Phone' /></TD>
</TR>
</xsl:template>

<xsl:template match = '/'>
<HTML>
<HEAD>
<STYLE>th { background-color: #CCCCCC }</STYLE>
</HEAD>
<BODY>
<TABLE border='1' style='width:300;'>
<TR><TH colspan='3'>suppliers</TH></TR>
<TR><TH >Company Name</TH><TH>Contact Name</TH><TH>Extension</TH></TR>
<xsl:apply-templates select = 'root' />
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>

I am typing this in the URL :



I can see the table headings, but not data underneath, what am I missing ?
(this is a modified example form a microsoft page)

thanks for the help..
 
so basically your asp/sql server will turn the query what format?

is it something like this?

<row>
<suppliers CompanyName=&quot;cc&quot; ContactName=&quot;fkd&quot; Phone=&quot;spdfk&quot; />
</row>

??? or are there namespaces involved when sqlserver returns your results?

make sure u r taking namespaces into account... eg look at the return xml and make sure that when u are applying templates that the template declaration includes that namespace..

tis just a guess cause we dont know what xml the query is changed into, and this will affect what the xsl looks like ;0)

matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top