StreamResult to a string
Added by Anonymous over 19 years ago
Legacy ID: #3144023 Legacy Poster: Curtis (cdfisher07)
I am trying to return the results of my transform to a string. I am returning a single value from the transformation to the calling function in my Java class, but the StreamResult expects the return to be serialized to the drive or System.out in order to work. How can I return the result to a string which can be used as a variable? I looked all through the thorough JAXP chapter in XSLT 2.0, but can't locate an example. Also, I am aware that XPath may be the way to go if using XSLT to return status or single values like I am doing, but I just want to learn this first, then move on to XPath stuff. Michael, I still can't reach Mulberry to ask any questions about XSLT, and this is really a JAXP and Saxon question, so I hope I have the right forum. Thanks, Curtis Fisher
Replies (2)
RE: StreamResult to a string - Added by Anonymous over 19 years ago
Legacy ID: #3144038 Legacy Poster: Michael Kay (mhkay)
Create a java.io.StringWriter, wrap that in a StreamResult, and when the transformation finishes, extract the string from the StringWriter using its toString() method. Michael Kay
RE: StreamResult to a string - Added by Anonymous over 19 years ago
Legacy ID: #3144298 Legacy Poster: Curtis (cdfisher07)
Thanks Michael, I know you don't need to teach standard Java, and I appreciate your efforts!
Please register to reply