I have the following xml element:
<notes>
<isImportant>true</isImportant>
<content><p>Click on the Link below to direct you the page " Java tutorial"</p>
<p> <a title="Java tutorial" target="_blank" href="https://www.javatpoint.com/java-tutorial">https://www.javatpoint.com/java-tutorial</a></p></content>
</notes>
In xslt I need to pass isImportant and content elements content to java method as string.
This is how I am saving those to a variable:
<xsl:variable name="notesIsImportant" select="$inputMetaXml//notes/isImportant"/>
<xsl:variable name="notesContent">
<xsl:copy-of select="$input//notes/content"/>
</xsl:variable>
Within template I am calling java method:
<xsl:value-of select="java:generateNotesJson($customContentInstance,string($notesIsImportant), string($notesContent))"/>
And this is my java class:
public class MetadataHandler {
public String generateNotesJson(String isImportant, String content) {
return String.format("{"IsImportant": "%s", "Content": "%s"}", isImportant, content);
}
}
The problem is that when I pass content of content element it is just passing text nodes. How can I make sure that I pass all element, attribute and text nodes, basically everything inside the content element as it is?
Above implementation for method call is giving me the following result:
Click on the Link below to direct you the page ” Java tutorial” https://www.javatpoint.com/java-tutorial
What I am trying to get:
Click on the Link below to direct you the page ” Java tutorial”
https://www.javatpoint.com/java-tutorial