Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XSL and SQL query : special chars such as ampersand

474972Aug 23 2006 — edited Aug 24 2006
Hello,
I've got this to create canonical XML file :
PROCEDURE CANONICAL_XML_XSL(query IN VARCHAR2,
p_file_path IN VARCHAR2,
p_file_name IN VARCHAR2)
AS
Ctx DBMS_XMLGEN.ctxHandle; -- Var's to convert SQL output to XML
v_xml clob;

xmlc varchar2(4000); -- Var's required to convert lob to varchar
off integer := 1;
len integer := 4000;
v_file Utl_File.File_Type;
v_more BOOLEAN := TRUE;
xsldoc VARCHAR2(4000);
l_Output XMLType;
lXMLData XMLType;
BEGIN
-- to parametize later the XSL file

-- XSL DEFINITION TO TRANSFORM TO A FLAT FILE

xsldoc :='<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="ROWSET/ROW">
<xsl:value-of select="LIGNE"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
';


Ctx := DBMS_XMLGEN.newContext(query);
lXMLData := DBMS_XMLGEN.GETXMLTYPE (Ctx,DBMS_XMLGEN.NONE);
l_Output := lXMLData.transform(XMLType(xsldoc));
clob_to_file(p_file_path,p_file_name,l_Output.getClobVal());
END;

Ok, it works but in the query some value could have &, >, < ... and when the XML is generated I should have $amp; for & etc ...
-> if I use PSLQL function : REPLACE, sqlplus thinks that $amp; is a bind variable !

Does someone have a solution ?

thanks

Romeo
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 21 2006
Added on Aug 23 2006
9 comments
1,255 views