0

I'm using oXygen editor XML Editor 19.0 with Saxon-EE 9.7.0.15.

I wrote the simple stylesheet below in order to test the saxon:send-mail function but, every time I try to run it, Saxon return a java.lang.NullPointerException error. Extended functions (-ext) are activated. I also get the same error with Saxon-PE.

Does anybody have an idea where the error may come from?

Here is the stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/"
    exclude-result-prefixes="xs" version="3.0">

    <xsl:variable name="mailSetup" as="map(xs:string, xs:string)">
        <xsl:map>
            <xsl:map-entry key="'to'" select="'[email protected]'"/>
            <xsl:map-entry key="'from'" select="'[email protected]'"/>
            <xsl:map-entry key="'smtp-server'" select="'smtp.gmail.com'"/>
            <xsl:map-entry key="'username'" select="'[email protected]'"/>
            <xsl:map-entry key="'password'" select="'mepassword'"/>
        </xsl:map>
    </xsl:variable>

    <xsl:variable name="html" as="xs:string">
      <![CDATA[ <html>
            <body>
                <h1>Test saxon:send-mail</h1>
                <p>Test Ok</p>
            </body>
        </html>]]> 
    </xsl:variable>

    <xsl:template name="main">
        <xsl:value-of select="saxon:send-mail($mailSetup, 'Test', $html, ())"/>
    </xsl:template>

</xsl:stylesheet>
4
  • 2
    It appears that Saxon uses the javax.mail API which is not part of the Java SE so you might need to install it from javaee.github.io/javamail/#Download_JavaMail_Release and put it on the class path. I have not checked whether that fixes the issue. Commented Aug 17, 2017 at 19:31
  • 1
    It seems putting that jar on the class path and running Saxon from the command line does not fix the issue, with 9.7 I get the NullPointerException you say you get inside oXygen, with 9.8 I get a RuntimeException caused by a NullPointerException. Commented Aug 17, 2017 at 19:41
  • 1
    And oXygen seems to come with a mailapi.jar already. Commented Aug 17, 2017 at 20:03
  • With a NullPointerException, it always helps to give a stack trace. Commented Aug 17, 2017 at 23:18

1 Answer 1

1

Logged here as a Saxon bug:

https://saxonica.plan.io/issues/3400

The NPE occurs if any of the mail options is missing from the map. In your case the missing option is realname.

The options are documented here:

http://www.saxonica.com/documentation/index.html#!functions/saxon/send-mail

except that the "cc" option seems to be missing from the documentation.

Sign up to request clarification or add additional context in comments.

3 Comments

The html option is also needed.
Is there a way to ask that the connection be SSL?
You may be able to configure it by setting Java system properties, see oracle.com/technetwork/java/javamail145sslnotes-1562622.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.