Subject: RE: [xsl] Accessing External Java Library From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 1 Nov 2007 15:48:58 -0000 |
> java -jar saxon8.jar Well, the first thing on my list of possible causes was that the class isn't on the classpath, and I also mentioned that a common cause of that is running with the -jar option which means there isn't a classpath. You need to use "java -cp ..... net.sf.saxon.Transform ... Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Carl Bourne [mailto:cbourne@xxxxxxxxxxxxxxx] > Sent: 01 November 2007 14:44 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: RE: [xsl] Accessing External Java Library > > OK - This is what I have now! > > From the output I can see that the iPGP.iPGP class could not > be loaded bit don't understand why!!! > > The iPGP.jar file is in the same directory as the saxon8.jar > and the xml, xslt files. > > 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>java > -jar saxon8.jar -TJ pgp.xml pgp.xslt Loading iPGP.iPGP No > Java class iPGP.iPGP could be loaded Error at xsl:value-of on > line 11 of file:/C:/Documents%20and%20Settings/cbourne/ > My%20Documents/PGPJava/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 > No Java class iPGP.iPGP could be loaded > Error at xsl:variable on line 18 of > file:/C:/Documents%20and%20Settings/cbourne/ > My%20Documents/PGPJava/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/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/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/pgp.xslt: > XTSE0010: xsl:param must be the first element within a > template or function Failed to compile stylesheet. 5 errors detected. > > > > > Carl Bourne > Intellect > DDI: +44 1491 842502 > M: +44 7770 284294 > > > > > > -----Original Message----- > From: Michael Kay [mailto:mike@xxxxxxxxxxxx] > Sent: 01 November 2007 12:59 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: RE: [xsl] Accessing External Java Library > > > > > Before calling the external Java library I need to set some > > attributes, e.g. > > > > pgp.setArmor(true) > > pgp.setConventional(true) > > pgp.setInputIsText(true) > > pgp.setOutputIsText(true) > > > > Is it possible to do this within the style sheet? > > Yes, if you're careful. The problem is that these methods > don't generate any output, so there's a risk that they can > get optimized away (or called in the wrong order). The trick > is to use them as if they were returning something, and that > something were written to your result tree, for example > > <out> > <xsl:value-of select="PGP:setArmor(true()), > PGP:setConventional(true()), > PGP: ...etc"/> > > > > Also the XSLT programmers reverence seems to imply that only static > > types are supported - is this the case? > > > No. The behaviour of extension functions varies from product > to product and release to release. The documentation for > Saxon 8.9 is at > > http://www.saxonica.com/documentation/extensibility/functions.html > > Michael Kay > http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Accessing External Java L, Carl Bourne | Thread | RE: [xsl] Accessing External Java L, Carl Bourne |
RE: [xsl] Accessing External Java L, Carl Bourne | Date | RE: [xsl] Accessing External Java L, Michael Kay |
Month |