RE: [xsl] Accessing External Java Library

Subject: RE: [xsl] Accessing External Java Library
From: "Carl Bourne" <cbourne@xxxxxxxxxxxxxxx>
Date: Thu, 1 Nov 2007 16:58:08 -0000
Hmm..Still getting problems here! Any input greatly appreciated.

Output:

C:\Documents and Settings\cbourne\My Documents\PGPJava>java -cp
.;C:\javapgp\iPG
P.jar net.sf.saxon.Transform -TJ pgp.xml pgp.xslt
Loading iPGP.iPGP
Looking for method setArmor in Java class class iPGP.iPGP
Number of actual arguments = 1
Trying method getArmor: name does not match
Trying method setArmor: name matches
Method is not static
Method has 1 argument; expecting 0
Trying method getConventional: name does not match
Trying method setConventional: name does not match
Trying method getInputIsText: name does not match
Trying method setInputIsText: name does not match
Trying method getOutputIsText: name does not match
Trying method setOutputIsText: name does not match
Trying method getUseKeyID: name does not match
Trying method setUseKeyID: name does not match
Trying method getOutputFilename: name does not match
Trying method setOutputFilename: name does not match
Trying method getASCIIOutput: name does not match
Trying method getPGPSDKErrorMessage: name does not match
Trying method encrypt: name does not match
Trying method encryptAndSign: name does not match
Trying method decryptAndVerify: name does not match
Trying method hashCode: name does not match
Trying method getClass: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method equals: name does not match
Trying method toString: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching setArmor with 1 parameter found in class
iPGP.iPGP
Error at xsl:value-of on line 14 of
file:/C:/Documents%20and%20Settings/cbourne/
My%20Documents/PGPJava/pgp.xslt:
  XPST0003: XPath syntax error at char 20 on line 14 in
{PGP:setArmor(true())}:
    Cannot find a matching 1-argument function named
{iPGP.iPGP}setArmor()
Loading iPGP.iPGP
Looking for method setConventional in Java class class iPGP.iPGP
Number of actual arguments = 1
Trying method getArmor: name does not match
Trying method setArmor: name does not match
Trying method getConventional: name does not match
Trying method setConventional: name matches
Method is not static
Method has 1 argument; expecting 0
Trying method getInputIsText: name does not match
Trying method setInputIsText: name does not match
Trying method getOutputIsText: name does not match
Trying method setOutputIsText: name does not match
Trying method getUseKeyID: name does not match
Trying method setUseKeyID: name does not match
Trying method getOutputFilename: name does not match
Trying method setOutputFilename: name does not match
Trying method getASCIIOutput: name does not match
Trying method getPGPSDKErrorMessage: name does not match
Trying method encrypt: name does not match
Trying method encryptAndSign: name does not match
Trying method decryptAndVerify: name does not match
Trying method hashCode: name does not match
Trying method getClass: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method equals: name does not match
Trying method toString: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching setConventional with 1 parameter found in
class iPGP
.iPGP
Error at xsl:value-of on line 15 of
file:/C:/Documents%20and%20Settings/cbourne/
My%20Documents/PGPJava/pgp.xslt:
  XPST0003: XPath syntax error at char 27 on line 15 in
{PGP:setConventional(tru
e())}:
    Cannot find a matching 1-argument function named
{iPGP.iPGP}setConventional(
)
Loading iPGP.iPGP
Looking for method setInputIsText in Java class class iPGP.iPGP
Number of actual arguments = 1
Trying method getArmor: name does not match
Trying method setArmor: name does not match
Trying method getConventional: name does not match
Trying method setConventional: name does not match
Trying method getInputIsText: name does not match
Trying method setInputIsText: name matches
Method is not static
Method has 1 argument; expecting 0
Trying method getOutputIsText: name does not match
Trying method setOutputIsText: name does not match
Trying method getUseKeyID: name does not match
Trying method setUseKeyID: name does not match
Trying method getOutputFilename: name does not match
Trying method setOutputFilename: name does not match
Trying method getASCIIOutput: name does not match
Trying method getPGPSDKErrorMessage: name does not match
Trying method encrypt: name does not match
Trying method encryptAndSign: name does not match
Trying method decryptAndVerify: name does not match
Trying method hashCode: name does not match
Trying method getClass: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method equals: name does not match
Trying method toString: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching setInputIsText with 1 parameter found in
class iPGP.
iPGP
Error at xsl:value-of on line 16 of
file:/C:/Documents%20and%20Settings/cbourne/
My%20Documents/PGPJava/pgp.xslt:
  XPST0003: XPath syntax error at char 26 on line 16 in
{PGP:setInputIsText(true
())}:
    Cannot find a matching 1-argument function named
{iPGP.iPGP}setInputIsText()

Loading iPGP.iPGP
Looking for method setOutputIsText in Java class class iPGP.iPGP
Number of actual arguments = 1
Trying method getArmor: name does not match
Trying method setArmor: name does not match
Trying method getConventional: name does not match
Trying method setConventional: name does not match
Trying method getInputIsText: name does not match
Trying method setInputIsText: name does not match
Trying method getOutputIsText: name does not match
Trying method setOutputIsText: name matches
Method is not static
Method has 1 argument; expecting 0
Trying method getUseKeyID: name does not match
Trying method setUseKeyID: name does not match
Trying method getOutputFilename: name does not match
Trying method setOutputFilename: name does not match
Trying method getASCIIOutput: name does not match
Trying method getPGPSDKErrorMessage: name does not match
Trying method encrypt: name does not match
Trying method encryptAndSign: name does not match
Trying method decryptAndVerify: name does not match
Trying method hashCode: name does not match
Trying method getClass: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method equals: name does not match
Trying method toString: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching setOutputIsText with 1 parameter found in
class iPGP
.iPGP
Error at xsl:value-of on line 17 of
file:/C:/Documents%20and%20Settings/cbourne/
My%20Documents/PGPJava/pgp.xslt:
  XPST0003: XPath syntax error at char 27 on line 17 in
{PGP:setOutputIsText(tru
e())}:
    Cannot find a matching 1-argument function named
{iPGP.iPGP}setOutputIsText(
)
Loading iPGP.iPGP
Looking for method encrypt in Java class class iPGP.iPGP
Number of actual arguments = 4
Trying method getArmor: name does not match
Trying method setArmor: name does not match
Trying method getConventional: name does not match
Trying method setConventional: name does not match
Trying method getInputIsText: name does not match
Trying method setInputIsText: name does not match
Trying method getOutputIsText: name does not match
Trying method setOutputIsText: name does not match
Trying method getUseKeyID: name does not match
Trying method setUseKeyID: name does not match
Trying method getOutputFilename: name does not match
Trying method setOutputFilename: name does not match
Trying method getASCIIOutput: name does not match
Trying method getPGPSDKErrorMessage: name does not match
Trying method encrypt: name matches
Method is not static
Method has 4 arguments; expecting 3
Trying method encryptAndSign: name does not match
Trying method decryptAndVerify: name does not match
Trying method hashCode: name does not match
Trying method getClass: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method equals: name does not match
Trying method toString: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching encrypt with 4 parameters found in class
iPGP.iPGP
Error at xsl:variable on line 20 of
file:/C:/Documents%20and%20Settings/cbourne/
My%20Documents/PGPJava/pgp.xslt:
  XPST0003: XPath syntax error at char 62 on line 20 in {...,
$asciiresult, $err
ormessa...}:
    Cannot find a matching 4-argument function named
{iPGP.iPGP}encrypt()
Failed to compile stylesheet. 5 errors detected.

XSLT:

<?xml version="1.0" ?>
<xsl:stylesheet version="2.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
      xmlns:PGP="iPGP.iPGP"
      exclude-result-prefixes="PGP">


<xsl:template match="dataelements">

<xsl:param name="passphrase">mypswd</xsl:param>
 <xsl:param name="asciiresult"></xsl:param>
 <xsl:param name="errormessage"></xsl:param>

<xsl:value-of select="PGP:setArmor(true())" />
<xsl:value-of select="PGP:setConventional(true())" />
<xsl:value-of select="PGP:setInputIsText(true())" />
<xsl:value-of select="PGP:setOutputIsText(true())"/>

   <xsl:variable name="datain" select="data"/>
   <xsl:variable name="encryptData" select="PGP:encrypt($passphrase,
$datain, $asciiresult, $errormessage)"/>
   <xsl:value-of select="$encryptData"/>
</xsl:template>
</xsl:stylesheet>

XML:

<dataelements>
    <dataelement>
        <data>New York</data>
    </dataelement>
    <dataelement>
        <data>Boston</data>
     </dataelement>
     <dataelement>
        <data>Denver</data>
     </dataelement>
</dataelements>


Carl Bourne
Intellect
DDI: +44 1491 842502
M: +44 7770 284294





-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: 01 November 2007 15:51
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Accessing External Java Library

> The external class now loads OK but I think my xslt is wrong
> somewhere?

Like the message says:

XTSE0010: xsl:param must be the first element within a template or
function

i.e. you can't have xsl:value-of before xsl:param.

Michael Kay
http://www.saxonica.com/

