Home » Developer & Programmer » JDeveloper, Java & XML » Problems with XSL processor (in printing special characters)
Problems with XSL processor (in printing special characters) [message #167602] Fri, 14 April 2006 08:05 Go to next message
umasenthil
Messages: 1
Registered: April 2006
Location: Bangalore
Junior Member

Hi Experts,

I have the following PL/SQL Procedure to transform the input data using XSL:

CREATE OR REPLACE PROCEDURE TestProcessXSL IS

myParser dbms_xmlparser.Parser;
indomdoc dbms_xmldom.domdocument;
xsltdomdoc dbms_xmldom.domdocument;
xsl dbms_xslprocessor.stylesheet;
outdomdocf dbms_xmldom.domdocumentfragment;
outnode dbms_xmldom.domnode;
proc dbms_xslprocessor.processor;

xslData CLOB := '<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="text" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="All/RP">
<xsl:text disable-output-escaping="yes"> " </xsl:text>
<xsl:value-of select="Name"/>
<xsl:text disable-output-escaping="yes"> " </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>';


xmlData CLOB := '<?xml version="1.0" encoding="utf-8" ?>
<All>
<RP Sequence="1">
<Name>Standard</Name>
</RP>
</All>';

outBuf VARCHAR2(1000);

BEGIN

-- Get the new xml parser instance
myParser := dbms_xmlparser.newParser;

-- Parse the XML document
dbms_xmlparser.parseClob(myParser, xmlData);

-- Get the XML's DOM document
indomdoc := dbms_xmlparser.getDocument(myParser);

-- Parse the XSL document
dbms_xmlparser.parseClob(myParser, xslData);

-- Get the XSL's DOM document
xsltdomdoc := dbms_xmlparser.getDocument(myParser);

xsl := dbms_xslprocessor.newstylesheet(xsltdomdoc, '');

-- Get the new xsl processor instance
proc := dbms_xslprocessor.newProcessor;

-- Apply stylesheet to DOM document
dbms_xslprocessor.processxsl(proc, xsl, indomdoc, outBuf);
DBMS_OUTPUT.PUT_LINE(outBuf);

EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20100, 'Exception occurred in XSL Processsing Function :'||SQLERRM);

END TestProcessXSL;
/

The execution of the above procedure results:

&quot; Standard &quot;

However, the expectation is to get the " printed in the Output like
" Standard "

Is there anything missing? or this is a known issue in Oracle XSLT?

(The same works as expected with "msxsl")

Thanks (for your valuable time)
Senthil
Re: Problems with XSL processor (in printing special characters) [message #167659 is a reply to message #167602] Sat, 15 April 2006 01:22 Go to previous message
deviram_dayal
Messages: 1
Registered: April 2006
Location: bangalore
Junior Member
Hi Senthil,

I would re-write your sample in the following way to achieve your expected output.

You could try this to get your expected output. Hope this helps.

CREATE OR REPLACE PROCEDURE TestProcessXSL IS
xslData CLOB := '<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="text" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="All/RP">
<xsl:text disable-output-escaping="yes"> " </xsl:text>
<xsl:value-of select="Name"/>
<xsl:text disable-output-escaping="yes"> " </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>';
xmlData CLOB := '<?xml version="1.0" encoding="utf-8" ?>
<All>
<RP Sequence="1">
<Name>Standard</Name>
</RP>
</All>';
outBuf VARCHAR2(1000);
xmlData1 XMLType;
xslData1 XMLType;
xmlData2 XMLType;
BEGIN
xmlData1:= XMLType.createXML (xmlData);
xslData1:= XMLType.createXML (xslData);
xmlData2:= XmlData1.transform(xslData1);
select extractvalue(XmlData2,'/') into outBuf from dual;
DBMS_OUTPUT.PUT_LINE(outBuf);
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20100, 'Exception occurred in XSL Processsing Function :'||SQLERRM);
END TestProcessXSL;
/


Pl let me know if you have any issues with this code

-Devi Ram Dayal
Previous Topic: Oracle JDBC??
Next Topic: palette inactive
Goto Forum:
  


Current Time: Fri Nov 22 05:18:13 CST 2024