マイ変換コードスニペットは以下の通りです:サクソン固有のTransformerクラスはありますか?
私はjavax.xml.transform.Transformer
クラスを使用しています
EnterpriseConfiguration config = new EnterpriseConfiguration();
StreamResult xmlOutput = new StreamResult(new StringWriter());
Source xmlInput = new StreamSource(new StringReader(sourceMsg));
EnterpriseTransformerFactory factory = new EnterpriseTransformerFactory();
Transformer transformer = factory.newTransformer(new StreamSource(new File(xsltPath)));
System.out.println("config.isLicenseFound() " + config.isLicenseFound());
transformer.transform(xmlInput,xmlOutput);
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
System.out.println("OUTPUT :::-> " + xmlOutput.getWriter().toString());
、私が知りたいのですサクソンに固有の任意のtranformerはありますか?はいの場合は、私に何かを提案することができます、事前に感謝します。ここで
は私が機能を実現しようとしているコードです:私は取得しています
static HashMap<String, String> mapValues = new HashMap<String, String>();
public static HashMap<String, String> getMapValues() {
return mapValues;
}
public static void setMapValues(HashMap<String, String> mapValues) {
DecomposeXsl.mapValues = mapValues;
}
public String transformXsl() throws IOException, SaxonApiException
{
mapValues.put("John", "Jbl");
processor = new Processor(false);
xsltCompiler = processor.newXsltCompiler();
XPathCompiler xpathCompiler = new Processor(false).newXPathCompiler();
String pageFragment = null;
StreamSource xslStreamSource = new StreamSource(new File(xsltPath));
XsltExecutable xsltExecutable = xsltCompiler.compile(xslStreamSource);
xsltExecutable = xsltCompiler.compile(xslStreamSource);
pageXmlTransformer = xsltExecutable.load();
XsltTransformer transformer = null;
transformer = pageXmlTransformer;
String inputStr = null;
//StringReader inputStrReader = new StringReader(inputStr);
StreamSource xmlDoc = new StreamSource(new File(sourcePath));
Serializer serializer = new Serializer();
serializer.setOutputWriter(new StringWriter());
serializer.setOutputProperty(Serializer.Property.SAXON_STYLESHEET_VERSION, "2.0");
serializer.setOutputProperty(Serializer.Property.METHOD, "xml");
serializer.setOutputProperty(Serializer.Property.MEDIA_TYPE, "text/html");
serializer.setOutputProperty(Serializer.Property.INDENT, "no");
serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
serializer.setOutputProperty(Serializer.Property.ENCODING, "utf-8");
transformer.setSource(xmlDoc);
transformer.setDestination(serializer);
transformer.transform();
pageFragment = serializer.getOutputDestination().toString();
System.out.println("pageFragment "+pageFragment);
return pageFragment;
}
例外は次のとおりです。ここで
XTDE1425: Cannot find a matching 2-argument function named {java:java.util.Map}get().
Reflexive calls to Java methods are not available under Saxon-HE
in built-in template rule
net.sf.saxon.s9api.SaxonApiException: Cannot find a matching 2-argument function named {java:java.util.Map}get(). Reflexive calls to Java methods are not available under Saxon-HE
は私のXSLコードです:
<xsl:param name="valMap" as="java:java.util.Map" required="no" select="controller:getMapValues()"/>
<newTag><xsl:value-of select="map:get($valMap, 'John')"/></newTag>
まずはお手伝いをしていただきありがとうございます。私は上記の提案を修正しましたが、私はまだ私の質問で開いていますが、実際にはTransformerのようなJava変換インターフェースを使用したくありません。代わりに私たちのようなサクソン特有のものはXSLTTransformerを持っています。 –
私はそれを使用しようとしている実際の目的は、xsltでJavaメソッドを呼び出すことです、私が直面している問題は、XSLTTransformerでこれを行うときはいつでも、私はexecptionの下になっています: –
名前が一致する2引数の関数{java:java.util.Map} get()。 Javaメソッドへの再帰呼び出しはSaxon-HEの下では利用できません –