>
> Any guidance would much appreciated!
>
> XML:
>
> <dataelements>
>     <dataelement>
>         <data>New York</data>
>     </dataelement>
>     <dataelement>
>         <data>Boston</data>
>      </dataelement>
>      <dataelement>
>         <data>Denver</data>
>      </dataelement>
> </dataelements>
>
> XSLT:
>
> <?xml version="1.0" ?>
> <xsl:stylesheet version="2.0"
>       xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>       xmlns:PGP="iPGP.iPGP"
>       exclude-result-prefixes="PGP">
>
> <xsl:template match="dataelements">
>    <xsl:value-of select="PGP:setArmor(true()),
>     PGP:setConventional(true()),
>     PGP:setInputIsText(true()),
>     PGP:setOutputIsText(true())"/>
>
>    <xsl:param name="passphrase">mypswd</xsl:param>
>    <xsl:param name="asciiresult"></xsl:param>
>    <xsl:param name="errormessage"></xsl:param>
>
>    <xsl:variable name="datain" select="data"/>
>    <xsl:variable name="encryptData"
> select="PGP:encrypt($passphrase, $datain, $asciiresult,
> $errormessage)"/>
>    <xsl:value-of select="$encryptData"/> </xsl:template>
> </xsl:stylesheet>
>
> Output:
>
> C:\Documents and Settings\cbourne\My
> Documents\PGPJava\saxon8>java -cp .;C:\java pgp\iPGP.jar
> net.sf.saxon.Transform -TJ ..\pgp.xml ..\pgp.xslt Loading
> iPGP.iPGP Looking for method setArmor in Java class class
> iPGP.iPGP Number of actual arguments = 1 Trying method
> getArmor: name does not match Trying method setArmor: name
> matches Method is not static Method has 1 argument; expecting
> 0 Trying method getConventional: name does not match Trying
> method setConventional: name does not match Trying method
> getInputIsText: name does not match Trying method
> setInputIsText: name does not match Trying method
> getOutputIsText: name does not match Trying method
> setOutputIsText: name does not match Trying method
> getUseKeyID: name does not match Trying method setUseKeyID:
> name does not match Trying method getOutputFilename: name
> does not match Trying method setOutputFilename: name does not
> match Trying method getASCIIOutput: name does not match
> Trying method getPGPSDKErrorMessage: name does not match
> Trying method encrypt: name does not match Trying method
> encryptAndSign: name does not match Trying method
> decryptAndVerify: name does not match Trying method hashCode:
> name does not match Trying method getClass: name does not
> match Trying method wait: name does not match Trying method
> wait: name does not match Trying method wait: name does not
> match Trying method equals: name does not match Trying method
> toString: name does not match Trying method notify: name does
> not match Trying method notifyAll: name does not match No
> method or field matching setArmor with 1 parameter found in
> class iPGP.iPGP Error at xsl:value-of on line 11 of
> file:/C:/Documents%20and%20Settings/cbourne/
> My%20Documents/PGPJava/saxon8/../pgp.xslt:
>   XPST0003: XPath syntax error at char 20 on line 11 in
> {...ue()), PGP:setConven
> tional}:
>     Cannot find a matching 1-argument function named
> {iPGP.iPGP}setArmor()
> Loading iPGP.iPGP
> Looking for method encrypt in Java class class iPGP.iPGP
> Number of actual arguments = 4 Trying method getArmor: name
> does not match Trying method setArmor: name does not match
> Trying method getConventional: name does not match Trying
> method setConventional: name does not match Trying method
> getInputIsText: name does not match Trying method
> setInputIsText: name does not match Trying method
> getOutputIsText: name does not match Trying method
> setOutputIsText: name does not match Trying method
> getUseKeyID: name does not match Trying method setUseKeyID:
> name does not match Trying method getOutputFilename: name
> does not match Trying method setOutputFilename: name does not
> match Trying method getASCIIOutput: name does not match
> Trying method getPGPSDKErrorMessage: name does not match
> Trying method encrypt: name matches Method is not static
> Method has 4 arguments; expecting 3 Trying method
> encryptAndSign: name does not match Trying method
> decryptAndVerify: name does not match Trying method hashCode:
> name does not match Trying method getClass: name does not
> match Trying method wait: name does not match Trying method
> wait: name does not match Trying method wait: name does not
> match Trying method equals: name does not match Trying method
> toString: name does not match Trying method notify: name does
> not match Trying method notifyAll: name does not match No
> method or field matching encrypt with 4 parameters found in
> class iPGP.iPGP Error at xsl:variable on line 18 of
> file:/C:/Documents%20and%20Settings/cbourne/
> My%20Documents/PGPJava/saxon8/../pgp.xslt:
>   XPST0003: XPath syntax error at char 62 on line 18 in {...,
> $asciiresult, $err
> ormessa...}:
>     Cannot find a matching 4-argument function named
> {iPGP.iPGP}encrypt()
> Error at xsl:param on line 13 of
> file:/C:/Documents%20and%20Settings/cbourne/My%
> 20Documents/PGPJava/saxon8/../pgp.xslt:
>   XTSE0010: xsl:param must be the first element within a
> template or function Error at xsl:param on line 14 of
> file:/C:/Documents%20and%20Settings/cbourne/My%
> 20Documents/PGPJava/saxon8/../pgp.xslt:
>   XTSE0010: xsl:param must be the first element within a
> template or function Error at xsl:param on line 15 of
> file:/C:/Documents%20and%20Settings/cbourne/My%
> 20Documents/PGPJava/saxon8/../pgp.xslt:
>   XTSE0010: xsl:param must be the first element within a
> template or function Failed to compile stylesheet. 5 errors detected.

Current Thread