Subject: [xsl] Xalan-Java extensions From: Zeynep Gunal <z.gunal@xxxxxxxxxxxxxxxx> Date: Wed, 21 Mar 2001 17:04:43 +0100 |
Hi again, I hope one day I will stop crying for help and start helping others, but it seems a long way away! In the meantime, I am trying to write some stuff to a file in "append" mode (I don't have to use XSLT to do that, I just liked the challenge) . I found a "JavaScript File object proposal" on Mozilla's web site but no follow-ups... Dead-end there. Then I decided to use Microsoft's JScript to see if I can use the FileSystemObject and its methods. The problem is, I could not even call my function (I first try it without passing a string): I am getting the error message "Instance method call to method appendtolog requires an Object instance as first argument". I read on Apache's website that Microsoft's JScript is a supported language and I downloaded the necessary dll's. The bsf.jar is on the class path. One last info: I am not a Java programmer, nor have I used JScript before. Either I am doing something really stupid, or ... if I could figure that out, I wouldn't be writing here! This is my command: java -cp xerces.jar;xalan.jar;bsf.jar;js.jar org.apache.xalan.xslt.Process -IN NotificationResponse.XML -XSL Site_Builder_NotificationResponse.xsl My AppendToLog_MSjavascript.xsl: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:mynamespace="urn:zgunal@xxxxxxxxxxx" extension-element-prefixes="msxsl" exclude-result-prefixes="mynamespace"> <msxsl:script language="JScript" implements-prefix="mynamespace"> { var fso, tf, a, ForAppending; ForAppending = 8; logString = "Testing.."; logFileName = "c:\testfile.txt"; fso = new ActiveXObject("Scripting.FileSystemObject"); if (fso.FileExists(logFileName)) tf = fs.OpenTextFile(logFileName, ForAppending, false); else tf = fso.CreateTextFile(logFileName, true); // Write the input string with a newline character. tf.WriteLine(logString) ; tf.Close(); } </msxsl:script> <xsl:template name="append-to-log"> <xsl:param name="log-string" select="." /> <xsl:value-of select="mynamespace:appendtolog()" /> </xsl:template> </xsl:stylesheet> And my main XSL (to be improved if the function call succeeds): <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:output method="html" indent="yes"/> <xsl:include href="AppendToLog_MSjavascript.xsl"/> <xsl:template match="/"> <xsl:if test="//ErrorInfo/ErrorCode != ''"> <xsl:apply-templates select="//ErrorInfo" /> </xsl:if> </xsl:template> <xsl:template match="//ErrorInfo"> <xsl:call-template name="append-to-log"> <xsl:with-param name="log-string"> <xsl:value-of select="concat('Merchant ID: ', //MerchantID)" /> </xsl:with-param> </xsl:call-template> <xsl:call-template name="append-to-log"> <xsl:with-param name="log-string"> <xsl:value-of select="concat('Staged Site: ', //StagedSite)" /> </xsl:with-param> </xsl:call-template> <xsl:call-template name="append-to-log"> <xsl:with-param name="log-string"> <xsl:value-of select="concat(ErrorCode, ' - ', ErrorMsg)" /> </xsl:with-param> </xsl:call-template> </xsl:template> </xsl:stylesheet> And, at last, this is the input XML: <NotificationResponse> <TransactionID>2912412340</TransactionID> <Operation>AdSiteCreated</Operation> <Mode>Batch</Mode> <PublisherInfo> <PublisherID>1</PublisherID> <PartnerID>2</PartnerID> <ProgramID>3</ProgramID> <AgentID>4567</AgentID> </PublisherInfo> <MerchantID>43245</MerchantID> <StagedSite>Some Text</StagedSite> <ErrorInfo> <ErrorCode>12345</ErrorCode> <ErrorMsg>Dummy Message</ErrorMsg> </ErrorInfo> <Messages> <Message>Some Message Text</Message> <Message>Some More Message Text</Message> </Messages> </NotificationResponse> Apologies for the length of my message. I appreciate your patience... And... any ideas? Many thanks in advance. Zeynep XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Problem with html input t, Dylan Walsh | Thread | RE: [xsl] Xalan-Java extensions, Chris Bayes |
RE: [xsl] Problem with html input t, Dylan Walsh | Date | RE: [xsl] Which xmlns:xsl to use ?, Clapham, Paul |
Month |