passing param to XSLT

Results 1 to 2 of 2

Thread: passing param to XSLT

  1. #1
    Join Date
    Dec 1969

    Default passing param to XSLT

    In the following code sample, I am trying to pass a value into my XSLT, but I get the error:<BR><BR>Microsoft VBScript runtime (0x800A01A8)<BR>Object required: &#039;[object]&#039;<BR><BR>The error is occurring on the line between the two commented lines saying &#039;*** ERROR ***<BR><BR><BR>dim objXMLDoc<BR>dim objXSLDoc<BR>dim strXMLDoc<BR>dim strXSLDoc<BR>dim strResults<BR>dim Cnt<BR>dim Location<BR>dim Path<BR>dim strHTTP<BR>dim String1<BR>dim strLeft<BR>dim strRight<BR>dim XSLParam<BR>dim ItemToView<BR><BR>const PROG_ID = "Microsoft.XMLDOM"<BR>&#039;Get the XML file name from the Request object<BR>strXMLDoc = server.mappath(request("XML"))<BR>&#039;Get the XSL file name from the Request object<BR>strXSLDoc = server.mappath("./Browse.xsl")<BR>Path = request("Path")<BR>ItemToView = request("Item")<BR>strHTTP = chr(34) & "http://" & chr(34)<BR><BR>if err.number = 0 then<BR> &#039;Parse the XML Document<BR> set objXMLDoc = server.CreateObject(PROG_ID)<BR> objXMLDoc.async = false<BR> objXMLDoc.load(strXMLDoc)<BR> if objXMLDoc.parseError.errorCode = 0 then<BR> &#039;Parse the XSL style sheet<BR> set objXSLDoc = server.CreateObject(PROG_ID)<BR> objXSLDoc.async = false<BR> objXSLDoc.load(strXSLDoc)<BR> set XSLParam = objXSLDoc.selectSingleNode("//xsl:param[@name=&#039;ItemToView&#039;]")<BR>&#039;*** ERROR ***<BR> XSLParam.childnodes(0).nodevalue = ItemToView <BR>&#039;*** ERROR ***<BR> if objXSLDoc.parseError.errorCode = 0 then<BR> &#039;If no errors, transform the XML <BR> &#039;into HTML using the XSL style sheet<BR> strResults = objXMLDoc.transformNode(objXSLDoc)<BR> else<BR> strResults = "The following error " & _<BR> "occurred while " & _<BR> "processing the XSL " & _<BR> "stylesheet: <BR>" &_<BR> objXSLDoc.parseError.errorCode & _<BR> ", " & _<BR> objXSLDoc.parseError.reason<BR> end if<BR> else<BR><BR><BR><BR><BR>Here are the first few lines of my XSLT<BR><BR>&#060;?xml version="1.0" encoding="UTF-8"?&#062;<BR>&#060;xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:did="urn:mpeg:mpeg21:2002:01-DIDL-NS" &#062;<BR>&#060;xsl:param name="ItemToView" select="&#039;1&#039;" /&#062;<BR><BR>&#060;xsl:template match="/"&#062;<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: passing param to XSLT

    This is your code:<BR><BR>set XSLParam = objXSLDoc.selectSingleNode("//xsl:param[@name=&#039;ItemToView&#039;]")<BR>XSLParam.childnodes(0).nodevalue = ItemToView <BR><BR>In the first of these lines you select this xml node:<BR>&#060;xsl:param name="ItemToView" select="&#039;1&#039;" /&#062;<BR><BR>In the second lone you want to access the first child node of this node, but the node you just selected does not have any child nodes...<BR>You can try this:<BR>XSLParam.Text = ItemToView<BR><BR>Also, I wonder if this is a proper way to set the values of parameters in an xsl file. I would use the XSLProcessor object and use it&#039;s AddParameter method to set the parameters... See more info.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts