You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Zeynep Gunal <z....@publitec.vnu.com> on 2001/03/30 12:48:32 UTC
Xalan-Java extensions - Is this the right mailing list to post th
is?
Hi,
I posted a question/request to the XSL-LIST mailing list and I received such
a reply:
Xalan supports JavaScript, but it doesn't do it using Microsoft's
<msxsl:script> element, it has its own syntax for binding the
implementation
of the extension functions.
Now, where can I get the information as to what this syntax is?
If Xalan-Dev is not the appropriate mailing list, could you please redirect
me?
Thanks a lot,
Zeynep
Copying from my original posting:
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.
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@hotmail.com"
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
Re: Xalan-Java extensions - Is this the right mailing list to post this?
Posted by Gary L Peskin <ga...@firstech.com>.
Zeynep Gunal wrote:
>
> Hi,
>
> I posted a question/request to the XSL-LIST mailing list and I received such
> a reply:
>
> Xalan supports JavaScript, but it doesn't do it using Microsoft's
> <msxsl:script> element, it has its own syntax for binding the
> implementation
> of the extension functions.
>
> Now, where can I get the information as to what this syntax is?
http://xml.apache.org/xalan-j/extensions.html#supported-lang
Gary