Note that there are some explanatory texts on larger screens.

plurals
  1. POXSL processor stack has overflowed - can't understand why
    primarykey
    data
    text
    <p>I'm trying to conditionally display the content of HTML page depending if a document being generated for a recognised company or not.</p> <p>However, the transformation doesn't work and I can't understand why :( I use MSXML3.0 as transformer and oXygen as IDE, which gives the errors I presented below.</p> <p>What I do is to construct a long string of all recognised companies (default and extra if any). I then split them into <code>&lt;token&gt;</code> elements that are stored in the <code>$companiesKnownList</code> variable. To determine if a company is in that list I count how many times it occurs:</p> <pre><code>count($companiesKnownList/token[normalize-space(.) = $productName]) &amp;lt; 1 </code></pre> <p>If it's less than 1, then the company doesn't appear in the <code>$companiesKnownList</code> variable and therefore is not recognized. Otherwise, if it appears in the <code>$companiesKnownList</code> variable once or more times it is a recognized company. Nevertheless, this is where it breaks and displays the following error:</p> <pre><code>Description: Code: 0x80004005 Description: The XSL processor stack has overflowed - probable cause is infinite template recursion. Description: The transformer process ended with code: 1 </code></pre> <p>I've noticed that if my XML has got a recognised company, ex <code>@ProductName="ski"</code> then transformation fails with stack overflow. If I have an unrecognized company, ex <code>@ProductName="bla"</code> the transformation works and text that it isn't a recognized company is displayed.</p> <p>I don't understand what's going wrong with valid companies. I would be more than grateful if you could help me out. I have been staring at it for a day now...without any progress :S</p> <p>Thanks!</p> <p><strong>Here is my stylesheet:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:str="http://exslt.org/strings" extension-element-prefixes="msxsl str" version="1.0"&gt; &lt;!-- Taken from http://www.exslt.org/str/functions/tokenize/index.html --&gt; &lt;xsl:import href="str.tokenize.template.xsl"/&gt; &lt;!-- normalize and lowcase product name --&gt; &lt;xsl:variable name="productName" select="normalize-space(translate(/Doc/@ProductName, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'))"/&gt; &lt;!-- default recognised companies for all docs --&gt; &lt;xsl:variable name="defaultRecognisedCompanies" select="'ski, holiday, summer trips'"/&gt; &lt;!-- Determine what companies to generate a doc for --&gt; &lt;xsl:variable name="companiesKnownListRaw"&gt; &lt;xsl:call-template name="recognisedCompanies"/&gt; &lt;/xsl:variable&gt; &lt;xsl:variable name="companiesKnownList" select="msxsl:node-set($companiesKnownListRaw)"/&gt; &lt;!-- Lists recognised companies for a document to be generated for --&gt; &lt;xsl:template name="recognisedCompanies"&gt; &lt;xsl:call-template name="recognisedCompaniesListForDocument"/&gt; &lt;/xsl:template&gt; &lt;xsl:template name="recognisedCompaniesListForDocument"&gt; &lt;xsl:param name="defaultCompanies" select="$defaultRecognisedCompanies"/&gt; &lt;xsl:param name="isUseDefaultsCompanies" select="true()"/&gt; &lt;xsl:param name="extraCompanies" select="''"/&gt; &lt;xsl:variable name="allCompaniesRaw"&gt; &lt;xsl:call-template name="str:tokenize"&gt; &lt;xsl:with-param name="string"&gt; &lt;xsl:choose&gt; &lt;!-- keep default companies --&gt; &lt;xsl:when test="$isUseDefaultsCompanies = 'true'"&gt; &lt;xsl:value-of select="concat($defaultCompanies, ', ', $extraCompanies)"/&gt; &lt;/xsl:when&gt; &lt;!-- discard default companies --&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="$extraCompanies"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:with-param&gt; &lt;xsl:with-param name="delimiters" select="','" /&gt; &lt;/xsl:call-template&gt; &lt;/xsl:variable&gt; &lt;!-- Normalize token's value and discard empty values --&gt; &lt;xsl:for-each select="msxsl:node-set($allCompaniesRaw)/token"&gt; &lt;xsl:if test="normalize-space(.) != ''"&gt; &lt;token&gt; &lt;xsl:value-of select="normalize-space(.)"/&gt; &lt;/token&gt; &lt;/xsl:if&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;!-- Construct HTML doc. Display appropriate message for a company if it's recognized or not --&gt; &lt;xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" doctype-system="http://www.w3.org/TR/html4/loose.dtd" encoding="UTF-8" indent="yes"/&gt; &lt;xsl:template match="/Doc"&gt; &lt;html&gt; &lt;xsl:choose&gt; &lt;!-- Not recognised company --&gt; &lt;!-- There is something wrong with the count conditions, and I don't understand what :( --&gt; &lt;xsl:when test="count($companiesKnownList/token[normalize-space(.) = $productName]) &amp;lt; 1"&gt; &lt;body&gt; &lt;div align="center"&gt; This type of company is NOT recognised for this document. &lt;/div&gt; &lt;/body&gt; &lt;/xsl:when&gt; &lt;!-- Recognised company --&gt; &lt;xsl:otherwise&gt; &lt;body&gt; &lt;div align="center"&gt; This type of company is recognised for this document. &lt;/div&gt; &lt;/body&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/html&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>XML</strong> is something simple like:</p> <p>In this example, <code>ski</code> is recognized company, but transformation fails. <code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;Doc ProductName="ski" /&gt;</code></p> <p>In this example, <code>bla</code> is not a recognized company and transformation succeeds with displaying text: "This type of company is NOT recognised for this document." <code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;Doc ProductName="bla" /&gt;</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload