Xsl:output
Does the current version of the XSLT processor support the html
method for <xsl:output> tag?
I tried using it but it just uses the toString() method of the
document...so I guess the answer will be "not yet"
Gj
null
Grant Jennings (guest) wrote:
: Does the current version of the XSLT processor support the
html
: method for <xsl:output> tag?
: I tried using it but it just uses the toString() method of the
: document...so I guess the answer will be "not yet"
: Gj
Not yet.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null
Similar Messages
-
XSL-1047: (Error) Invalid instantiation of 'xsl:output' in 'INSERT' context
Following is my development environment:
JDeveloper 9i Release Candidate
JDeveloper JVM 1.3.1
Oracle XML Parser v2 9.2.0.0.0
I'm using the Oracle XML Parser V2 9.2.0.0.0 library to apply a stylesheet to an XML document. However when I invoke the call to processor.processXSL() an XSLException is thrown with the following details:
oracle.xml.parser.v2.XSLException: <Line 1, Column 116>: XSL-1047: (Error) Invalid instantiation of 'xsl:output' in 'INSERT' context.
exception
Below is the sequence of events:
// Create an instance of XSLProcessor to perform the transformation
XSLProcessor processor = new XSLProcessor();
// create a Reader from a String object that contains the stylesheet text
StringReader r = new StringReader( stylesheet );
// create a new XSL stylesheet, passing it the Reader object reference
XSLStylesheet sheet = processor.newXSLStylesheet(r);
// apply the stylesheet
// the variable sheet represents the XSLStylesheet object
// the variable source represents the XMLDocument object
// this call throws the exception
DocumentFragment df =
processor.processXSL(sheet,source);
I've included the Stylesheet and source XML file I'm processing below.
Note: My application works fine when I use the Oracle XML Parser v2 9.0.1 library. (although I have to use new XSLStylesheet() in place of XSLProcessor.newXSLStylesheet())
Any ideas on what has changed between the two releases? I do have a reproducible test case that I can send on if required?
thanks in advance
private String stylesheet =
"<INSERT xsl:version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"> "+
"<xsl:output method=\"xml\" indent=\"yes\"/> "+
"<ROWSET table_name=\"acc_database\"> "+
" <xsl:for-each select=\"DATABASES/DATABASE\"> "+
" <ROW> "+
" <DBID><xsl:value-of select=\"DBID\"/></DBID> "+
" <DBNAME><xsl:value-of select=\"DBNAME\"/></DBNAME> "+
" <DBSIZE><xsl:value-of select=\"DBSIZE\"/></DBSIZE> "+
" <DBPATHNAME><xsl:value-of select=\"DBPATHNAME\"/></DBPATHNAME> "+
" <DBUSER><xsl:value-of select=\"DBUSER\"/></DBUSER> "+
" <DBPASSWORD><xsl:value-of select=\"DBPASSWORD\"/></DBPASSWORD> "+
" <ISAPPDB><xsl:value-of select=\"ISAPPDB\"/></ISAPPDB> "+
" <ISATTACHEDDB><xsl:value-of select=\"ISATTACHEDDB\"/></ISATTACHEDDB> "+
" <CONVERTDB><xsl:value-of select=\"CONVERTDB\"/></CONVERTDB> "+
" <VERSION><xsl:value-of select=\"VERSION\"/></VERSION> "+
" </ROW> "+
" </xsl:for-each> "+
"</ROWSET> "+
"</INSERT>";
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- this file was generated by the Oracle Migration Workbench Exporter for MS Access 9.2.0.1.0 on 13/02/02 15:16:52 -->
<!-- Do not modify this file as any modification will invalidate the export and subsequent migration of your MS Access database -->
<DATABASES>
<DATABASE>
<DBID>1</DBID>
<DBNAME>xmltest</DBNAME>
<DBSIZE>1</DBSIZE>
<DBPATHNAME>E:\xmltest.mdb</DBPATHNAME>
<DBUSER>xmltest</DBUSER>
<DBPASSWORD>oracle</DBPASSWORD>
<ISAPPDB>1</ISAPPDB>
<ISATTACHEDDB>0</ISATTACHEDDB>
<CONVERTDB>1</CONVERTDB>
<VERSION>4.0</VERSION>
<TABLES>
<TABLE PRIMARY_KEY="1">
<TBLID>1</TBLID>
<DBID>1</DBID>
<TBLNAME>xsu_test</TBLNAME>
<CNVTABLESTRUCT>1</CNVTABLESTRUCT>
<CNVMOVEDATA>1</CNVMOVEDATA>
<CNVRI>1</CNVRI>
<CNVVALIDATION>1</CNVVALIDATION>
<CNVDEFAULT>1</CNVDEFAULT>
<CNVADDTIMESTAMP>1</CNVADDTIMESTAMP>
<ATTACHTABLEBACKTOACCESS>1</ATTACHTABLEBACKTOACCESS>
<SAVEPASSWORD>0</SAVEPASSWORD>
<CNVMAKEUPDATEABLE>1</CNVMAKEUPDATEABLE>
<RETAINLOCALCOPY>0</RETAINLOCALCOPY>
<SYNCWITHSERVER>1</SYNCWITHSERVER>
<OWNERID>1</OWNERID>
<VALIDATIONTEXT></VALIDATIONTEXT>
<VALIDATIONRULE></VALIDATIONRULE>
<NUMBEROFROWS>1</NUMBEROFROWS>
<CACHINGTABLE>0</CACHINGTABLE>
<DESCRIPTION></DESCRIPTION>
<COLUMNS>
<COLUMN>
<COLID>1</COLID>
<TBLID>1</TBLID>
<COLNAME>id</COLNAME>
<COLTYPE>4</COLTYPE>
<COLTYPEDESC>Long</COLTYPEDESC>
<COLAUTOINCR>1</COLAUTOINCR>
<NEXTCOUNTERVALUE>0</NEXTCOUNTERVALUE>
<MAXLENGTHSOURCE>0</MAXLENGTHSOURCE>
<AVGLENGTHSOURCE>0</AVGLENGTHSOURCE>
<COLTEXTSIZE>4</COLTEXTSIZE>
<ALLOWZEROLENGTH>0</ALLOWZEROLENGTH>
<DEFAULTVALUE></DEFAULTVALUE>
<COLREQUIRED>1</COLREQUIRED>
<COLCOLLATINGORDER>1033</COLCOLLATINGORDER>
<COLORDPOSITION>1</COLORDPOSITION>
<VALIDATIONRULE></VALIDATIONRULE>
<VALIDATIONTEXT></VALIDATIONTEXT>
<COLUMNDESCRIPTION></COLUMNDESCRIPTION>
</COLUMN>
<COLUMN>
<COLID>2</COLID>
<TBLID>1</TBLID>
<COLNAME>name</COLNAME>
<COLTYPE>10</COLTYPE>
<COLTYPEDESC>Text</COLTYPEDESC>
<COLAUTOINCR>0</COLAUTOINCR>
<NEXTCOUNTERVALUE>0</NEXTCOUNTERVALUE>
<MAXLENGTHSOURCE>0</MAXLENGTHSOURCE>
<AVGLENGTHSOURCE>0</AVGLENGTHSOURCE>
<COLTEXTSIZE>50</COLTEXTSIZE>
<ALLOWZEROLENGTH>0</ALLOWZEROLENGTH>
<DEFAULTVALUE></DEFAULTVALUE>
<COLREQUIRED>1</COLREQUIRED>
<COLCOLLATINGORDER>1033</COLCOLLATINGORDER>
<COLORDPOSITION>2</COLORDPOSITION>
<VALIDATIONRULE></VALIDATIONRULE>
<VALIDATIONTEXT></VALIDATIONTEXT>
<COLUMNDESCRIPTION></COLUMNDESCRIPTION>
</COLUMN>
</COLUMNS>
<INDEXES>
<INDEX>
<INDID>1</INDID>
<TBLID>1</TBLID>
<DBID>1</DBID>
<INDNAME>id</INDNAME>
<CNVINDEX>1</CNVINDEX>
<ISPRIMARY>0</ISPRIMARY>
<ISUNIQUE>0</ISUNIQUE>
<ISFOREIGN>0</ISFOREIGN>
<IGNORENULLS>0</IGNORENULLS>
<ISREQUIRED>0</ISREQUIRED>
<INDEX_COLUMNS>
<INDEX_COLUMN>
<INDCOLID>1</INDCOLID>
<INDID>1</INDID>
<COLID>1</COLID>
<COLORDER>1</COLORDER>
</INDEX_COLUMN>
</INDEX_COLUMNS>
</INDEX>
<INDEX>
<INDID>2</INDID>
<TBLID>1</TBLID>
<DBID>1</DBID>
<INDNAME>PK_xsu_test</INDNAME>
<CNVINDEX>1</CNVINDEX>
<ISPRIMARY>1</ISPRIMARY>
<ISUNIQUE>1</ISUNIQUE>
<ISFOREIGN>0</ISFOREIGN>
<IGNORENULLS>0</IGNORENULLS>
<ISREQUIRED>1</ISREQUIRED>
<INDEX_COLUMNS>
<INDEX_COLUMN>
<INDCOLID>2</INDCOLID>
<INDID>2</INDID>
<COLID>1</COLID>
<COLORDER>1</COLORDER>
</INDEX_COLUMN>
</INDEX_COLUMNS>
</INDEX>
</INDEXES>
</TABLE>
</TABLES>
<RELATIONS>
</RELATIONS>
</DATABASE>
<ATTACHED_TABLES>
</ATTACHED_TABLES>
</DATABASES>Your problem is that your stylesheet is illegal.
You're using the "simple form" of the stylesheet which
is equivalent to having a single root template.
If you use the simple form, you cannot use: <xsl:include>,
<xsl:import>, <xsl:output>, <xsl:param>
or any other <xsl:XXX> element which must be at the "top-level"
of the stylesheet.
The solution is to change from:
<INPUT xsl:version="1.0" xmlns:xsl="...">
<xsl:output>
</INPUT>.
which is illegal to:
<xsl:stylesheet version="1.0" xmlns:xsl="...">
<xsl:output>
<xsl:template match="/">
<INPUT>
</INPUT>
</xsl:template>
</xsl:stylesheet> -
Xsl:output function fully implemented in XSL-processor?
I'm using XSL-processor as contained in the XML-parser version 2.0.2 in C.
When changing the referring DTD of an incoming XML-message with following XSL-stylesheet
<xsl:output method="xml"/>
<xsl:output ommit-xml-declaration="no"/>
<xsl:output standalone="no"/>
<xsl:output doctype-system="someOther.dtd"/>
nothing seems to happen.
Is <xsl:output> already fully implemented in this C-version of the XSL-processor?
ErwinHi,
The xsl:output is not yet implemented. This was specified in the README file.
Thanks,
Oracle XML Team
null -
Xsl output placing %20 (spaces) in output
Xsl output placing %20 (spaces) in output when XSL file is
save by Dreamweaver CS3, I notice a problem in Dreamweaver CS3
today, when editing XSL files. Here is the xsl code
Note: I have no problems when using DW 8 for writing my xsl
style sheets. I suspect a setting in DW CS3 would fix this. My
current development environment is all hand coded, not using DW
server behaviors for any thing. Using MSXML2.DomDocument.4.0 for a
XML Parser.
Top part of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output omit-xml-declaration="yes"/>
Works good this way (all the code on one line)
<xsl:value-of disable-output-escaping="yes"
select="url"/>?n=<xsl:value-of disable-output-escaping="yes"
select="navigationid"/>&p=<xsl:value-of
disable-output-escaping="yes" select="parentid"/>
I decided to make the code readable by placing the xsl calls
on separate lines using line return on the keyboard.
<xsl:value-of disable-output-escaping="yes"
select="url"/>?n=
<xsl:value-of disable-output-escaping="yes"
select="navigationid"/>&p=
<xsl:value-of disable-output-escaping="yes"
select="parentid"/>
The code above resulted in my query string having
%20%20%20%20%20 between the n= and value or p and value. It looks
like the DW CS3 is placing some character in the file that XSL
parser is interpreting as spaces (%20)
Note: Dreamweaver 8 does not have this problem. is there a
setting in CS3 to fix this, maybe a bug in DW CS3?
David PearsonHi,
The xsl:output is not yet implemented. This was specified in the README file.
Thanks,
Oracle XML Team
null -
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! -
Xml-declaration="yes" in xsl:output
When I have a xml-declaration="yes" in my xsl:output, should I
get <?xml version="1.0" ... ?> in my output? I tried it on
Oracle xmlparser_v2_0_2 sample XSLSample.java and I did not get
the <?xml ...?> line. How do I modify the file so that it
outputs this line if I have xml-declaration="yes"?
Thanks.
Khun Yee
nullKhun Yee Fung (guest) wrote:
: When I have a xml-declaration="yes" in my xsl:output, should I
: get <?xml version="1.0" ... ?> in my output? I tried it on
: Oracle xmlparser_v2_0_2 sample XSLSample.java and I did not
get
: the <?xml ...?> line. How do I modify the file so that it
: outputs this line if I have xml-declaration="yes"?
: Thanks.
: Khun Yee
You should get this per the spec only it has not yet been
implemented. It will be in a future release.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null -
Xsl:output not yet implemented??
Is the xsl:output tag implemented in oracle
xslt?
I've tryed this in an xsl file:
<xsl:output method="xml" encoding="ISO-8859-1" omit-xml-declaration="no" doctype-system="Segnatura.dtd" indent="yes" />
With another xslt processor produces this header:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Segnatura SYSTEM "Segnatura.dtd">
while with xdk the header is empty!!
I'm doing something wrong or not?
Please I really nead help on this topic.
Thanks
mauroWe fully implement <xsl:output>
the most common error is that programmer's accidentally use:
DocumentFragment processXSL(xsl,xml)
instead of the:
void processXSL(xsl,xml,PrintWriter)
Only the latter gives the XSLT processor a chance to control the serialization and implement the <xsl:output> hints. -
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 -
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
-
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> -
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 peterSorry 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! -
Xsl output attributes for cdata-section-elements and doctype-system
I am using an xsl file to transform one xml document to another xml document. I want to use the xsl:output Element to do two things:
1.Generate CDATA sections for the text contained in an xml element,"Description"
2. Add the line "<!DOCTYPE PartInformation SYSTEM "part.dtd">
I am using the following code in the xsl file to do these two things, but it does not seem to be doing anything.
<xsl:output cdata-section-elements="Description" doctype-system="part.dtd"/>
Does anybody have any idea what's happening?
Thanks
KishoreWould you specify the XDK version and supply a simple sample including XML and XSL file?
-
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. -
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.
Maybe you are looking for
-
How to see system files in Finder (e.g. the main mail data file) ?
-
Will the TOC structure get affected if output file structure is changed?
I have used FlashHelp to generate output for a project hence the output folder has a structure, now while deploying on the server if I make changes in the output file/folder structure will this affect the "table of contents" or any other feature. Als
-
firefox has remembered my passwords but when I click on the bookmark it opens gmail as an example but does not fill in my account name. When I fill it in the password is automatically entered.. == This happened == Every time Firefox opened
-
How to make an irrelative person able to see the process flow?
A manager asks his/her secretary to help him/her fill a form,which results that the manager isn't involved in the process.But the manager wants to trace the progress of the process.How should I do?
-
Safari Has been crashing ever since the update to Safari 4
It has gotten to the point where I cannot ignore this any further and I need to fix this. If I log into another user ID, I can load up Safari just fine. Here is my crash report, I would appreciate any help: Date/Time: 2009-08-25 14:57:00.781 -0700 OS