954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to add new line character as separator in XMLTransform

Hi,

As the title states, I have a query that I use to concatenate all the rows into a single string and I use the XMLTransform method to accomplish that but I still need to add a new line separator within the XML string and so far I didn't find any escape character to work. I tried the '\n', CHR(10), ASCII_CHR(10)||ASCII_CHR(13),
...

Here is the code snippet:

SELECT
        XMLTransform(SYS_XMLAgg(SYS_XMLGen(LocationTable.LOCATION)), XMLType('<?xml version="1.0"?><xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:template match="/">
            <xsl:for-each select="/ROWSET/LOCATION">
              <xsl:value-of select="text()"/>
              ---NEW LINE SEPARATOR NEEDED HERE---
            </xsl:for-each>
          </xsl:template>
        </xsl:stylesheet>')).getstringval()
        FROM LocationTable


Regards,
Alin

end3r
Light Poster
37 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

I found the answer:

SELECT
        XMLTransform(SYS_XMLAgg(SYS_XMLGen(LocationTable.LOCATION)), XMLType('<?xml version="1.0"?><xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          <xsl:variable name="new_line" select="''&#xA;''" />
          <xsl:template match="/">
            <xsl:for-each select="/ROWSET/LOCATION">
              <xsl:value-of select="text()"/>
              <xsl:value-of select="$new_line" />
            </xsl:for-each>
          </xsl:template>
        </xsl:stylesheet>')).getstringval()
        FROM LocationTable
end3r
Light Poster
37 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: