Sunday 15 April 2012

Calling Java Function from XSLT gives "Could not compile stylesheet" -


I have gone to all positions of similar issues, but I can not solve my problem as shown below as XSLT Gone:

XSLT:

  & lt ;? XML version = "1.0" encoding = "ISO-885 9-1"? & Gt; & Lt; Xsl: stylesheet version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" xmlns: proxy = "java: com.hp.gpp.pp.util.UrlUtils" extension- Element-prefix = "proxy" & gt; & Lt; Xsl: output method = "xml" version = "1.0" indent = "yes" /> & Lt; Xsl: Ultimate name = "proxy" /> & Lt; Xsl: variable name = "baseurl" = "/ html / head / base / @ href" /> & Lt ;! - Output to copy input - & gt; & Lt; Xsl: template match = '* | @ * '& Gt; & Lt; XSL: Copy & gt; & Lt; Xsl: apply-select template = 'node () | @ * '/ & Gt; & Lt; / XSL: Copy & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "* [@ href]" & gt; & Lt; XSL: Copy & gt; & Lt; Xsl: attribute name = "href" & gt; & Lt; Xsl: select value = "proxy: rewrite ($ proxy, $ absolute, @ href)" /> & Lt; / Xsl: attribute & gt; & Lt; Xsl: apply-select template = "node () | @ * [name (.)! = 'Href']" /> & Lt; / XSL: Copy & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "* [@ src]" & gt; & Lt; XSL: Copy & gt; & Lt; Xsl: attribute name = "src" & gt; & Lt; Xsl: Select Value = "Proxy: Reconstruction ($ proxy, dollar basal, @ SRC)" /> & Lt; / Xsl: attribute & gt; & Lt; Xsl: apply-select template = "node () | @ * [name (.)! = 'Src']" /> & lt; / XSL: Copy & gt; & Lt; / XSL: Templates & gt; & Lt ;! - rewrite & lt; A href & gt; - & gt; & Lt; Xsl: template match = "base" & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;   

And a Java code is as follows:

  XSLTemplateFactory templateFactory = New DefaultTemplateFactory (); Templates templates = TemplateFinders .getTemplatesFromURL (XSS_FILE_NAME); Source xmlStrim = new streamsource (reader); Results oStream = new stream result (res.getWriter ()); Transformer Transformer = Templates. NEU Transformers (); Transformer. Sitemapator ("Proxy", New Urutils (Reich, Ridge)); Transformer. TransSForm (XMLSTM, Ostream); In any case, the code works locally but gives it when deploying:  
  error: 'non-static java function The first argument for 'rewrite' is not a valid object reference. 'Incorrect error:' stylesheet can not be compiled 'com.hp.gpp.pp.exception.ProxyPortletException: error.transformer: stylesheet could not be compiled   

this problem Is not able to find here. Can anyone help me in this?

Thanks & amp; Richin

You must remove the transformer.setParameter call from your code. And and LT related to your XSLT; Xsl: param name = "proxy" /> directions.

Then put the prefix of names in the Java class, like

     

Then you can write

  & lt; Xsl: attribute name = "href" & gt; & Lt; Xsl: Select value = "Proxy: rewritewritable ($ basural, @ rff)" /> & Lt; / XSL: Specialty & gt;   

I think that rewriteRelative takes only two parameters: the base URL and a relative URL? I'm not sure the previous parameter was for $ proxy , but I think it is not included in it.

No comments:

Post a Comment