Running on 11gR1...
Trying to run an xslt to output html... and the transformation strips out the space between my 2 elements...(space between John and Smith is removed)
SELECT XMLSERIALIZE (
CONTENT XMLTRANSFORM (
xmltype (
'<data><column name = "USER_FNAME">John</column><column name = "USER_LNAME">Smith</column></data>'),
xmltype (
'<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<p>
Hello <xsl:value-of select="/data/column[@name=''USER_FNAME'']"/> <xsl:value-of select="/data/column[@name=''USER_LNAME'']"/></p>
</body></html>
</xsl:template>
</xsl:stylesheet>')) AS CLOB)
FROM DUAL;
Outputs:
<html><body><p>
Hello JohnSmith</p></body></html>
From what I have read, this is the standard behaviour... the only thing I could do to get this to work was to add an xsl:text with xml:space="preserve"
SELECT XMLSERIALIZE (
CONTENT XMLTRANSFORM (
xmltype (
'<data><column name = "USER_FNAME">John</column><column name = "USER_LNAME">Smith</column></data>'),
xmltype (
'<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<p>
Hello <xsl:value-of select="/data/column[@name=''USER_FNAME'']"/><xsl:text xml:space="preserve"> </xsl:text><xsl:value-of select="/data/column[@name=''USER_LNAME'']"/></p>
</body></html>
</xsl:template>
</xsl:stylesheet>')) AS CLOB)
FROM DUAL;
Part of the issue is I'm also generating the xslt from user-inputted template... user enters simple templating code, I run it through various regexes to generate an xslt.. then run the xslt on xml data.
Example:
<p>Hello {{USER_FNAME}} {{USER_LNAME}}</p>
That snippet is entered by a user, and turned into the xslt listed above... It seems having to replace all whitespace with empty xsl:text elements a bit problematic...Wondering if there is a more elegant solution?
Thanks for the help and advice!