Xmltype.transform and xsl:output method="html"
hi, 9.2.0.4 winxp,
i wonder whether xmltype.transform regards any output instructions in the stylesheet. i requested any of xml, html and text and always got the same result?
any ideas or hints to more info?
regards peter
Sorry for jumping in on this thread, but I have a question regarding you reply. I have an XSL stylesheet that preforms XML to HTML conversion. Everything works correctly with the exception of those HTML tags that are not weel formed. Using your example if I have something like:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<input type="text" name="{NAME}" size="{DISPLAY_LENGTH}" maxlength="{LENGTH}"></input>
</xsl:stylesheet>
It would render HTML in the format of
<HTML>
<input type="text" name="in1" size="10" maxlength="20"/>
</HTML>
While IE can handle this Netscape can not. Is there anyway to generate completely cross browser complient HTML with XSL?
Thanks!
Similar Messages
-
REPLY to xsl:output method="html" posting
Due to a problem with the discussion software, I cannot reply to postings
with a less-than sign in the Subject!
As you can imagine in an XML forum where
angle-brackets are common, this is a real
pain! The OTN guys tell me they are
working on a solution.
We fully support all options of <xsl utput>
The problem here is that your XSL Stylesheet must be a well-formed XML document, so everywhere you are using the <BR> element, you need to use
instead.
<xsl utput method="html"/> requests
that when the XSLT Engine writes out
the result of your transformation,
is a propert HTML document.
what the XSLT engine reads in must
be well-formed XML.Sorry for jumping in on this thread, but I have a question regarding you reply. I have an XSL stylesheet that preforms XML to HTML conversion. Everything works correctly with the exception of those HTML tags that are not weel formed. Using your example if I have something like:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<input type="text" name="{NAME}" size="{DISPLAY_LENGTH}" maxlength="{LENGTH}"></input>
</xsl:stylesheet>
It would render HTML in the format of
<HTML>
<input type="text" name="in1" size="10" maxlength="20"/>
</HTML>
While IE can handle this Netscape can not. Is there anyway to generate completely cross browser complient HTML with XSL?
Thanks! -
xsl:output method="html"/ - supported?
Is the otutput method "html" supported in
the recent version of the XML/XSL parser?
I was trying to use the <BR> tag with the
<xsl utput method="xml"/> declaration but
I got an XSLException error message
indicating a not well-formed XML document.
Then I tried the following output method
declaration: <xsl utput method="html"/>
but I got the same result?!
Here's a simple XSL stylesheet I was using:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl utput method="html"/>
<xsl:template match="/">
<HTML>
<HEAD></HEAD>
<BODY>
<P>
Blah blah<BR>
More blah blah<BR>
</P>
</BODY>
</HTML>
</xsl:template>
My question is: "How do I use a not
well-formed tags (like <IMG>, <BR>, etc.)
in a XSL stylesheet?"
Thank you very much in advance!
Cheers.
GeorgiSorry for jumping in on this thread, but I have a question regarding you reply. I have an XSL stylesheet that preforms XML to HTML conversion. Everything works correctly with the exception of those HTML tags that are not weel formed. Using your example if I have something like:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<input type="text" name="{NAME}" size="{DISPLAY_LENGTH}" maxlength="{LENGTH}"></input>
</xsl:stylesheet>
It would render HTML in the format of
<HTML>
<input type="text" name="in1" size="10" maxlength="20"/>
</HTML>
While IE can handle this Netscape can not. Is there anyway to generate completely cross browser complient HTML with XSL?
Thanks! -
XSLProcessor support of xsl:output method="text"?
I'm having trouble getting my processor to format the output as a big string. Actually, the output is html, but because of some browser bugs I want to avoid linebreaks between tags. Specifically table cell tags <td> and the content of the cell.
Right now, even though I write my xsl like this:
<table><tr><td>content</td></tr></table>
the processor formats the output like this:
<table>
<tr>
<td>content</td>
</tr>
</table>
Is there any way to avoid these line breaks and indentation?
When I add the lines
<xsl:output method="text"/>
<xsl:output indent="no"/>
to my xsl document, nothing happens.
Thanks in advance.
nullOh. One more thing. I tried parsing that very simple xml file using the xsl sheet you suggested with the class XSLSample that downloads with the parser. Same problem. Any ideas?
xml file:
<root>
<foo>test text</foo>
</root>
xsl file:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="no"/>
<xsl:template match="/">
<html>
<body>
<table>
<tr>
<td><xsl:value-of select="foo"/></td>
<td><xsl:text>SomeText</xsl:text></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
output:
<root>
<html>
<body>
<table>
<tr>
<td/>
<td>SomeText</td>
</tr>
</table>
</body>
</html>
</root>
null -
Escaping characters with -- output method="html" --
Hi all,
I am finding trouble with the
<xsl:output method="html"/>
comand.
I am passing a variable to an XSL which contains the session ID of my application. This session ID contains '%'s, and the XSL parser is escaping those characters to '%25' if I set the above command as said.
<xsl:stylesheet...>
<xsl:param name="paramX">#</xsl:param>
</xsl:stylesheet>
Using <xsl:output method="xml"/> is not an option.
Is there any way to tell the parser not to escape a subset of the XSL????
Thanks for your time,
J. ArraiThe XSLT 1.0 specification requires processors to escape the values of URI attributes in HTML output mode.
See section 16.2 of the XSLT 1.0 spec.
"The html output method should escape non-ASCII characters in URI attribute values using the method recommended in Section B.2.1 of the HTML 4.0 Recommendation. -
Problems with the xsl element ---- xsl:output method="xml"/ ----
Hy, my problem is the next, I am trying to read a xml file and transform it in itself but when I do with XSLT, Internet Explorer doesnt show a xml file, just show me the text nodes of the xml file. I have the element <xsl:output method="xml"/>" in the xsl file but I dont Know what Iam doing wrong.
The next code is from the xsl file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:copy-of select="catalog"/>
</xsl:template>
</xsl:stylesheet>
The next code is from the xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Edited with XML Spy v2007 (http://www.altova.com) -->
<?xml-stylesheet type="text/xsl" href="PlantillaXSL.xml"?>
<catalog dni="4546545">
<cd numero="2" id="5" color="red">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
The result in internet explorer is:
Bob Dylan USA Columbia 10.90 1985All right. I asked because it's unusual to use the ".xml" extension for an XSL file, so I thought it might be an error. But there's nothing wrong with that.
Next debugging step: is that XSL file actually being used? Insert some debugging code in it so that you can tell. -
XMLTYPE.transform works differently in SQL and PL/SL
Hi, when I use XMLTYPE.transform in SQL, it's working fine - try this:
SELECT XMLTYPE.createXml('<data/>').transform(XMLTYPE.createXml('<?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" version="1.0" encoding="UTF-8" omit-xml-declaration="yes" indent="yes" />
<xsl:template match="/">
<HTML>
<BODY>
<TABLE>
<TR><TD><INPUT readOnly="readOnly" size="19" maxLength="30" type="text" value="test..."/></TD></TR>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>')).getClobVal() FROM DUAL;
But when i tried to do tha same in PL/SQL, i obtain error - try this:
DECLARE
lClob CLOB;
lXsl XMLTYPE;
lXml XMLTYPE;
BEGIN
lXml := XMLTYPE.createXml('<data/>');
lXsl := XMLTYPE.createXml('<?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" version="1.0" encoding="UTF-8" omit-xml-declaration="yes" indent="yes" />
<xsl:template match="/">
<HTML>
<BODY>
<TABLE>
<TR><TD><INPUT readOnly="readOnly" size="19" maxLength="30" type="text" value="test..."/></TD></TR>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>');
lClob := lXml.transform(lXsl).getClobVal();
END;
Error is:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00210: expected '=' instead of '>'
Error at line 7
ORA-06512: at "SYS.XMLTYPE", line 138
ORA-06512: at line 20
Oracle version is 11.2.0.2.0.
Knows anybody where is the problem?
Thanks, R. KazimirHi,
Actually it does not work for both.
Remove .getClobVal() method and see what happens :
SQL> SELECT XMLTYPE.createXml('<data/>')
2 .transform(XMLTYPE.createXml('<?xml version="1.0" encoding="UTF-8"?>
3 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4 <xsl:output method="html" />
5 <xsl:template match="/">
6 <HTML>
7 <BODY>
8 <TABLE>
9 <TR><TD><INPUT readOnly="readOnly" size="19" maxLength="30" type="text" value="test..."/></TD><
/TR>
10 </TABLE>
11 </BODY>
12 </HTML>
13 </xsl:template>
14 </xsl:stylesheet>'))
15 FROM dual;
ERROR:
ORA-31011: Echec d'analyse XML
ORA-19202: Une erreur s'est produite lors du traitement la fonction XML (
LPX-00210: '=' attendu plutôt que '>'
Error at line 1
)Besides, using getClobVal() in the SQL version produces an invalid output :
<HTML>
<BODY>
<TABLE>
<TR>
<TD>
<INPUT readOnly>
</INPUT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>The readOnly attribute is not well-formed.
Even stranger : change the just the case of the attribute value, e.g. "readOnly" to "readonly", and it works!
I'm not sure what's happening here. Most likely a combination of bugs regarding html output method.
As a workaround, you can use output method "xml" instead. Works in any cases.
On a side note, in your version, getter methods like getClobVal() are deprecated. Oracle now recommends using XMLSerialize function.
The same goes with XSL transformation, where one should use XMLTransform instead of transform() method. -
Escaped ampersand still causes LPX-00242 in xmltype.transform
Running Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
Collecting input from web form, and fetching via SQLX functions to then transform into html and plain text documents. If the "&" is inputted... the SQLX functions does escape it to "&"... but the LPX-00242 error is still raised when sending to xmltype.transform.
A simple test case:
set define off;
declare
l_xsl xmltype;
l_xml xmltype;
begin
l_xsl := xmltype('<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
Hello <xsl:value-of select="//name"/>
</xsl:template>
</xsl:stylesheet>');
l_xml := xmltype('<test><name>Jane&John Doe</name></test>');
dbms_output.put_line(l_xml.transform
(l_xsl
).getclobval ());
end;the above code raises this exception:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00241: entity reference is not well formed
Error at line 3
ORA-06512: at "SYS.XMLTYPE", line 138
ORA-06512: at line 20If I rerun the above block... but change the xml string to <test><name>Jane &amp; John Doe</name></test>
I now get the following exception:
Error at line 2
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00242: invalid use of ampersand ('&') character (use &)
Error at line 3
ORA-06512: at "SYS.XMLTYPE", line 138
ORA-06512: at line 20If I change the xml string to <test><name>Jane &amp;amp; John Doe</name></test>.. no exceptions and displays the following:
Hello Jane &amp; John Doe
any reason why the SQLX function escaping is not sufficient and I need to double-escape it? The working version is not ideal, since I now have to decode the entity reference back to it's character, otherwise the entity reference code is displayed in the content.
Edited by: pl_sequel on Sep 7, 2011 2:12 PMHi tsuji,
Interesting discussion, really, but I fail to see how the way we're generating the XMLType instance in the first place is important for any subsequent transformation.
You said :
That part is well noticed. And that precisely poses problem.and,
[6.2] But the working (at least for this sample) of the latter but not the former using xmltype() precisely pose the problem of either xmltype().transform() implementation contains bug [...]Could you explain again what you think works and what doesn't?
I may be missing something but all these appear to work correctly :
SQL> var xsldoc varchar2(4000)
SQL> begin
2 :xsldoc := '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3 <xsl:output method="text"/>
4 <xsl:template match="/">Hello <xsl:value-of select="//name"/>
5 </xsl:template>
6 </xsl:stylesheet>';
7 end;
8 /
PL/SQL procedure successfully completed
SQL> set define off
SQL> select xmltransform(
2 xmlelement("test", xmlelement("name", 'Jane&John Doe'))
3 , :xsldoc
4 ).getclobval() as result
5 from dual
6 ;
RESULT
Hello Jane&John Doe
SQL> select xmltransform(
2 xmltype('<test><name>Jane&John Doe</name></test>')
3 , :xsldoc
4 ).getclobval() as result
5 from dual
6 ;
RESULT
Hello Jane&John Doe
SQL> select xmltype(
2 '<test><name>Jane&John Doe</name></test>'
3 ).transform(xmltype(:xsldoc)).getclobval() as result
4 from dual
5 ;
RESULT
Hello Jane&John Doe
SQL> select xmlelement("test",
2 xmlelement("name", 'Jane&John Doe')
3 ).transform(xmltype(:xsldoc)).getclobval() as result
4 from dual
5 ;
RESULT
Hello Jane&John Doe
In any case, you know well there is a something fishy going on, one way of looking at it or another.Yes, I agree. For sure, Oracle XSLT processors are not bug-free.
For the case we're looking at now, the essence of the XMLType datatype is probably more to blame than the XSLT processor though.
A little off-topic addendum about the method="html" output :
SQL> select xmltransform(xmlelement("test",
2 xmlelement("name", 'Jane&John Doe')
3 ),'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4 <xsl:output method="html" encoding="iso-8859-15" indent="yes"/>
5 <xsl:template match="/"><html><head/><body><p><xsl:value-of select="//name"/></p></body></html>
6 </xsl:template>
7 </xsl:stylesheet>').getclobval()
8 as result
9 from dual;
RESULT
<html>
<head>
<meta http-equiv="Content-Type" content="text/html" charset="iso-8859-15">
</meta>
</head>
<body>
<p>Jane&John Doe</p>
</body>
</html>
Not perfect but the method seems supported too.
Edited by: odie_63 on 11 sept. 2011 20:43 -
XDK9.2.0.2, pb with JAXP and XSL Processor
Hello,
I'm using XDK 9.2.0.2 and I try to use JAXP.
I have a difference between using the Oracle XSL processor directly and through JAXP.
Through JAXP, the processor don't care about the xsl:outpout encoding attribute !
Why ?
It take care of method, indent, ... but not encoding !
I try to set the property with : transformer.setOutputProperty(OutputKeys.ENCODING, "iso-8859-1");
It works but I don't want to do that this way !
TIA
Didier
sample (from XSLSample2):
/* $Header: XSLSample2.java 07-jan-2002.02:24:56 sasriniv Exp $ */
/* Copyright (c) 2000, 2002, Oracle Corporation. All rights reserved. */
* DESCRIPTION
* This file gives a simple example of how to use the XSL processing
* capabilities of the Oracle XML Parser V2.0. An input XML document is
* transformed using a given input stylesheet
* This Sample streams the result of XSL transfromations directly to
* a stream, hence can support xsl:output features.
import java.net.URL;
import oracle.xml.parser.v2.DOMParser;
import oracle.xml.parser.v2.XMLDocument;
import oracle.xml.parser.v2.XMLDocumentFragment;
import oracle.xml.parser.v2.XSLStylesheet;
import oracle.xml.parser.v2.XSLProcessor;
// Import JAXP
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
public class XSLSample2
* Transforms an xml document using a stylesheet
* @param args input xml and xml documents
public static void main (String args[]) throws Exception
DOMParser parser;
XMLDocument xml, xsldoc, out;
URL xslURL;
URL xmlURL;
try
if (args.length != 2)
// Must pass in the names of the XSL and XML files
System.err.println("Usage: java XSLSample2 xslfile xmlfile");
System.exit(1);
// Parse xsl and xml documents
parser = new DOMParser();
parser.setPreserveWhitespace(true);
// parser input XSL file
xslURL = DemoUtil.createURL(args[0]);
parser.parse(xslURL);
xsldoc = parser.getDocument();
// parser input XML file
xmlURL = DemoUtil.createURL(args[1]);
parser.parse(xmlURL);
xml = parser.getDocument();
// instantiate a stylesheet
XSLProcessor processor = new XSLProcessor();
processor.setBaseURL(xslURL);
XSLStylesheet xsl = processor.newXSLStylesheet(xsldoc);
// display any warnings that may occur
processor.showWarnings(true);
processor.setErrorStream(System.err);
// Process XSL
processor.processXSL(xsl, xml, System.out);
// With JAXP
System.out.println("");
System.out.println("With JAXP :");
TransformerFactory tfactory = TransformerFactory.newInstance();
String xslID = xslURL.toString();
Transformer transformer = tfactory.newTransformer(new StreamSource(xslID));
//transformer.setOutputProperty(OutputKeys.ENCODING, "iso-8859-1");
String xmlID = xmlURL.toString();
StreamSource source = new StreamSource(xmlID);
transformer.transform(source, new StreamResult(System.out));
catch (Exception e)
e.printStackTrace();
My XML file :
<?xml version="1.0" encoding="ISO-8859-1"?>
<ListePatients>
<Patient>
<Nom>Zeublouse</Nom>
<NomMarital/>
<Prinom>Agathe</Prinom>
</Patient>
<Patient>
<Nom>Stick</Nom>
<NomMarital>Laiboul</NomMarital>
<Prinom>Ella</Prinom>
</Patient>
<Patient>
<Nom>`ihnotvy</Nom>
<NomMarital/>
<Prinom>Jacques</Prinom>
</Patient>
</ListePatients>
my XSL file :
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" omit-xml-declaration="yes" indent="yes" encoding="ISO-8859-1"/>
<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>
<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Liste de patients</TITLE>
</HEAD>
<BODY>
<xsl:apply-templates select='ListePatients'/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match='ListePatients'>
<TABLE>
<xsl:for-each select='Patient'>
<xsl:sort select='Nom' order='ascending' data-type='text'/>
<TR TITLE='`ihnotvy'>
<TD><xsl:value-of select='Nom'/></TD>
<TD><xsl:value-of select='NomMarital'/></TD>
<TD><xsl:value-of select='Prinom'/></TD>
</TR>
</xsl:for-each>
</TABLE>
</xsl:template>
</xsl:stylesheet>
The result :
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>Liste de patients</TITLE>
</HEAD>
<BODY>
<TABLE>
<TR TITLE="`ihnotvy">
<TD>`ihnotvy</TD>
<TD></TD>
<TD>Jacques</TD>
</TR>
<TR TITLE="`ihnotvy">
<TD>Stick</TD>
<TD>Laiboul</TD>
<TD>Ella</TD>
</TR>
<TR TITLE="`ihnotvy">
<TD>Zeublouse</TD>
<TD></TD>
<TD>Agathe</TD>
</TR>
</TABLE>
</BODY>
</HTML>
With JAXP :
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>Liste de patients</TITLE>
</HEAD>
<BODY>
<TABLE>
<TR TITLE="C C)C(C.C/C4C6C9">
<TD>C C)C(C.C/C4C6C9</TD>
<TD></TD>
<TD>Jacques</TD>
</TR>
<TR TITLE="C C)C(C.C/C4C6C9">
<TD>Stick</TD>
<TD>Laiboul</TD>
<TD>Ella</TD>
</TR>
<TR TITLE="C C)C(C.C/C4C6C9">
<TD>Zeublouse</TD>
<TD></TD>
<TD>Agathe</TD>
</TR>
</TABLE>
</BODY>
</HTML>You can also use a PrintWriter to wrap a JspWriter
since PrintWriter has a constructor that takes any
Writer instance.I'm having the same problem, I've spent a lot of time
on it but I can't get it work.
Could you post some working code that shows how you
can do it?
Thanks.
It works now, I have used the code:
result = processor.processXSL(stylesheet, xml);
PrintWriter pw = new PrintWriter(out);
result.print(pw);
I had tried this before but there was an error in other place that prevented it to work.
Thank you anyway. -
Support for "escape-uri-attributes" in xsl:output ???
Does XSLT processor supports
new attribute "escape-uri-attributes" for
xsl:output element?This was tested on 9.2.0.1 Beta (D) XDK for Java
For an example _encXSQL.xsql?param=PŠPHFŽŠĐŽČĆ
returns some garbage in href link, but the valu of the
param is correct shown as text in html.
Here are the code for XSQL page (_encXSQL.xsql)
<?xml version="1.0" encoding="windows-1250"?>
<?xml-stylesheet type="text/xsl" href="_encXSL.xsl" ?>
<page
param = ""
xmlns:xsql="urn:oracle-xsql">
<xsql:include-param name="param"/>
</page>
And the code for XSL (_encXSL.xsl)
<?xml version="1.0" encoding="windows-1250"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl=" "
target="_new">http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" ident="no" encoding="windows-1250"/>
<!-- Root template -->
<xsl:template match="/">
<html>
<head></head>
<body>
<a href="_encTestXSQL.xsql?param={page/param}">
Param:
<xsl:value-of select="page/param"/>
</a>
</body>
</html>
</xsl:template>
</xsl:stylesheet> -
XSLT replace ignores output method
Hi,
i'm using OSB 10gR3 and in my proxy service i'm doing a XSLT replace action.
My XSLT has the following instruction at the beginning:
+<xsl:output method="html" encoding="us-ascii"/>+
which works just fine in every xlst processor except OSB. It seems OSB simply ignores this tag and always processes the output in XML.
Any ideas on how i can force both output method and encoding ?
Thanks.There is a mistake in the statement - The xml I have for transfromation has special characters like "&" inside CDATA sections. In the output sql file (the result of transformation) these special characters are output escaped. They appear as "&".
I am correcting that as below.
The xml I have for transfromation has special characters like "&" inside CDATA sections. In the output sql file (the result of transformation) these special characters are output escaped. They appear as "&". -
Dbms_xslprocessor ignore xsl:output
If I use the xslprocessor.processXsl the output is correct HTML
If I use dbms_xslprocessor.processXsl , in the output will be " replaced with quot; ...
it looks so that dbms_xslprocessor ignore tag <xsl:output method = "html"/>, or should I set output by other way ?
I've last patch 9.2.0.3.0 installed
I'm SunSPARC Solaris (64 bit) running
code fragment :
x_xsl_dom_document := Dbms_Xmldom.newDOMDocument (a_xslt);
x_style_sheet := dbms_xslprocessor.newStylesheet(x_xsl_dom_document, '');
x_processor := dbms_xslprocessor.newProcessor;
dbms_lob.createtemporary(x_tmp_clob, false, dbms_lob.call);
dbms_xslprocessor.processXsl(x_processor, x_style_sheet, a_xml, x_tmp_clob);Please post your question in XMLDB forum
-
Different output XMLTRANSFORM and XMLTYPE.TRANSFORM
Hi,
we upgrade from 10gR2 to 11gR2 and still have problems with XML transformation. Under unknown circumstances the XMLTRANSFORM function
fails with "LPX-00660: Not a well-formed document or external entity" when the count of Page elements is greater then one.
It seems, this bug isnt fixed in 11gR2...
SET SCAN OFF
DECLARE
xml XMLTYPE := XMLTYPE('<?xml version="1.0" encoding="iso-8859-1"?>
<FILE>
<DOCUMENT>
<PAGE>
<b101f>Hello</b101f>
<b101>World</b101>
<f101/>
<REGARDS/>
</PAGE>
</DOCUMENT>
<DOCUMENT>
<PAGE>
<list_layout xpos="10" lsign="+"/>
<le>May</le>
<le>the</le>
<le stil="f">force</le>
<le>be</le>
<le>with</le>
<le>you</le>
<f101/>
<REGARDS/>
</PAGE>
</DOCUMENT>
</FILE>
xsl XMLTYPE := XMLTYPE('<?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="xml" omit-xml-declaration="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="FILE">
<FILE>
<xsl:apply-templates/>
</FILE>
</xsl:template>
<xsl:template match="DOCUMENT">
<DOCUMENT>
<xsl:apply-templates/>
</DOCUMENT>
</xsl:template>
<xsl:template match="PAGE">
<PAGE>
<CONTENT>
<xsl:apply-templates/>
</CONTENT>
</PAGE>
</xsl:template>
<xsl:template match="REGARDS">
<xsl:text disable-output-escaping="yes">&lt;lt;b101&lt;gt;Best regards&lt;lt;/b101&lt;gt;</xsl:text>
</xsl:template>
</xsl:stylesheet>
buf VARCHAR2(32767 CHAR);
BEGIN
DBMS_OUTPUT.PUT_LINE(xml.transform(xsl).getClobVal());
SELECT xmltransform(xml, xsl).getStringVal()
INTO buf
FROM dual;
DBMS_OUTPUT.PUT_LINE(buf);
END;
/Oracle Docu: http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb08tra.htm
XMLType instance can be transformed in the following ways:
Using Oracle SQL function XMLtransform or XMLType method transform() in the database.
Using Oracle XML Developer's Kit transformation options in the middle tier, such as XSLT Processor for Java.
You can alternatively use XMLType method transform() as an alternative to Oracle SQL function XMLtransform. It has the same functionality.
Output:
<FILE>
<DOCUMENT>
<PAGE>
<CONTENT>
<b101f>Hello</b101f>
<b101>World</b101>
<f101/>&lt;lt;b101&lt;gt;Best regards&lt;lt;/b101&lt;gt;</CONTENT>
</PAGE>
</DOCUMENT>
<DOCUMENT>
<PAGE>
<CONTENT>
<list_layout xpos="10" lsign="+"/>
<le>May</le>
<le>the</le>
<le stil="f">force</le>
<le>be</le>
<le>with</le>
<le>you</le>
<f101/>&lt;lt;b101&lt;gt;Best regards&lt;lt;/b101&lt;gt;</CONTENT>
</PAGE>
</DOCUMENT>
</FILE>
<FILE><DOCUMENT><PAGE><CONTENT><b101f>Hello</b101f><b101>World</b101><f101></f101><b101>Best regards</b101></CONTENT></PAGE></DOCUMENT><DOCUMENT><PAGE><CONTENT><list_layout xpos="10" lsign="+"></list_layout><le>May</le><le>the</le><le stil="f">force</le><le>be</le><le>with</le><le>you</le><f101></f101><b101>Best regards</b101></CONTENT></PAGE></DOCUMENT></FILE>Hi,
we upgrade from 10gR2 to 11gR2 and still have problems with XML transformation. Under unknown circumstances the XMLTRANSFORM function
fails with "LPX-00660: Not a well-formed document or external entity" when the count of Page elements is greater then one.
It seems, this bug isnt fixed in 11gR2...
SET SCAN OFF
DECLARE
xml XMLTYPE := XMLTYPE('<?xml version="1.0" encoding="iso-8859-1"?>
<FILE>
<DOCUMENT>
<PAGE>
<b101f>Hello</b101f>
<b101>World</b101>
<f101/>
<REGARDS/>
</PAGE>
</DOCUMENT>
<DOCUMENT>
<PAGE>
<list_layout xpos="10" lsign="+"/>
<le>May</le>
<le>the</le>
<le stil="f">force</le>
<le>be</le>
<le>with</le>
<le>you</le>
<f101/>
<REGARDS/>
</PAGE>
</DOCUMENT>
</FILE>
xsl XMLTYPE := XMLTYPE('<?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="xml" omit-xml-declaration="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="FILE">
<FILE>
<xsl:apply-templates/>
</FILE>
</xsl:template>
<xsl:template match="DOCUMENT">
<DOCUMENT>
<xsl:apply-templates/>
</DOCUMENT>
</xsl:template>
<xsl:template match="PAGE">
<PAGE>
<CONTENT>
<xsl:apply-templates/>
</CONTENT>
</PAGE>
</xsl:template>
<xsl:template match="REGARDS">
<xsl:text disable-output-escaping="yes">&lt;lt;b101&lt;gt;Best regards&lt;lt;/b101&lt;gt;</xsl:text>
</xsl:template>
</xsl:stylesheet>
buf VARCHAR2(32767 CHAR);
BEGIN
DBMS_OUTPUT.PUT_LINE(xml.transform(xsl).getClobVal());
SELECT xmltransform(xml, xsl).getStringVal()
INTO buf
FROM dual;
DBMS_OUTPUT.PUT_LINE(buf);
END;
/Oracle Docu: http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb08tra.htm
XMLType instance can be transformed in the following ways:
Using Oracle SQL function XMLtransform or XMLType method transform() in the database.
Using Oracle XML Developer's Kit transformation options in the middle tier, such as XSLT Processor for Java.
You can alternatively use XMLType method transform() as an alternative to Oracle SQL function XMLtransform. It has the same functionality.
Output:
<FILE>
<DOCUMENT>
<PAGE>
<CONTENT>
<b101f>Hello</b101f>
<b101>World</b101>
<f101/>&lt;lt;b101&lt;gt;Best regards&lt;lt;/b101&lt;gt;</CONTENT>
</PAGE>
</DOCUMENT>
<DOCUMENT>
<PAGE>
<CONTENT>
<list_layout xpos="10" lsign="+"/>
<le>May</le>
<le>the</le>
<le stil="f">force</le>
<le>be</le>
<le>with</le>
<le>you</le>
<f101/>&lt;lt;b101&lt;gt;Best regards&lt;lt;/b101&lt;gt;</CONTENT>
</PAGE>
</DOCUMENT>
</FILE>
<FILE><DOCUMENT><PAGE><CONTENT><b101f>Hello</b101f><b101>World</b101><f101></f101><b101>Best regards</b101></CONTENT></PAGE></DOCUMENT><DOCUMENT><PAGE><CONTENT><list_layout xpos="10" lsign="+"></list_layout><le>May</le><le>the</le><le stil="f">force</le><le>be</le><le>with</le><le>you</le><f101></f101><b101>Best regards</b101></CONTENT></PAGE></DOCUMENT></FILE> -
Xsl:output ignored when doing transformation by XMLReader and XMLFilter
I want to make XML transformation via XSL file using XMLReader and filter as described in java tutorial http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/xslt/5_chain.html, but it is not working correctly. Transformation is not using encoding and method set in xslfile by <xsl:output method="xml" encoding="ISO-8859-2"/>.
I wrote simple test program whitch has two method doing transformation:
transform_method1 - transforms by XMLReader and filter
transform_method2 - transforms in other manner described in the same tutorial
The second method is working, but first not. Maybe someone has some solution why the first method is not working correctly?
Here is test class:
package xslt;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import javax.xml.transform.*;
import javax.xml.transform.sax.*;
import javax.xml.transform.stream.*;
import java.io.*;
public class TestTransform {
public static void main(String[] args) {
File xml_file = new File(args[0]);
File xsl_file = new File(args[1]);
File output_file_method1 = new File(args[2]);
File output_file_method2 = new File(args[3]);
transform_method1(xml_file, xsl_file, output_file_method1);
transform_method2(xml_file, xsl_file, output_file_method2);
private static void transform_method1(File xml, File xsl, File output) {
try {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(xml));
InputSource input = new InputSource(bis);
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser parser = spf.newSAXParser();
XMLReader reader = parser.getXMLReader();
SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory.newInstance();
XMLFilter filter1 = stf.newXMLFilter(new StreamSource(xsl));
filter1.setParent(reader);
StreamResult result = new StreamResult(output);
Transformer transformer = stf.newTransformer();
SAXSource transformSource = new SAXSource(filter1, input);
System.out.println("encoding method1="+transformer.getOutputProperty(OutputKeys.ENCODING));
transformer.transform(transformSource, result);
} catch (Exception e) {
e.printStackTrace();
private static void transform_method2(File xml, File xsl, File output) {
try {
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer( new StreamSource( xsl) );
System.out.println("encoding method2="+transformer.getOutputProperty(OutputKeys.ENCODING));
transformer.transform(new StreamSource(xml), new StreamResult(output));
} catch (Exception e) {
e.printStackTrace();
}and here is test xml file:
<?xml version="1.0" encoding="ISO-8859-2"?>
<root>
<line>Some text line 1</line>
<line>Some text line 2</line>
<line>Some text line 3</line>
</root>the test stylesheet:
<?xml version="1.0" encoding="ISO-8859-2"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="ISO-8859-2"/>
<xsl:template match="root">
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="line">
<div><xsl:apply-templates/></div>
</xsl:template>
</xsl:stylesheet>I get output file from method1:
<?xml version="1.0" encoding="UTF-8"?>
Some text line 1
Some text line 2
Some text line 3and method2 output:
<?xml version="1.0" encoding="ISO-8859-2"?>
<p>
<div>Some text line 1</div>
<div>Some text line 2</div>
<div>Some text line 3</div>
</p>Output on System.out from program is:
encoding method1=UTF-8
encoding method2=ISO-8859-2Can someone help how can I make transformation like transform_method1 style not to ignore <xsl:output method="xml" encoding="ISO-8859-2"/> tag?You have two transformations chained together. The first is the XMLFilter, which uses your XSLT, and the second is the Transformer, which takes its output and does an identity transformation on it. The second transformation is the one that produces your final XML, so it's the one that controls what encoding it gets.
So your stylesheet should be working. Your only "problem" is that you get a different encoding than you expected. And I put "problem" in quotes because the output you are getting is identical, in XML terms, to the output you want to get. -
Uri-escaping in XSLT-Processor when using html-method in xsl:output
I've a problem with the XSLT-Processor:
He tries to escape non-ASCII Characters in the href-Attribute when I use the output method "html". This is correct according to XSLT 1.0 and HTML4, but the processor doesn't really escape the characters, he just gives me a %3F ('?'-character) instead of %HH (where HH corresponds to the hex value of the char).
I searched the forums and found a thread with the same problem, but there was no solution to this issue. The thread was started in 2002 so maybe someone came up with a solution.Add the non-ascii character to <xsl:text disable-output-escaping="yes"></xsl:text>
Maybe you are looking for
-
Hello macintosh family! I would like to ask how can I change the document margins within a different section in the same document?
-
Workflow will not manually start - getting Server Error in '/' Application - Runtime Error
I've tested so far in three site collections and I am not able to manually start a workflow. I am getting the below error Runtime Error Description: An application error occurred on the server. The current custom error settings for this application p
-
Correcting Multiple Schedules on the Same Report
Hi Created a report and scheduled it to run daily at 8am. Works Great. two months later a change is requested I make the change and republish the report, but fail to schedule it for the same time. Now I have the same report with the same name schedul
-
Where is front row in lion?
anyone know where lion moved front row to? did they eliminate it? don't tell me i need to boot up my old laptop for this presentation!
-
Getting Toplink 11.1.1.2.0 to work
I've been trying to get Toplink to work with my PostgreSQL database for a while, but I hit a brick wall and have no idea how to resolve the issue. I have used Toplink Workbench provided with the Toplink installation to create a sessions.xml file and