Transform XML using JSTL
Hi. This is what I Have...
D:\testing\stocks.xml - well formed XML file
D:\testing\stocks.xslt - displays the above XML file in a table
D:\testing\view.jsp
This is the code for view.jsp<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<html>
<head>
<title>JSP, XML and XSLT</title>
</head>
<body bgcolor="#FFFFCC">
<h3>Transforming XML into HTML using XSLT</h3>
<c:import url="stocks.xml" var="xmldocument"/>
<c:import url="stocks.xslt" var="xslt"/>
<p>Imported...</p>
<c:out value="${xmldocument}"/>
<c:out value="${xslt}"/>
<p>Transformation...</p>
<x:transform xml="${xmldocument}" xslt="${xslt}"/>
</body>
</html>And this is what I get when I drag view.jsp into my browser window...
Transforming XML into HTML using XSLT
Imported...
Transformation...
I used Altnova XMLSpy and StyleVision to generate the XML and XSLT files, and I know the stylesheet correctly displays a table containing the contents of the XML file.
So why doesn't the JSP import teh XSLT and XML and initiate the transformation?
Sorted it, just put the jsp into an existing web app and linked to it from the controller servlet.
Similar Messages
-
Problem Tranforming xml using jstl
Hello To Every One
I have transformed xml document using servlet now i need to know how can i transform xml document using jstl. I have found this code very often but it doesn't work with a relative or absolute url. I need to pass parameters dynamically.
<c:import var="xml" url="<%=xmlFile%>" />
<c:import var="xslt" url="<%=xsltFile%>" />
<x:transform xml="${xml}" xslt="${xslt}" />In this code I have to pass xmlFile and xsltFile parameter dynamically and i want to make it as session variables. When i put relative url in *<c: import >* tag it works fine but for absolute url it does not work. Although I doesnot want to pass absolute url but relative ones, but how can i achieve that one.
E.G.
<x:transform xml="relative url for xmlfile" xslt="relative url for xslt file" />If anyone have the solution please reply me as soon as possible. Thanx in Advance for your kind Attention.Thanx for your answer This is my Code which works fine.
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
<html>
<head>
</head>
<body>
<form method="post">
<c:import var="xml" url="..\\data\\192.168.1.94\\master.xml" />
<c:import var="xslt" url="..\\other\\Masterview.xsl" />
<x:transform xml="${xml}" xslt="${xslt}" />
</form>
</body>
</html>But in <c:import > tag i want to put url value dynamically so when i convert that string to a variable and pass that variable into url attribute it does not work.
Like This
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
<html>
<head>
</head>
<body>
<%
try{
String xmlFile="..\\data\\"+session.getAttribute("param1").toString()+"\\master.xml";
String xsltFile="..\\other\\"+session.getAttribute("param2").toString()+"\\MasterView.xsl";
}catch(Exception ep){ep.printStackTrace();}
%>
<form method="post">
<c:import var="xml" url="<%=xmlFile.toString()%>" />
<c:import var="xslt" url="<%=xsltFile.toString()%>" />
<x:transform xml="${xml}" xslt="${xslt}" />
</form>
</body>
</html> -
Transform XML using XSL, output XML
Hi all,
I have an xml document and I want to transform it using an xsl file. As a result I want an xml document, it's possible? Anyone could help me?That 's exactly what XSLT does. Learn more about it here: http://www.ibiblio.org/xml/books/bible2/chapters/ch17.html
Good luck. -
Exception When trying to Format XML using JSTL
Hi all
I m trying to display content of XML in a .jsp page using JSTL ,
When i try to dispaly the content it is thowing an exception :
org/saxpath/SAXPathException
Can any one please help ....
i m using jstl1.0.6.jar and standard-1.0.6.jar
Code Snppet Used:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<c:set var="someXML">
<name>Sri</name>
</c:set>
<x:parse var="parsedDocument" xml="${someXML}" />
<x:out select="$parsedDocument/name" />
Thanks in AdvanceThank for reply
I had even tried with this code:
<c:set var="someXML">
<person>
<name>Joe</name>
<age>30</age>
</person>
</c:set>
<x:parse varDom="parsedDocument" xml="${someXML}" />
<x:set var="name" select="$parsedDocument/person/name" />
<c:out value="${name}" />
even then i m getting the same exception:
Message: org/saxpath/SAXPathException -
Transforming XML using XSLT more than once
Hi,
I am trying to transform an XML Document object in Java. However, it requires 2 transforms as each of them is complicated and needs to be generic enough for use by different XML strings. So I have a single XML string and two XSLT files.
Currently, I am using the Java transformer to perform both the transforms one after another. However, I was wondering if there is a function within XSLT or Java that would allow performing the second transform on the result of the first transform without having to resort to multiple calls from within Java.
Thanks a lot.
Jay Badiyanihttp://xml.apache.org/xalan-j/samples.html#usexmlfilters
-
Hello,
I have an OutOfMemoryError when applying an xsl transformation to generate html
code in a web page. I'm running Weblogic 6.1 sp2
I think the problem comes from the objectin which th html is stored during the
transformation. The problem only occurs from a minimal xml size. I could fix
it by increasing JVM allocated size but I would like to find a more flexible solution.
If I know an other way to solve this problem, I really would appreciate !
Thanl you,
Laurent.
[AgentsGeres.jsp]Hello,
You might try asking your question in the JSP newsgroup:
http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=xover&group=weblogic.developer.interest.jsp
There just may not be a more flexible solution :-)
This doc may be of some value, see chapter 2:
http://edocs.bea.com/wls/docs61/pdf/perform.pdf
HTH,
Bruce
Laurent Gosuin wrote:
>
Hello,
I have an OutOfMemoryError when applying an xsl transformation to generate html
code in a web page. I'm running Weblogic 6.1 sp2
I think the problem comes from the objectin which th html is stored during the
transformation. The problem only occurs from a minimal xml size. I could fix
it by increasing JVM allocated size but I would like to find a more flexible solution.
If I know an other way to solve this problem, I really would appreciate !
Thanl you,
Laurent.
Name: AgentsGeres.jsp
AgentsGeres.jsp Type: Hypertext Markup Language (text/html)
Encoding: base64 -
Help Please ! -- transform XML to HTML using xslt tag in JSP
Hello,
I have problem to do XSL transform in JSP.
I have an XSL : test.xsl
I have an XML : test.xml
In JSP I have:
<x:xslt media="html" xml="test.xml">
<x:stylesheet media="html" uri="test.xsl" />
</x:xslt>
But It doesn't work the way it suppose to. What is wrong in my code ? I followed the URL http://e-docs.bea.com/wls/docs81/xml/xml_apps.html
Thanks in advance,
ChristinaBasically:
try{
//Setting up parameters.
xml=new StreamSource(new File(xmlInput));
xsl=new StreamSource(new File(xslInput));
baos=new ByteArrayOutputStream();
htmlResult=new StreamResult(baos);
//Transform input(xml, xsl) onto html output.
TransformerFactory tfactory=TransformerFactory.newInstance();
Transformer transformer=tfactory.newTransformer(xsl);
transformer.transform(xml, htmlResult);
baos.writeTo(out);
//System.err.println(htmlResult.getOutputStream().toString());
catch(...){
}I havent tested and I havent use this for a while, but I hope this can serve as a staring point.
Regards,
OO -
Problem transforming XML/XSL Using Xalan
Hi, I am using the xalan apis to transform XML/XSL in a servlet..My servlet code is like...
response.setContentType("text/html; charset=UTF-8");
// Output goes in the response stream.
PrintWriter out = response.getWriter();
boolean environmentOK = (new org.apache.xalan.xslt.EnvironmentCheck()).checkEnvironment (out);
try
TransformerFactory tFactory = TransformerFactory.newInstance();
// Get the XML input document and the stylesheet.
Source xmlSource = new StreamSource("D:\\DATA\\jrun\\test\\test.xml");
Source xslSource = new StreamSource("D:\\DATA\\jrun\\test\\test.xsl");
// Generate the transformer.
Transformer transformer = tFactory.newTransformer(xslSource);
// Perform the transformation, sending the output to the response.
transformer.transform(xmlSource, new StreamResult(out));
I am getting the error ..
javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Namespace not supported by SAXParserjavax.xml.transform.TransformerConfigurationException
That's why I have added the line..
boolean environmentOK = (new org.apache.xalan.xslt.EnvironmentCheck()).checkEnvironment (out);
But that gives me the following error diagnostic information...
ERROR.version.DOM=ERROR attempting to load DOM level 2 class: java.lang.NoSuchMethodException
I have put all the 3 required classes, xml-apis.jar, xercesImpl.jar and xalan.jar in my application servers classpath..
Please let me know what I am doing wrong..and how this can be fixed.
Thanks
Surajithey Surajit
Your code is unable to create a transformer from a factory instance.
I would check why it is not creating the Transformer.On my win32 system i usee two forward slashes..to identify the file path
D://xyz//abc....instead of D:\\...i wonder if thats one reason why your code is not able to create a transformer based on the StreamSource u create for the file paths.
Code i use..that works
javax.xml.transform.TransformerFactory tFactory =
javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Source xmlSource = new javax.xml.transform.stream.StreamSource (xmlInputSource);
javax.xml.transform.Source xslSource = new javax.xml.transform.stream.StreamSource
(xslInputSource);
// Generate the transformer.
javax.xml.transform.Transformer transformer = tFactory.newTransformer(xslSource);
// Perform the transformation, sending the output to the response.
transformer.transform(xmlSource,new javax.xml.transform.stream.StreamResult(out));
I used jaxp-1.2 with tomcat 4.1.12
Hope that helps. -
How to use JSTL varriable in to XML
1. how to use JSTL varriable into Xml Tag.
for example :
java value I am passing to XML.
<eztag:companytag pgm_sname="<%= strpgm_name%>" dbase="<%= strd%>"
dbpass="<%= strp%>" dburl="<%= stru%>" session="<%= session%>" />
After modified in JSTL
<eztag:companytag pgm_sname="${pgm_name}" dbase="${strd}"
dbpass="${strp}" dburl="${stru}" session="${session}" />
but its Not working. How to use this
2.How to use ArrayLIst in JSTL
For example
IN Java scriplet code in JSP
<%for(int i=0;i<alist.size();i++) {
String str = String.valueOf(alist.get(i));
String str1 = String.valueOf(alist.get(i+1));
%>
<TD>STR - <%=str%> </TD>
<TD>STR1 - <%=str1%> </TD>
<% } %>
This code How to Use in JSTL.
thanks in advancethanks for reply
But in this article it describes how to passing the value of function.
I need how to assign the JSTL varriable to xml tag attribute.
for example
In my TLD File
<tag>
<name>companytag</name>
<tag-class>bas.CompanyTag</tag-class>
<attribute>
<name>dbase</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>dbpass</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>dburl</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>pgm_sname</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>session</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
</tag>
Html code
old code :
<%@ taglib uri="/ezerptags.tld" prefix="eztag" %>
<eztag:companytag pgm_sname="<%= strpgm_name%>" dbase="<%= strd%>"
dbpass="<%= strp%>" dburl="<%= stru%>" session="<%= session%>" />
After modified in JSTL
<%@ taglib uri="/ezerptags.tld" prefix="eztag" %>
<eztag:companytag pgm_sname="${pgm_name}" dbase="${strd}"
dbpass="${strp}" dburl="${stru}" session="${session}" />
but its Not working. How to use this
the "eztag" and "companytag" are the customtag. these tages available in eztaglib.tld file. I am passing the value through XML Tag.
Please suggest me . how to use.
is there any article describes how to pass jstl varriable to XML Tag attribute.
thanks in advance -
String to XML using XSLT..
Hey folks
Am having a XML in a single string in ma request and wanna convert that into a XML. Tried that using XSLT but seems am missing out on some point...It works fine with Stylus but fails within PI
Following code am using :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.sdn.com/xslt">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:for-each select="//*:string">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The name of the element in which i get the whole XML is "string".
My request string is something liek this :
<xml version="1.0" encoding="UTF-8"?><ProductDefinition><RefNo>23232323</RefNo><Description>dfdfdfdfdf</Description></ProductDefinition>
Now am trying to generate a XML using the XSL but its failing in PI...
Kindly point out where am i going wrong?Thanks, but graphical mapping does not expose <![CDATAhttp:// ... ] to be removed. Surely this must be done with XSLT?+
Don't worry about <![CDATA ... pass your whole string in source message like this : <![CDATAhttp://<?xml version=\"1.0\" encoding=\"UTF-8\"?><ProductDefinition><RefNo>12345</RefNo><Description>Test</Description></ProductDefinition>]>
1st the graphical mapping where you use replace string will replace <?xml version=\"1.0\" encoding=\"UTF-8\"?> and then the XSLT mapping would get a input like this : <![CDATAhttp://<ProductDefinition><RefNo>12345</RefNo><Description>Test</Description></ProductDefinition>]> which would eventually form your target structure...
I tried it myself few days back so its a sure shot method ... just try it
Cheers!!!
Soumen -
Unable to transform XML with XSL in java code
Hi,
Could somebody please tell me what's wrong with my code, why it isn't transform the XML with XSL to the output that I want. If I use the command line to transform the XML, it output perfectly:
java org.apache.xalan.xslt.Process -in marc.xml -xsl MARC21slim2MODS.xsl -out out.xml
Here is the code of my program to transform the XML with XSL, I am using xalan-j_2_2-bin:
import java.io.*;
import java.net.*;
import java.util.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.dom.*;
import java.math.BigInteger;
String xslDoc = "MODS.xsl";
String xmlResult = "out.xml";
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
dfactory.setNamespaceAware(true);
DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
Document xmlDoc = docBuilder.newDocument();
Element root = xmlDoc.createElement("collection");
root.setAttribute("xmlns", "http://www.loc.gov/MARC21/slim");
xmlDoc.appendChild(root);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xslDoc));
FileWriter fw = new FileWriter(new File(xmlResult));
StreamResult output = new StreamResult(fw);
transformer.transform(new DOMSource(xmlDoc), output);
fw.flush();
fw.close();
========================
marc.xml -- source XML file
========================
<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="http://www.loc.gov/MARC21/slim"><record><leader>01488cam 2200337 a 4500</leader><controlfield tag="001">2502929</controlfield><controlfield tag="005">19930521155141.9</controlfield><controlfield tag="008">920219s1993 caua j 000 0 eng </controlfield><datafield ind1=" " ind2=" " tag="035"><subfield code="9">(DLC) 92005291</subfield></datafield><datafield ind1=" " ind2=" " tag="906"><subfield code="a">7</subfield><subfield code="b">cbc</subfield><subfield code="c">orignew</subfield><subfield code="d">1</subfield><subfield code="e">ocip</subfield><subfield code="f">19</subfield><subfield code="g">y-gencatlg</subfield></datafield>
</record></collection>
========================
out.xml -- result using command line
========================
<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="http://www.loc.gov/mods/" xmlns:xlink="http://www.w3.org/TR/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/ http://www.loc.gov/standards/marcxml/schema/mods.xsd">
<mods>
<titleInfo>
<title>Arithmetic</title>
</titleInfo>
<name type="personal">
<namePart>Sandburg, Carl</namePart>
<namePart type="date">1878-1967</namePart>
<role>creator</role>
</name>
</mods>
</collection>
========================
out.xml -- result using my java program
========================
<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="http://www.loc.gov/mods/" xmlns:xlink="http://www.w3.org/TR/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/ http://www.loc.gov/standards/marcxml/schema/mods.xsd">01488cam 2200337 a 4500250292919930521155141.9920219s1993 caua j 000 0 eng (DLC) 920052917cbcorignew1ocip19y-gencatlgpc16 to br00 02-19-92; br02 to SCD 02-21-92; fd11 02-24-92 (PS3537.A618 A...); fa00 02-26-92; fa05 03-02-92; fm31 03-06-92; CIP ver. pv08 04-16-93; pv01 to CLT 04-20-93; lb10 05-21-93
</collection>I am using the same XSL file. My Java program use the same XSL file I used in the command line.
It is possible that my Java code is using a different parser, but I developed a seperate program to parse the XML using the same parser that my Java code is using. It output the result I expected. Here is the code for the program:
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class Convertor {
public static void main(String[] args) throws Exception {
String xslDoc = "MARC21slim2MODS.xsl";
String xmlResult = "out.xml";
String xmlDoc = marc.xml";
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xslDoc));
StreamSource xmlSource = new StreamSource(xmlDoc);
FileWriter fw = new FileWriter(new File(xmlResult));
StreamResult output = new StreamResult(fw);
transformer.transform(xmlSource, output);
} -
Problem while parsing xmlString in jsp using JSTL
HI, I am not able to display data in jsp page that I have stored in string variable in XML form.
I want to print xmlString data in jsp using jstl.
probably i might have to parse it but i don't have idea . Can any one help me PLZ??I managed the code but getting following error
org.apache.jasper.JasperException: javax.servlet.jsp.JspException: Content is not allowed in prolog.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Content is not allowed in prolog.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:854)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.xml.test_jsp._jspService(test_jsp.java:106)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.xml.sax.SAXParseException: Content is not allowed in prolog.
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264)
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseInputSource(ParseSupport.java:227)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseInputSourceWithFilter(ParseSupport.java:193)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseReaderWithFilter(ParseSupport.java:199)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseStringWithFilter(ParseSupport.java:206)
org.apache.taglibs.standard.tag.common.xml.ParseSupport.doEndTag(ParseSupport.java:138)
org.apache.jsp.xml.test_jsp._jspx_meth_x_parse_0(test_jsp.java:168)
org.apache.jsp.xml.test_jsp._jspService(test_jsp.java:82)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) -
In which cases can the ABAP statement CALL TRANSFORMATION be used?
Hi friends,
here is my questions with options below.
In which cases can the ABAP statement CALL TRANSFORMATION be used? (T/F)
-To transform as iXML document object into and ABAP data structure using
XSLT.
- To transform an XML document contained in a string into another XML
document
using and XSLT program.
- To get canonic XML display of an ABAP data structure.
- To transform an XML document contained in an xstring into another XLM
document using an ST program (Simple Transformation).
- To transform and ABAP data structure into an SML document using ST.
Kindly give me the expalnation to each statement with either True or False.CALL TRANSFORMATION is a new language element in ABAP that we can use to <b>call up the transformation</b>.
The type of transformation:
XML to XML
XML to ABAP
ABAP to XML or
ABAP to ABAP is already determined by the two additions SOURCE and RESULT in CALL TRANSFORMATION.
Check this link for more details.
http://help.sap.com/saphelp_nw04/helpdata/en/a8/824c3c66177414e10000000a114084/content.htm
Regards,
Maha -
Transforming XML/XSLT : CDATA problem
Hi!
I have a problem transforming xml with XSLT using the API javax.xml.
The result is correct until I have a CDATA section in my xml document.
The transforming process encodes all the & < > (special characters) it finds in.
This occurs problem for the follow of my treatement because the content of my CDATA is already encoded.
For example, this xml code :
<?xml version='1.0' encoding="ISO-8859-1" ?>
<article>
<article-contenu><![CDATA[Accent : é Signe : <]]></article-contenu>
</article>
produces in my output :
Accent : &eacute; Signe : &lt;
This is my java code :
TransformerFactory tFactory = TransformerFactory.newInstance();
Source xmlSource = new StreamSource(readerXml);
Source xslSource = new StreamSource( fileXsl );
// Generate the transformer.
Transformer transformer = tFactory.newTransformer(xslSource);
// Perform the transformation, sending the output to the response.
transformer.transform(xmlSource, new javax.xml.transform.stream.StreamResult(sw));
How can I tell the transformer not to do that?
Thanks for your answers!I am having a similar problem. I have enclosed my text data in my xml file like this:
<![CDATA[<b>Hello World!</b>]]>
My select statement in my XSLT sheet is as follows:
<xsl:value-of select="." disable-output-escaping="yes"/>
I have tried setting xsl:output to text, to html, and to xml. The <, >, and & get converted to xhtml entities.
Where should I begin to troubleshoot? If the Xalan xslt jars? My stylesheet. My xml doc? Java code?
Any feedback welcome. -
Binary to XML using GUI_DOWNLOAD
Hi,
I am trying to download (local) the data in binary format to XML using CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD. But the data that has been downloaded contains all chinese characters instead of the actual data. And this doesn't happen everytime I download the file, but very sporadic. I am guessing this is something to do with the code pade. I have tried using different code pages and couldn't resolve the issue. we are on 4.7 and it is non-unicode.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
BIN_FILESIZE = L_LEN
FILETYPE = 'BIN'
FILENAME = 'C:/XML/Test.xml'
CODEPAGE = '4110'
CHANGING
DATA_TAB = LT_DATA
Please advise.Hi Tony,
you might want to check out interface IF_IXML and class CL_IXML_80_20 for conversions before download.
example:
form xstring_download using p_xml_xstring type xstring.
data: lt_filename type standard table of file_table with header line.
data: lv_rc type i. " Anzahl der Dateien := 1.
* Deklarationen für DOWNload...
data: lv_download_rc type sysubrc.
data: lv_filename type string.
types: lty_x_line(256) type x,
lty_x_tab type table of lty_x_line.
data:
lr_ixml type ref to if_ixml,
lr_document type ref to if_ixml_document,
lr_streamfactory type ref to if_ixml_stream_factory,
lr_parser type ref to if_ixml_parser,
lr_istream type ref to if_ixml_istream,
lv_xtab_size type i,
lt_xtab type lty_x_tab.
*** STEP 1
*** transform XML String of type XSTRING into Table
* create the ixml main factory
lr_ixml = cl_ixml=>create( ).
* create a stream factory
lr_streamfactory = lr_ixml->create_stream_factory( ).
* create a input stream
lr_istream =
lr_streamfactory->create_istream_xstring( string = p_xml_xstring ).
* create a ixml document (DOM Respresentation)
lr_document = lr_ixml->create_document( ).
* create a xml parser
lr_parser = lr_ixml->create_parser(
document = lr_document
stream_factory = lr_streamfactory
istream = lr_istream ).
* parse document
check lr_parser->parse( ) = 0.
* render to table of x -> default encoding utf-8
call method cl_ixml_80_20=>render_to_table_of_x "also: table_of_c
exporting
document = lr_document
pretty_print = 1
importing
stream_table = lt_xtab
stream_table_size = lv_xtab_size.
*** Step 2
*** Download
* Init
clear lv_rc.
refresh lt_filename.
lv_download_rc = 4.
while lv_download_rc ne 0.
call method cl_gui_frontend_services=>file_open_dialog
changing
file_table = lt_filename[]
rc = lv_rc
exceptions
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
others = 5.
if sy-subrc <> 0.
* MESSAGE annn(kkkk) WITH space. "<<<<<< adjust
elseif lv_rc lt 1. "e.g. abort by user
exit. "from while loop.
endif.
if not lt_filename[] is initial.
read table lt_filename index 1.
move lt_filename-filename to lv_filename. "implicit conversion
call function 'GUI_DOWNLOAD'
exporting
bin_filesize = lv_xtab_size
filename = lv_filename
filetype = 'BIN'
tables
data_tab = lt_xtab
exceptions
others = 1.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
if sy-subrc <> 0.
* MESSAGE innn(kkkk) WITH g_filename. <<<<<< adjust
* GUI-Übertragungsfehler (UPLOAD &1)
else.
lv_download_rc = 0.
endif.
endif. "not lt_filename[] is initial.
endwhile.
endform . "xstring_download
have fun!
hp
Maybe you are looking for
-
This serial number is no longer valid for this product
Hi everyone, when I typed in my serial number for my design premium 5.5, it said "This serial number is no longer valid for this product". I purchased the product in 2011 and I installed it on my computer several times because I re-installed windows.
-
While doing SO, im getting run time error - reg;
Hi, While doing sales order and whenever im doing save its getting runtime error. Runtime Errors MESSAGE_TYPE_X Date and Time 14.12.2011 10:55:26 Short dump has not been completely stored (too big) Short text The current applica
-
Xdock Optical out to MD in?
Hi there, have just become the proud owner of an Xdock transmitter & receiver pair. Unfortunately, my pride is draining away fast! I bought this to connect to a Sony micro system that only has an MD (optical) in. Having connected it up, I'm getting n
-
Iphoto 11 edited pictures are shown in reduced size
Hello, maybe someone has a tip: I have imported some very important Jpegs from a Nikon D90 to Iphoto. Then right click and edit in external photo editor (Photoshop). After finsihed editing, hit the save button. Closed the photo in Photoshop, and retu
-
Problems with email on new ipad not deleting?
I have recently synced my new ipad 64gb 4g wifi from the back up from my ipad2. All was working fine & (no previous problems with my emails on ipad2) until I received an email a few days ago from apple which the original acknowledged changes to secut