Indentation issue when converting XML to XSLT
Hi,
I am trying to convert XML document to XSLT, and I don't want the resulting stylesheet to have any indentation. I use <xsl:output indent="no" method="text" /> to supress indentation however the resulting document is still indented. The database version is Oracle 9.2. Do you know any solution to the problem or any way to work around it?
To test the code first create table text_xml and populate it with data.
Then create a function "submissionxml" that applies xsl stylesheet on created column. The result should be another stylesheet and it should not be indented.
create table text_xml (text_xml xmltype);
declare
buffer clob;
v_xml sys.xmltype;
amount integer :=100;
begin
buffer:='<?xml version="1.0" encoding="iso-8859-1"?>
<TEXT>
Thank you for registering as a Speaker for OracleWorld 2002.
Your registration ID is <ATTEND_ID/>
This email is to inform you that your registration has been received and is being processed.
<LINK>BLA-LINK?ATTEND_ID=<ATTEND_ID/></LINK>
</TEXT>';
v_xml:=sys.xmltype.createxml(buffer);
insert into text_xml(text_xml) values (v_xml);
commit;
end;
/
CREATE OR REPLACE function submissionxml return STRING is
v_template xmltype;
v_text xmltype;
v_result xmltype;
begin
v_template:=sys.xmltype.createxml('<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:out="transform.xsl">
<xsl:output indent="no" method="text" />
<xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<out:stylesheet version="1.0">
<out:output method="html" indent="no" />
<out:strip-space elements="*"/>
<out:template match="/ROWSET/ROW/TEXT">
<out:element name="TEXT">
<xsl:apply-templates />
</out:element>
</out:template>
</out:stylesheet>
</xsl:template>
<xsl:template match="ATTEND_ID">
<out:value-of select="ATTEND_ID"/>
</xsl:template>
<xsl:template match="FIRST_NAME">
<out:value-of select="FIRST_NAME"/>
</xsl:template>
<xsl:template match="LAST_NAME">
<out:value-of select="LAST_NAME"/>
</xsl:template>
<xsl:template match="B|I|U|BR|P">
<out:element name="{name()}">
<xsl:apply-templates/>
</out:element>
</xsl:template>
<xsl:template match="LINK">
<xsl:call-template name="htmLink">
</xsl:call-template>
</xsl:template>
<xsl:template name="htmLink">
<out:element name="a">
<out:attribute name="href">
<xsl:apply-templates/>
</out:attribute>
<xsl:apply-templates/>
</out:element>
</xsl:template>
</xsl:stylesheet>');
select xmltransform(text_xml, v_template) into v_result
from text_xml;
return v_result.getSTRINGval();
end;
/