Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: how to use jscript in xsl file how to use jscript in xsl fileTo: NULL Date: 7/5/2006 4:05:00 AM
Hi, I'm looking for an exemple using jscrip into xsl file.
here is my xslt, that cause an error:
<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:choose>
<xsl:when test="overflow"></xsl:when>
<xsl:otherwise>
<table class="Table_HEADER" id="head" name="head" style="width:100%"
cellpadding="0" cellspacing="1">
<tr height="24px">
<td style="text-align: center;WIDTH: 3%;"></td>
<td style="text-align: center;WIDTH: 8%;">
<span link="quantity"></span>
</td>
<td style="text-align: center;WIDTH: 8%;">
<span link="qttmin"></span>
</td>
<td style="text-align: center;WIDTH: 8%;">
<span link="unitsaleprice"></span>
</td>
<xsl:if test="//products[@stock='on']">
<td style="text-align: center;WIDTH: 7%;">
<span link="stock"></span>
</td>
</xsl:if>
<xsl:if test="//products[@delay='on']">
<td style="text-align: center;WIDTH: 7%;">
<span link="delay"></span>
</td>
</xsl:if>
<td style="text-align: center;WIDTH: 8%;cursor:hand;"
onClick="orderBy('reference')">
<span link="reference"></span>
</td>
<td style="text-align: center;WIDTH: 19%;cursor:hand;"
onClick="orderBy('designation')">
<span link="designation"></span>
</td>
<td style="text-align: center;WIDTH: 10%;cursor:hand;"
onClick="orderBy('supplier')">
<span link="supplier"></span>
</td>
<td style="text-align: center;WIDTH: 10%;cursor:hand;"
onClick="orderBy('number(supplier/saleprice/currency[@status =
\'default\'])')">
<span link="unitPriceFreeTax"></span>
(<xsl:value-of select="//saleprice/currency[@status = 'default']/@id"
/>)
</td>
<td style="text-align: center;WIDTH: 12%;cursor:hand;">
<span link="totalPriceFreeTax"></span>
(<xsl:value-of select="//saleprice/currency[@status = 'default']/@id"
/>)
</td>
</tr>
</table>
<DIV style="height: 445px; overflow-y: scroll;">
<xsl:if test="data">
<xsl:apply-templates select="data" />
</xsl:if>
<xsl:if test="results">
<xsl:apply-templates select="results" />
</xsl:if>
<xsl:if test="category">
<xsl:apply-templates select="category" />
</xsl:if>
<xsl:if test="data[@type='filter']">
<table border="0" cellpadding="0" cellspacing="0" width="100%"
class="mks_TNormal">
<tr style="cursor: hand;" onClick="swap();">
<td>
<img border="0" alt="" src="images/back.gif" />
</td>
<td class="mks_TNormal">
<SPAN link="backToResultsScreen"></SPAN>
</td>
</tr>
</table>
</xsl:if>
</DIV>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="results">
<xsl:apply-templates select="pattern/category" />
</xsl:template>
<xsl:template match="data">
<xsl:apply-templates select="category" />
</xsl:template>
<xsl:template match="category">
<xsl:choose>
<xsl:when test="category">
<xsl:apply-templates select="category" />
</xsl:when>
<xsl:when test="product">
<TABLE border="0" style="width:100%" cellspacing="0" cellpadding="0"
class="mks_TNormal">
<TR>
<TD COLSPAN="13" class="mks_TTitleW">
<xsl:eval>getAncestor(this)</xsl:eval>
<xsl:value-of select="name" /> ] :
<xsl:eval>this.selectNodes("product").length</xsl:eval> <SPAN
link="foundProducts"></SPAN>
</TD>
</TR>
<xsl:apply-templates select="product" />
</TABLE>
<BR />
</xsl:when>
<xsl:when test=".[not(product)]">
<!--xsl:if test="@parent"-->
<TABLE border="0" style="width:100%" cellspacing="0" cellpadding="0"
class="mks_TNormal">
<TR>
<TD class="mks_TTitleW">
<xsl:value-of select="name" />
<I>
<xsl:eval>getAncestor(this)</xsl:eval>
</I>
</TD>
</TR>
<TR>
<TD class="mks_TNormal">
<SPAN link="noProductFound"></SPAN>
</TD>
</TR>
</TABLE>
<BR />
<!--/xsl:if-->
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="product">
<TR align="center">
<xsl:attribute name="id">
line<xsl:value-of select="@id" />
</xsl:attribute>
<td style="text-align: center;WIDTH: 3%;">
<INPUT type="CHECKBOX" link="checkToComparator">
<xsl:attribute name="name">
CHECKBOX<xsl:value-of select="@id" />
</xsl:attribute>
<xsl:attribute name="productID">
<xsl:value-of select="reference" />
</xsl:attribute>
<xsl:attribute name="onclick">top.comparChecked();</xsl:attribute>
</INPUT>
</td>
<TD style="text-align: center;WIDTH: 7%;" align="center">
<INPUT type="TEXT" size="5" maxlength="5" value="0" style="text-align:
right;" typeData="quantity">
<xsl:attribute name="name">
Qtt<xsl:value-of select="@id" />
</xsl:attribute>
<xsl:attribute name="referenceData">
<xsl:value-of select="reference" />
</xsl:attribute>
<xsl:attribute name="providerData">
<xsl:value-of select="supplier/@id" />
</xsl:attribute>
<xsl:attribute name="onBlur">
doOnBlur('<xsl:value-of select="reference" />','<xsl:value-of
select="@id" />');
</xsl:attribute>
</INPUT>
</TD>
<TD style="text-align: center;WIDTH: 1%;">
<TABLE border="0" cellspacing="0" cellpadding="0">
<TR>
<TD>
<IMG border="0" src="../img/p0.gif" style="HEIGHT: 9px;width: 9px"
align="center">
<xsl:attribute name="onclick">
ajoute(this,'<xsl:value-of select="reference" />','<xsl:value-of
select="@id" />');
</xsl:attribute>
</IMG>
</TD>
</TR>
<TR>
<TD>
<IMG border="0" src="../img/m0.gif" style="HEIGHT: 9px;width: 9px"
align="center">
<xsl:attribute name="onclick">
enleve(this,'<xsl:value-of select="reference" />','<xsl:value-of
select="@id" />');
</xsl:attribute>
</IMG>
</TD>
</TR>
</TABLE>
</TD>
<TD style="text-align: center;WIDTH: 8%;" class="mks_TNormal">
<xsl:value-of select="qttmin" />
</TD>
<TD style="text-align: center;WIDTH: 8%;" class="mks_TNormal">
<xsl:value-of select="unitsaleprice" />
</TD>
<xsl:if test="//products[@stock='on']">
<TD style="text-align: center;WIDTH: 7%;" class="mks_TNormal">
<xsl:value-of select="supplier/ProdStock" />
</TD>
</xsl:if>
<xsl:if test="//products[@delay='on']">
<TD style="text-align: center;WIDTH: 7%;" class="mks_TNormal">
<xsl:value-of select="supplier/ProdDelay" />
</TD>
</xsl:if>
<TD link="clickHereToShowProduct" title="" style="text-align:
center;WIDTH: 8%;cursor: hand;">
<xsl:attribute name="onClick">
showProduct('<xsl:value-of select="reference" />');
</xsl:attribute>
<xsl:value-of select="reference" />
</TD>
<TD link="clickHereToShowProduct" style="text-align: left;WIDTH:
19%;cursor: hand;"
title="">
<xsl:attribute name="onClick">
showProduct('<xsl:value-of select="reference" />');
</xsl:attribute>
<TABLE class="mks_TNormal">
<TR>
<TD>
<IMG border="0" style="HEIGHT: 28px;WIDTH: 28px">
<xsl:choose>
<xsl:when test="image/small[text() != '']">
<xsl:attribute name="src">
images/products/<xsl:value-of select="image/small" />
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="src">images/product.gif</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</IMG>
</TD>
<TD title="{designation}">
<xsl:call-template name="truncateText">
<xsl:with-param name="text" select="designation" />
<xsl:with-param name="maxLength" select="28" />
</xsl:call-template>
</TD>
</TR>
</TABLE>
</TD>
<TD style="text-align: center;WIDTH: 10%;cursor: default;">
<xsl:attribute name="title">
<xsl:value-of select="supplier/name" />
<xsl:value-of select="supplier/addr1" />
<xsl:value-of select="supplier/addr2" />
<xsl:value-of select="supplier/zipcode" /> <xsl:value-of
select="supplier/city" /> <xsl:value-of select="supplier/country" />
Phone : <xsl:value-of select="supplier/phone" />
Fax : <xsl:value-of select="supplier/fax" />
Contact : <xsl:value-of select="supplier/contact" />
</xsl:attribute>
<xsl:value-of select="supplier/name" />
</TD>
<TD style="WIDTH: 8%;">
<INPUT style="cursor: hand;border: none; background-color:
transparent;text-align: right;"
type="text" size="10" readonly="true">
<xsl:attribute name="name">
Prix<xsl:value-of select="@id" />
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="supplier/saleprice/currency[@status =
'default']" />
</xsl:attribute>
<xsl:attribute name="title">
<xsl:eval>getChildNumber(this)</xsl:eval>
</xsl:attribute>
</INPUT>
</TD>
<TD style="WIDTH: 2%;">
<xsl:if expr="getChildNumber(this) > 1">
<xsl:attribute name="onClick">
getQtyPrice('<xsl:value-of select="@id" />');
</xsl:attribute>
<IMG border="0" src="../img/q.ico" style="HEIGHT: 15px;width:
15px;CURSOR: hand" align="center"></IMG>
</xsl:if>
</TD>
<TD style="WIDTH: 10%;">
<INPUT style="cursor: default;border: none; background-color:
transparent;text-align: right;"
type="text" size="15" value="0.00" readonly="true">
<xsl:attribute name="name">
PrixTotal<xsl:value-of select="@id" />
</xsl:attribute>
</INPUT>
</TD>
</TR>
<TR>
<TD></TD>
<TD colSpan="10">
<xsl:attribute name="id">
QtyPrice<xsl:value-of select="@id" />
</xsl:attribute>
</TD>
</TR>
</xsl:template>
<xsl:template name="truncateText">
<xsl:param name="text" />
<xsl:param name="maxLength" />
<xsl:choose>
<xsl:when test="string-length($text) > $maxLength">
<xsl:value-of select="concat(substring($text, 1, $maxLength), '...')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:script>
<![CDATA[
function getAncestor(xNode)
{
var GeaTree = "";
var MyParent = xNode.parentNode;
while (MyParent.nodeName == "category")
{
GeaTree = MyParent.selectSingleNode("name").text + "/" + GeaTree;
MyParent = MyParent.parentNode;
}
if (GeaTree != "")
GeaTree = "[" + GeaTree;
return GeaTree;
}
function getPatternQtt(xNode)
{
var GeaTree = "";
var MyParent = xNode.parentNode;
while (MyParent.nodeName != "pattern")
{
MyParent = MyParent.parentNode;
}
GeaTree = MyParent.selectSingleNode("@quantity").text
return GeaTree;
}
function getChildNumber(xNode)
{
var MyString ="";
var count = xNode.selectNodes("supplier/saleprice").length;
return count;
}
]]>
</xsl:script>
</xsl:stylesheet>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
