Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2004, 04:57 PM
Registered User
 
Join Date: Jun 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Maximum Length for XSL variable

Hi,

I have tried to find an answer but I can not find one. I thought this board could provide some guidance/assistance. Thanks.

My dilemma is: I'm using --objSessionData("Query")-- to pass a querystring to a xsl variable "P_Query". Though the xsl variable is not holding querys that exceed 2200(or around 2200) characters.

ManyScripts.asp
if oxsldoc.documentelement.selectsinglenode("//xsl:variable[@name='P_Query']") is nothing = false then
oxsldoc.documentelement.selectsinglenode("//xsl:variable[@name='P_Query']").text = objSessionData("Query") end if

someXSL.xsl
<xsl:variable name="P_Query"></xsl:variable>

This works great, however, sometimes the querystring "objSessionData("Query")" can exceed 2200 characters and the xsl variable "P_Query" will not hold the complete querystring.

I'm using "P_Query" to pass the querystring as a link called "Next Page". P_Query holds the search criteria <C><P><O><V></V></O></P></C> and passes the querystring to the next page.

My question: Is there a way to assign maxlength to the xsl variable"P_Query"?

Thank you for your time and assistance -- It's greatly appreciated.

Thanks,
Mike
 
Old January 28th, 2004, 05:33 PM
Registered User
 
Join Date: Jun 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

here's the link structure:
<TR>
<TD align="left" width="30%">
<xsl:if test="number(@Current_Page) &gt; 1">
<A>
<xsl:attribute name="HREF"><![CDATA[_SearchResults.asp?Action=PageBak&Map=]]><xsl:value-of select="$XMLMAPMap"/><![CDATA[&XSL=]]><xsl:value-of select="$ListXSL"/><![CDATA[&Page=]]><xsl:value-of select="@Current_Page"/><![CDATA[&Query=]]><xsl:value-of select="$P_Query"/></xsl:attribute><img src="images/left.gif" border="0"/>Previous Page
</A>
</xsl:if>
</TD>
<TD align="center" width="40%">
<xsl:value-of select="@Record_Count" /> Records Found <BR/>
Page <xsl:value-of select="@Current_Page" /> of <xsl:value-of select="@Page_Count" />
</TD>
<TD align="right" width="30%">
<xsl:if test="number(@Current_Page) &lt; number(@Page_Count)">[/green]

<A>
<xsl:attribute name="HREF"><![CDATA[_SearchResults.asp?Action=PageFwd&Map=]]><xsl:value-of select="$XMLMAPMap"/><![CDATA[&XSL=]]><xsl:value-of select="$ListXSL"/><![CDATA[&Page=]]><xsl:value-of select="@Current_Page"/><![CDATA[&Query=]]><xsl:value-of select="$P_Query"/></xsl:attribute>
Next Page <img src="images/right.gif" border="0"/>
</A>

</xsl:if>
</TD>
</TR>

Thanks,
Mike
 
Old January 29th, 2004, 07:25 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Which version of DomDocument are you using, I don't know of any limitation on string length, other than max length in VB which is about 65k.
Can you show where you create the DomDocument? Are you sure the full string is being held in the session variable and it's not being truncated before it reaches the xsl?

Aside from that this code is very wasteful, searching twice for the same node:
Code:
if oxsldoc.documentelement.selectsinglenode("//xsl:variable[@name='P_Query']") is nothing = false then
oxsldoc.documentelement.selectsinglenode("//xsl:variable[@name='P_Query']").text = objSessionData("Query") end if
change it to:
Code:
Dim oSearchNode
Set oSearchNode = oxsldoc.documentElement.selectSingleNode("//xsl:variable[@name='P_Query']")
If Not oSearchNode Is Nothing Then
  oSearchNode.text = objSessionData("Query")
End If
Joe (MVP - xml)
 
Old January 29th, 2004, 10:31 AM
Registered User
 
Join Date: Jun 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Joe,

Thanks for assisting. The objSessionData("Query")does contain the entire querystring. The initial search criteria is passed using objSessionData("Query")and it returns the first page of search results. However when you click on the "Next Page" link (the P_Query variable) nothing happens (and again this is only when the search criteria is extremely long). I agree I didn't find any text that gave a maximum length. It's driving me mad =)

Here is the domdocument info:


function XMLTransform(sXMLDoc,sXSLDoc)
dim oXmlDoc
dim oXslDoc

set oXmlDoc = Server.CreateObject("Msxml2.DOMDocument.3.0")
set oXslDoc = Server.CreateObject("Msxml2.DOMDocument.3.0")
oXmlDoc.async = false
oXslDoc.async = false
oxmldoc.preservewhitespace = false
oXmlDoc.load(application("XMLDir") & "\" & sXMLDoc)
if oXmlDoc.parseError.errorCode <> 0 then
response.write "The following error occurred while processing the XML file: <br>" & oXmlDoc.parseError.errorCode & ", " & oXmlDoc.parseError.reason & ", " & oXmlDoc.ParseError.line
end if

oXslDoc.load(application("XSLDir") & "\" & sXSLDoc)
oxsldoc.setProperty "SelectionLanguage", "XPath"
oxsldoc.setProperty "SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'"
if oXslDoc.parseError.errorCode <> 0 then
response.write "The following error occurred while processing the XSL stylesheet: <br>" & oXslDoc.parseError.errorCode & ", " & oXslDoc.parseError.reason
        response.end
end if

Thanks again Joe. I do appreciate your time and knowledge.

Mike
 
Old January 29th, 2004, 12:04 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If you run this code, it needs WScript installed so Windows only, you'll see that the file is fine, IE won't display it properly but if opened in text editor it's all there. So there must be a problem elsewhere. FILE_PATH needs altering before you run it.
Code:
var DATA_LENGTH = 10000;
var FILE_PATH = "E:\\scripts\\xml\\longString.xml"; //Change this to somewhere local

function getDomDoc()
{
  var oDom =  new ActiveXObject("Msxml2.DomDocument.3.0");
  oDom.async = false;
  return oDom;
}

function main()
{
  var oDom = getDomDoc();
  var sXml = "<root/>";
  oDom.loadXML(sXml);
  var sText = "1";
  for (var i = 1; i < DATA_LENGTH - 1; i++)
  {
    sText += "0";     
  }
  sText += "1";
  var oNode = oDom.selectSingleNode("root");
  oNode.text = sText;
  oDom.save(FILE_PATH);
  WScript.echo("Done");
}

main();


--

Joe





Similar Threads
Thread Thread Starter Forum Replies Last Post
Maximum length of http Object mohan.karunanidhi Ajax 2 November 21st, 2006 06:11 AM
How to set a length of a Variable rtr1900 ASP.NET 1.0 and 1.1 Basics 2 May 19th, 2006 01:07 AM
Maximum Request Length exceeded? dparsons ASP.NET 1.0 and 1.1 Professional 0 March 23rd, 2006 12:41 AM
Setting xsl:variable maximum count isme XSLT 2 March 14th, 2006 03:39 AM
make textbox maximum length of <td> cell crmpicco Javascript How-To 0 October 19th, 2005 10:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.