We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

xasp: name space objects XSL

Medium Priority
919 Views
Last Modified: 2013-11-18
I have the following code in another application that workes fine
namespace declaration xmlns:xasp="urn:asp-objects">

    <xsl:variable name="offer-url">
      <xsl:value-of select="yahoo:Url" />
</xsl:variable>
 <xsl:variable name="offer-url-encoded">
      <xsl:value-of select="xasp:encodeURL(string(yahoo:Url))" />
</xsl:variable>

I am trying to re use this in another xsl but i am getting this error

Error in XPath expression
Unknown function - Name and number of arguments do not match any function signature in the static context - 'urn:asp-objects:encodeURL'

can anyone help me with this please
Comment
Watch Question

Gertone (Geert Bormans)Information Architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
this is either an external function,
so you will need a bunch of other things
including making the extension function library accessible
(eg. if java, make sure the jar is on the classpath)

or this is a XSLT2 function,
make sure that yu include the definition then and that your stylesheet is an XSLT2 stylesheet and you have an XSLT2 processor

lots of things that cann go wrong.

I think it would b esmart if you posted both the XSLT that had this working and the XSLT that has this not working

cheers

Geert

Author

Commented:
Thanks Geert

Ill post these in 2 posts as they are on different computers.

Here is the xsl that this function works in.
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xasp="urn:asp-objects">
<xsl:template match="/">
 
<div id="maincontent">
	<!--variable for parsing links - set in glbMain-->
	<xsl:variable name="url2sub">
		 <xsl:value-of select="xasp:GetRequestVariable('url2','session')" />
	</xsl:variable>
 
	<!--2nd variable for parsing links - set in glbMain-->
	<xsl:variable name="url2sub2">
		 <xsl:value-of select="xasp:GetRequestVariable('url2sub2','session')" />
	</xsl:variable>
 
	<!--variables for back link-->
	<xsl:variable name="back1">
		<xsl:value-of select="substring(//parent-form/url2,$url2sub,18)" />
	</xsl:variable>
	<xsl:variable name="back2">
		<xsl:value-of select="substring(//form/url2,$url2sub,11)" />
	</xsl:variable>
	<xsl:variable name="back3">
		<xsl:value-of select="//form/@id" />
	</xsl:variable>
	<xsl:variable name="backmain">
		<xsl:value-of select="substring(//parent-form/url2,$url2sub)" />
	</xsl:variable>
	<xsl:variable name="backcat">
			<xsl:value-of select="substring(//top-level-form/url2,$url2sub)" />
	</xsl:variable>
	<xsl:variable name="cn">
		<xsl:value-of select="//top-level-form/name" />
	</xsl:variable>
 
 
	<!-- build the crumbtrail -->
	<ul class="crumbtrail">
		<li><a href="index.asp">Home</a>&#160;::</li>
		<li><a href="index.asp?cat={$backcat}&amp;cn={$cn}"><xsl:value-of select="//top-level-form/name" /></a>&#160;::</li>
		<xsl:if test="not(//top-level-form/name=//parent-form/name)">
			<li><a href="index.asp?cat={$backmain}"><xsl:value-of select="//parent-form/name" /></a>&#160;::</li>
		</xsl:if>
		<li><a href="index.asp?cat={$back1}{$back2}{$back3}"><xsl:value-of select="//category/title" />&#160;</a></li>
		<xsl:for-each select="//bread-crumbs/crumb">
			<xsl:variable name="url-value">
				<xsl:value-of select="@url-value" />
			</xsl:variable>
			<xsl:if test="@type='attribute'">
				<li>::&#160;<a href="index.asp?cat={$back1}{$back2}{$back3}/keyword-/dnatrs-{$url-value}"><xsl:value-of select="@display-value" /></a></li>
			</xsl:if>
		</xsl:for-each>
	</ul>
 
	<!-- Main Content -->
	<div id="mainresults">
		<table cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td class="nopadding" colspan="4">
					<h1>Items Found (<xsl:value-of select="//domain/domain-listing/hybrid-items/@total" />)</h1>
				</td>
			</tr>
			<tr>
				<td class="nopadding" colspan="4">
					<!-- get session variable for link-->
					<xsl:variable name="catid">
						<xsl:value-of select="substring(//form/url2,$url2sub)" />
					</xsl:variable>
 
					<!-- get session variable for sort order-->
					<xsl:variable name="so">
						<xsl:value-of select="xasp:GetRequestVariable('so','session')" />
					</xsl:variable>
 
					<!-- build variable for narrowing down the results -->
					<xsl:variable name="narrow">
						<xsl:for-each select="//bread-crumbs/crumb">
							<xsl:if test="@type='attribute'">
								<xsl:value-of select="concat(@url-value,'-')" />
							</xsl:if>
						</xsl:for-each>
					</xsl:variable>
 
					<!-- get session variable for page no-->
					<xsl:variable name="pg">
						<xsl:value-of select="xasp:GetRequestVariable('pg','session')" />
					</xsl:variable>
 
					<!-- get session variable for sortby-->
					<xsl:variable name="sb">
						<xsl:value-of select="xasp:GetRequestVariable('sb','session')" />
					</xsl:variable>
 
					<!-- build sort by links -->
					<div class="sortbar">
						Sort by:
						<xsl:choose>
							<xsl:when test="$sb=0">
								<xsl:choose>
									<xsl:when test="$so=2">
										<a class="selected" href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=0&amp;so={$so}">Best match
										<img style="vertical-align:top;" border="0" src="sort.gif" /></a>&#160;&#160;
									</xsl:when>
									<xsl:otherwise>
										<a class="selected" href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=0&amp;so={$so}">Best match
										<img style="vertical-align:top;" border="0" src="sortdesc.gif" /></a>&#160;&#160;
									</xsl:otherwise>
								</xsl:choose>
							</xsl:when>
							<xsl:otherwise>
								<a href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=0&amp;so={$so}">Best match</a>&#160;&#160;
							</xsl:otherwise>
						</xsl:choose>
 
						<xsl:choose>
							<xsl:when test="$sb=2">
								<xsl:choose>
									<xsl:when test="$so=2">
										<a class="selected" href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=2&amp;so={$so}">Price
										<img style="vertical-align:top;" border="0" src="sort.gif" /></a>&#160;&#160;
									</xsl:when>
									<xsl:otherwise>
										<a class="selected" href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=2&amp;so={$so}">Price
										<img style="vertical-align:top;" border="0" src="sortdesc.gif" /></a>&#160;&#160;
									</xsl:otherwise>
								</xsl:choose>
							</xsl:when>
							<xsl:otherwise>
								<a href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=2&amp;so={$so}">Price</a>&#160;&#160;
							</xsl:otherwise>
						</xsl:choose>
 
						<xsl:choose>
							<xsl:when test="$sb=3">
								<xsl:choose>
									<xsl:when test="$so=2">
										<a class="selected" href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=3&amp;so={$so}">Store Name
										<img style="vertical-align:top;" border="0" src="sort.gif" /></a>&#160;&#160;
									</xsl:when>
									<xsl:otherwise>
										<a class="selected" href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=3&amp;so={$so}">Store Name
										<img style="vertical-align:top;" border="0" src="sortdesc.gif" /></a>&#160;&#160;
									</xsl:otherwise>
								</xsl:choose>
							</xsl:when>
							<xsl:otherwise>
								<a href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=3&amp;so={$so}">Store Name</a>&#160;&#160;
							</xsl:otherwise>
						</xsl:choose>
 
						<xsl:choose>
							<xsl:when test="$sb=5">
								<xsl:choose>
									<xsl:when test="$so=2">
										<a class="selected" href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=5&amp;so={$so}">Store Rating
										<img style="vertical-align:top;" border="0" src="sort.gif" /></a>&#160;&#160;
									</xsl:when>
									<xsl:otherwise>
										<a class="selected" href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=5&amp;so={$so}">Store Rating
										<img style="vertical-align:top;" border="0" src="sortdesc.gif" /></a>&#160;&#160;
									</xsl:otherwise>
								</xsl:choose>
							</xsl:when>
							<xsl:otherwise>
								<a href="index.asp?cat={$catid}/dnatrs-{$narrow}&amp;sb=5&amp;so={$so}">Store Rating</a>&#160;&#160;
							</xsl:otherwise>
						</xsl:choose>
					</div>
				</td>
			</tr>
 
			<!-- display the products -->
			<xsl:for-each select="//domain/domain-listing/hybrid-items/store-offer">
				<!--path for product image-->
				<xsl:variable name="offer-image">
					<xsl:value-of select="offer-image" />
				</xsl:variable>
 
				<!--path for store logo-->
				<xsl:variable name="store-logo">
					<xsl:value-of select="store-logo" />
				</xsl:variable>
 
				<!-- path for store-rating-image -->
				<xsl:variable name="store-rating-image">
					<xsl:value-of select="store-rating-image" />
				</xsl:variable>
 
				<!--url for deal-->
				<xsl:variable name="offer-url">
					<xsl:value-of select="offer-url" />
				</xsl:variable>
 
				<!-- url encoded offer-url link so that we can pass it through to a redirect.asp page -->
				<xsl:variable name="offer-url-encoded">
					<xsl:value-of select="xasp:encodeURL(string(offer-url))" />
				</xsl:variable>
 
				<tr>
					<td>
						<img src="{$offer-image}" />
					</td>
					<td valign="top">
						<strong><a href="redirect.asp?target={$offer-url-encoded}" target="_blank"><xsl:value-of select="offer-name" /></a></strong><br/><br/>
						<xsl:value-of select="offer-description" /><br/><br/>
						<strong>In stock:</strong>&#160;<xsl:value-of select="in-stock" /><br/>
						<xsl:if test="not(string-length(stock-description)=0)">
							<strong>Availability:</strong>&#160;<xsl:value-of select="stock-description" /><br/><br/>
						</xsl:if>
					</td>
					<td width="20%" align="center">
						<img src="{$store-logo}" /><br/><br/>
						<xsl:choose>
							<xsl:when test="(string-length($store-rating-image)=0)">
								Not Reviewed
							</xsl:when>
							<xsl:otherwise>
								<img src="{$store-rating-image}" /><br/><br/>
							</xsl:otherwise>
						</xsl:choose>
					</td>
					<td width="20%" align="center" valign="center">
						<br/>&#163;<xsl:value-of select="format-number(offer-price,'###,##0.00')" /><br/>
						P&amp;P <xsl:value-of select="shipping" /><br/>
						<strong>&#163;
						<xsl:choose>
							<xsl:when test="string(number(total-price))='NaN'">
								<xsl:value-of select="total-price" />
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="format-number(total-price,'###,##0.00')" />
							</xsl:otherwise>
						</xsl:choose>
						</strong><br/>
						<a href="redirect.asp?target={$offer-url-encoded}" target="_blank"><img style="margin:8px 0px;" src="buynow2.gif" border="0" /></a><br/>
						<a href="redirect.asp?target={$offer-url-encoded}" target="_blank"><xsl:value-of select="store-name" /></a><br/><br/>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</div>
 
	<!-- show "narrow results by" column -->
	<xsl:choose>
		<xsl:when test="//attribute-list/attribute">
			<div id="narrowresults">
				<h1>Narrow results by</h1>
				<xsl:for-each select="//attribute-list/attribute">
					<h2><xsl:value-of select="@name" /></h2>
					<div class="narrowresultscontent">
						<xsl:for-each select="attr-value">
							<xsl:variable name="filter">
								<xsl:value-of select="substring(url2,$url2sub2)" />
							</xsl:variable>
							<a href="index.asp?cat={$filter}"><xsl:value-of select="name" /></a>&#160;<span class="smallcounter">(<xsl:value-of select="count" />)</span><br/>
						</xsl:for-each><br/>
					</div>
				</xsl:for-each>
			</div>
		</xsl:when>
		<xsl:otherwise>
			<div id="narrowresults">
				<h1>Narrow results by</h1>
				<xsl:variable name="results">
					<xsl:value-of select="//domain/domain-listing/hybrid-items/@total" />
				</xsl:variable>
 
				<xsl:choose>
					<xsl:when test="$results=1">
						<div class="narrowresultscontent"><strong>There is <xsl:value-of select="$results" /> item that
						matched your selection.</strong> There are no additional ways to narrow down these results.</div>
					</xsl:when>
					<xsl:otherwise>
						<div class="narrowresultscontent"><strong>There are <xsl:value-of select="$results" /> items that
						matched your selection.</strong> There are no additional ways to narrow down these results.</div>
					</xsl:otherwise>
				</xsl:choose>
			</div>
		</xsl:otherwise>
	</xsl:choose>
