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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Please...<xsl:if > not working 1

Status
Not open for further replies.

crowsario

Programmer
Jul 23, 2001
24
US
Hello,

i am trying to do a for loop for only the first ten records returned by an asp generated xml file from a sql server backend. when i do not put the <xsl:if> in the template below it works fine... it just gives me more than i want to show at one time. with the <xsl:if> it gives me the following error:
&quot;Error Type:
Microsoft XML Extensions to SQL Server (0x80004005)
SQLXML: error loading XSL stylesheet&quot;

any suggestions would be greatly appreciated


<?xml version=&quot;1.0&quot;?>

<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xsl:template match=&quot;/&quot;>
<html>
<body>
<table>
<xsl:for-each select=&quot;alldata/firstset/tablename&quot;>
<xsl:if test=&quot;position()<10&quot;>
<tr>
<td>
<xsl:value-of select=&quot;@fieldname&quot;/>
</td>

</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>


please help
 
Try :

<?xml version=&quot;1.0&quot;?>

<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xsl:template match=&quot;/&quot;>
<html>
<body>
<table>
<xsl:for-each select=&quot;alldata/firstset/tablename&quot;>
<xsl:if test=&quot;position() &lt; 10&quot;>
<tr>
<td>
<xsl:value-of select=&quot;@fieldname&quot;/>
</td>

</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
 
thanks for the quick response,

sorry.. i left that out of my post... but my xsl does contain the closing tag for the stylesheet. it doesn't like the <xsl:if> statement for some reason. as i stated the page does work without the <xsl:if>

but thanks for trying
-R
 
Don't use position() < 10:
escape the &quot;<&quot; character with & l t ;
 
Hi Jel,

i still get the same error. In fact i can't even use xsl:when or xsl:choose statements in my xsl files... it's really weird. Do you think it is because i am using asp and not asp.net? This is my first xml project so any suggestions/comments/links would be helpful.

thanks again
-R
 
Hi crowsario,

Which version of the Microsoft xml parser are you relying on? It looks like you're using a very old version of the parser, which used a working draft version of the xslt specifications and is missing a lot of functionality.

Jordi Reineman
 
Hi JJR,

i thought i was using the most recent version... it's microsofts SQLXML3.0...

thanks
-Crow
 
The XML you posted seems to have aquired a rogue ; in the middle of the xsl:stylesheet tag. Removing it and ensuring that the test line reads

Code:
<xsl:if test=&quot;position() &amp;lt; 10&quot;>

Makes the template work fine on my environment (IE6 native XSL conversion). I know the original Microsoft XSL engine was really buggy, perhaps ASP's still using it.

-- Chris Hunt
Extra Connections Ltd
 
ChrisHunt,

thanks a ton for the extra set of eyes.. that worked. also thanks for everyone else's suggestions

-Crowsario
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top