</div>
</xsl:template>
</xsl:stylesheet>

Open in new window

Author

Commented:
here is the one that doesnt work,
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
    xmlns:user="urn:comparionsplus-com:xslt"
    xmlns:yahoo="urn:yahoo:prods"
    xmlns:xasp="urn:asp-objects">
    <xsl:output method="html"/>
    <xsl:template match="/">
        <html>
            <body>
                <xsl:apply-templates select="yahoo:ProductSearch/yahoo:Products"/>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="yahoo:ProductSearch/yahoo:Products">
 
            
        <xsl:apply-templates select="yahoo:Product/yahoo:Offer"/>
    </xsl:template>
    	<xsl:variable name="offer-url">
					<xsl:value-of select="yahoo:Url" />
				</xsl:variable>
    				<xsl:variable name="offer-url-encoded">
					<xsl:value-of select="xasp:encodeURL(string(yahoo:Url))" />
				</xsl:variable>
 
    <xsl:template match="yahoo:Products/yahoo:Product/yahoo:Offer">
<div class="clear"></div>
<div class="products">
      <table align="center" class="style2" bgcolor="ffffff" cellpadding="3" border="1">
        <tr>
            <td align="center" class="style23" rowspan="3">
                     <a>
      
       <xsl:attribute name="href">redirect.aspx?target=<xsl:value-of select="$offer-url-encoded"/>
       </xsl:attribute>
       
       <img>
       <xsl:attribute name="src" >
       
       <xsl:value-of select="yahoo:ListImage/yahoo:Url"/>
       </xsl:attribute> 
       <xsl:attribute name="border"> <xsl:value-of select="0"/>
       </xsl:attribute>
       <xsl:attribute name="alt">
       <xsl:value-of select="yahoo:ProductName"/>
       </xsl:attribute>
       </img>
       <input><xsl:attribute name="name"><xsl:text>productLink</xsl:text></xsl:attribute><xsl:attribute name="type"><xsl:text>hidden</xsl:text></xsl:attribute><xsl:attribute name="value"><xsl:value-of select="$offer-url-encoded"/></xsl:attribute></input>
       </a></td>
            <td class="style27" colspan="3">
                <xsl:value-of select="yahoo:ProductName"/></td>
            <td class="style19">
                Price</td>
            <td align="center" class="style9">
                 <xsl:value-of select="yahoo:Price"/> GBP</td>
        </tr>
        <tr>
            <td colspan="3" rowspan="2">
 
              <xsl:value-of select="translate(normalize-space(yahoo:Summary), '#', '')"/>
            </td>
            <td class="style19">
                Delivery</td>
            <td align="center" class="style9">
                <xsl:value-of select="yahoo:DeliveryCost"/> GBP</td>
        </tr>
        <tr>
            <td align="center" class="style10" colspan="2">
               
                <xsl:value-of select="yahoo:Availability"/></td>
        </tr>
        <tr>
            <td class="style23">
                Category</td>
            <td align="center" colspan="2">
                <a><xsl:attribute name="href">home.aspx?catid=<xsl:value-of select="yahoo:Category/@id"/>&amp;title=<xsl:value-of select="translate(normalize-space(yahoo:Category/yahoo:Name), ' ', '_')"/></xsl:attribute><xsl:value-of select="yahoo:Category/yahoo:Name"/></a></td>
            <td align="center" colspan="2"> 
                <xsl:value-of select="yahoo:Merchant/yahoo:Name"/>
 </td>
            <td align="center" class="style10" colspan="2">
           <div> 
           <a>
 
  <xsl:attribute name="href"><xsl:text>redirect.aspx</xsl:text></xsl:attribute>Buy Now
  
    <input>
  <xsl:attribute name="id"><xsl:text>productLink</xsl:text></xsl:attribute><xsl:attribute name="name"><xsl:text>productLink</xsl:text></xsl:attribute><xsl:attribute name="method"><xsl:text>post</xsl:text></xsl:attribute><xsl:attribute name="type"><xsl:text>hidden</xsl:text></xsl:attribute><xsl:attribute name="runat"><xsl:text>server</xsl:text></xsl:attribute><xsl:attribute name="value"><xsl:value-of select="yahoo:Url"/></xsl:attribute>
  </input>
  </a>
 
  
</div>
</td>
        </tr>
    </table>
</div>
         <br />
    </xsl:template>
    
 
</xsl:stylesheet>

Open in new window

Gertone (Geert Bormans)Information Architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
yep, that is likely an extension library
what processor are you using on the computer that does work?
it is hard for me to tell how the extension library is configured.
There likely is a jar on the classpath that is included
or a .dll that is connected one way or another.
You have to make sure that you copy and configure that as wel
Information Architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Gertone, Could  i trouble you to look at this one.

In an effort to over come the problems i was having using the asp namespace i tried to create an extension object to url encode the urls.

this seems to almost right, but i cant work out where its going wrong. your help would be much appreciated.
thank You

https://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_24562199.html
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.