ENTITIES and transforming XML to XML/HTML using XSL

I am going absolutely nuts. When using XSL to transform an XML
file to HTML or another XML schema, critical entities dissappear.
For example:
<oldtag>press &quot;any&quot; key</oldtag>
will get rendered to
<newtag>press "any" key</newtag>
by the XML/XSL parser, which is not valid HTML or XML.
How do I preserve these entities through the transformation
process. Escaping the text (in the XML source) with <![CDATA[]]
is not possible in this case.--Michael
null

Assuming you can't use a CDATA in the DTD to prevent parsing,
then my suggestion would be to use the XSL stylesheet to restore
the entities as there is no way that I am aware of that will set
conditional expansion.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
Michael Van Auken (guest) wrote:
: I am going absolutely nuts. When using XSL to transform an
XML
: file to HTML or another XML schema, critical entities
dissappear.
: For example:
: <oldtag>press &quot;any&quot; key</oldtag>
: will get rendered to
: <newtag>press "any" key</newtag>
: by the XML/XSL parser, which is not valid HTML or XML.
: How do I preserve these entities through the transformation
: process. Escaping the text (in the XML source) with <![CDATA
: > is not possible in this case.
: --Michael
null

Similar Messages

  • Converting XML document to HTMl using xsl

    Hi,
    I'm trying to convert an xml document into html page using xsl. But when I try to open the page in the browser nothing comes up.
    I'm not sure if I am using the PrintWriter correctly.
    StreamResult result = new StreamResult(new PrintWriter(new (File"text.html")));
    Please help.

    Oops! I wrote the parenthesis wrong in the previous mail
    This is the correct one I use in my program.
    StreamResult result = new StreamResult(new PrintWriter(new File("text.html")));
    Please help. Its urgent

  • Code to translate xml data into html using jaxp ?

    Hi all !!
    Could you please send me code to translate xml data into html using jaxp
    i am sending my xml file and xsl file
    its urgent
    my xml file is :
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="scenario.xsl"?>
    <scenarioReport>
    <node name="node1">
    <netObjId>124 </netObjId>
    <result>undefined</result>
    <report>The cell is 124.</report>
    <action>qsdsqdqsd </action>
    </node>
    <node name="node 3">
    <netObjId>124 </netObjId>
    <result>undefined</result>
    <report>Result is unresolved because ...</report>
    <action>No action</action>
    </node>
    <node name="node 2">
    <netObjId>124 </netObjId>
    <result>undefined</result>
    <report>qsdqsdqs </report>
    <action>qsdsqd</action>
    </node>
    <node name="node 5">
    <netObjId>124 </netObjId>
    <result></result>
    <report> </report>
    <action> </action>
    </node>
    <node name="node 4">
    <netObjId>124 </netObjId>
    <result></result>
    <report> </report>
    <action></action>
    </node>
    </scenarioReport>
    my xsl file is::
    <?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"/>
    <xsl:template match="/">
    <html>
    <body>
    <h2> Scenario Report</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
    <th align="left">Nodename</th>
    <th align="left">netObjId</th>
    <th align="left">Result</th>
    <th align="left">Report</th>
    <th align="left">Action</th>
    </tr>
    <xsl:for-each select="scenarioReport/node">
    <tr>
    <td><xsl:value-of select="@name"/></td>
    <td><xsl:value-of select="netObjId"/></td>
    <td bgcolor="#ffffff "><xsl:value-of select="result"/></td>
    <td><xsl:value-of select="report"/></td>
    <td><xsl:value-of select="action"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

    Must be something wrong with your XSL.
    However apparently it was so urgent that you didn't have the time to look at what you posted. They just "fixed" the forum software and apparently it doesn't escape HTML that you type in any more. Or stuff that looks like HTML, either. So your post was unreadable.
    If your deadline hasn't passed, try reposting that code surrounded by [pre] and [/pre].

  • Problem in transforming xml to html using xsl

    Hi everybody ,
    I am creating a xml in memory and i want to transform using xsl into an html.
    I want to embed some html code also in the data node.But when I get the html it simply writes as it is. I tried to make it cdata section but it did not worked. Pls help.
    crypticashu
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.dom.DOMSource;
    import org.w3c.dom.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    public class mytemp {
         public static void main(String args[])
         DocumentBuilder builder = null;
         Document document = null;
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         try
         builder = factory.newDocumentBuilder();
         document = builder.newDocument();
         catch (ParserConfigurationException e)
         e.printStackTrace();
         Element root = (Element) document.createElement("REPORT");
         document.appendChild(root);
         Node child = document.createElement("DATA");
         CDATASection data = document.createCDATASection("<b>Hello World </b>");
         child.appendChild(data);
         root.appendChild(child);
         document.getDocumentElement().normalize();
         DOMSource domsource = new DOMSource(document);
              TransformerFactory tfactory = TransformerFactory.newInstance();
              File f = new File("c:/mytemp/report.xsl");
              StreamSource xsl = new StreamSource(f);
              File html = new File("c:/myhtml.html");
              try
                   Templates templates = tfactory.newTemplates(xsl);
                   Transformer transformer = templates.newTransformer();
                   transformer.transform(domsource, new StreamResult(html));
              catch(Exception e)
                   e.printStackTrace();
         }

    want to embed some html code also in the data node.But when I get the html it simply writes as it is.That statement contradicts:
    In real application i will be getting data containg html tags.I want the parser to read that data as simple text. Both cannot be true. You either want the HTML to not be parsed or you want the transformer to deal with it. Which one?
    - Saish

  • Write and transform to String XML

    I have a big trable.
    I dinamicly generate XML File and try to transform it to String. I use standart toString() method for root Element of XML Document.
    My data are in Windows-1251 encoding, but result String is in UTF-8 encoding.
    When I write dinamicly generated XML Document in File.
    I set encoding Windows-1251, but result is in UTF-8.
    PLEASE HELP ME!!!!!

    Well, regarding file encodings Java has a history and so does MS-Windows. I don't know all the details for the Russian (let's rather use the term Cyrillic from now on) encodings but I went through a similar problem with German and iso-8859-1 encoding. The problem was similar in that some characters above 127 got displayed as '?'.
    Java uses a default encoding which changed in versions later than 1.1.7 from iso-8859-1 to CP1252 (I assume that for Cyrillic that translates to iso-8859-5 and cp1251, respectively).
    Windows and DOS have a whole list of changes with respect to Cyrillian encodings: CP855, CP866 and finally CP1251, which is incompatible with both iso-8859-5 and ISO-IR-111 (aka KOI8).
    Since your characters are displayed as '?' it's very unlikely you'll see a UTF-8 encoding in your output file (with all due respect), it rather seems to be a mismatch between one of the iso encodings and CP1251, that's my guess.
    Anyways, let me describe my problem a bit, and hopefully you can deduce a solution for yours.
    My XML file contained character 129 (that's a u with two dots on top) and displaying as well as writing that character to a file put a '?' in its place. DOS ASCII editors (as well as older Windows editors) use iso-8859-1 and display and input character 129 correctly and when I used JSDK1.1.6 everything was fine. Now, Java assumes CP1251 and by forcing it to use iso-8859-1 I got input and output working just fine.
    Since I don't have a Cyrillic Windows version at my disposal I can't find out which encoding will work for you, but it has to do with the default encoding Java is using, not so much with the XML and its parsing.
    You can use the following test program to find out what the correct settings are. Play with the encoding settings (CP8xx, iso-8859-5, CP1251) until both input and output files are identical and contain the correct characters.
    import java.io.*;
    class x{
       public static void main(String[] args)
          try
             InputStreamReader  isr = new InputStreamReader(new FileInputStream("ascii.txt"), "iso-8859-1");
             OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("ascii_out.txt"), "iso-8859-1");
             char[] buf=new char[1024];
             int n;
             while((n=isr.read(buf,0,1024))!=-1)
                osw.write(buf,0,n);
             isr.close();
             osw.close();
          catch(Exception e)
             e.printStackTrace();
    }If you still have problems, please provide more information:
    1. encoding attribute you're setting in the XML file
    2. the default file encoding of your Java version (a system property) + JSDK version
    3. XML parser vendor + version
    4. What you exactly mean by "transform" (XSLT ? just outputting ?)
    5. Some code samples might help, too.
    Hope that helps,
    Good luck.
    P.S.
    Here are some links for info on character sets and encodings:
    http://czyborra.com/charsets/codepages.html
    http://czyborra.com/charsets/iso8859.html
    http://www.cl.cam.ac.uk/~mgk25/unicode.html

  • How to validate and transform large (180M) xml files

    Hi:
    I've been looking at various ways to do this with oracle and am getting a bit lost in the sea of documentation and different ways to go about this. I was hoping that something like the XMLParser class and XMLTransform would be smart enough to handle large files by using SAX when it has to but I'm getting "too many nodes" when trying to transform a really large file. I've gotten oraxsl to handle it if I pass in the proper memory parameters on the command line but a) this will still have limits and b) I was trying to do this in a stored procedure which (I think) means I'm looking at XMLParser?
    I've also seen documentation on something called "Scalable DOM" but I think that's only in 11g? So I'm thinking I have to write a (Java?) stored procedure to loop through the top elements of this XML file (select extract(...)) and transform each node?
    I have the XML, XSD, and XSLT all in clob columns. What's the easiest/quickest path within Oracle to validate the XML against the xsd and translate source XML with XSL?
    I'm using Oracle 10gR2 on RH Linux.
    Thanks.

    So I'm thinking I have to write a (Java?) stored procedure to loop through the top elements of this XML file (select extract(...)) and transform each node? Here's something I've written a while back when I hit the same restrictions ("too many nodes") on 10.2.0.4.
    It takes XMLType as input parameters (but it's easy to adapt for CLOB), and streams the transformed XML directly into a file :
    create or replace and compile java source named ora_xslt_util as
    import oracle.xml.parser.v2.*;
    import oracle.xdb.XMLType;
    import java.io.*;
    import org.w3c.dom.*;
    public class oraXSL
    private static XMLDocument getXMLDocument(XMLType xml) throws Exception
        XMLDocument doc = null;
        DOMParser parser  = new DOMParser();
        parser.setValidationMode(oracle.xml.parser.v2.XMLParser.NONVALIDATING);
        parser.setPreserveWhitespace(true);
        parser.parse(new StringReader(xml.getStringVal()));
        doc = parser.getDocument();
        return doc;
    public static void transform(XMLType doc, XMLType xsl, String filename) throws Exception
        OutputStream os = new FileOutputStream(filename);
        XMLDocument xmldoc = getXMLDocument(doc);
        XMLDocument xsldoc = getXMLDocument(xsl);
        XSLProcessor xsp = new XSLProcessor();
        XSLStylesheet xss = xsp.newXSLStylesheet(xsldoc);
        xsp.processXSL(xss, xmldoc, os);
        os.close();
    }and the PL/SQL wrapper (originally part of a package) :
    PROCEDURE processXSL (
       p_xmldoc IN XMLType
    , p_xsldoc IN XMLType
    , p_filename IN VARCHAR2
    IS
    LANGUAGE JAVA NAME 'oraXSL.transform(oracle.xdb.XMLType,oracle.xdb.XMLType,java.lang.String)'
    ;

  • How to display xml to html using xsl?

    hi all...may i know how to display xml to html page?
    i ve included <xsl:output method="html" indent="yes" /> inside my xsl file. i clicked on output.xml file and everything is displayed correctly but the format is xml instead of html. is there anyway to transform it to html?
    below are my xsl and xml codes:
    // xsl file
    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="yes" />
    <xsl:template match="/">
    <html>
    <body>
    <h2>Document Contents</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
         <th align="center">Document Name</th>     
         <th align="center">Document ID</th>          
         <th align="center">Owner</th>               
    </tr>
    <xsl:for-each select="Document/Contents">
    <tr>
    <td><xsl:value-of select="DocumentName"/></td>
    <td><xsl:value-of select="DocumentID"/></td>
    <td><xsl:value-of select="Originator"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    // xml file
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="xsltStyleSheet.xsl"?>
    <Document>
         <Contents>
              <DocumentName>register</DocumentName>
              <DocumentID>1</DocumentID>
              <Originator>hhh</Originator>
         </Contents>
    </Document>
    </xsl:template></xsl:stylesheet>

    your XSL transforms to HTML (in fact XHTML): what more do you expect? did you expected anything different from the following output? if yes: what and why?
    <html>
         <body>
              <h2>Document Contents</h2>
              <table border="1">
                   <tr bgcolor="#9acd32">
                        <th align="center">Document Name</th>
                        <th align="center">Document ID</th>
                        <th align="center">Owner</th>
                   </tr>
                   <tr>
                        <td>register</td>
                        <td>1</td>
                        <td>hhh</td>
                   </tr>
              </table>
         </body>
    </html>

  • How to convert from xml file to html using java code

    How to convert from xml file to html file using java code

    Get yourself Apache Xalan or Saxon or some XSLT processor
    String styleSheet = "/YourXSLTStylesheet.xsl";
    String dataSource = "/YourXMLDocument.xml";
    InputStream stylesheetSource = TransformMe.class.getResourceAsStream(styleSheet);
    InputStream dataSourceStream = TransformMe.class.getResourceAsStream(dataSource);
    OutputStream transformedOut = new FileOutputStream("filename.html");
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer(new StreamSource(stylesheetSource));
    transformer.transform(new StreamSource(dataSourceStream), new StreamResult(transformedOut));You'll also need to learn XSLT if you don't already know that. Here's a good place to start
    http://www.w3schools.com/xsl/

  • Preserving Line and Tab Spaces in XML File

    Hi all,
    Question is in detail
    I want to preserve spaces in my XML Document.
    XML File is as follows
    <?xml version="1.0" encoding="UTF-8"?>
    <desc xml:space = "prserved">          AAA&#xD;
    &#xD;
    Customer Id: [ customer_id ]&#xD;
    Customer Id: [ customer_id ]&#xD;
    Customer Id: [ customer_id ]&#xD;
    Customer Id: [ customer_id ]&#xD;
    Customer Id: [ customer_id ]&#xD;
    </desc>
    Output of the XML File Should be like this
    AAA
    Customer Id: [ customer_id ]
    Customer Id: [ customer_id ]
    Customer Id: [ customer_id ]
    Customer Id: [ customer_id ]
    Customer Id: [ customer_id ]
    i want same output that what you see above, when i am converting xml file to pdf file.
    First, i am generating XML File dynamically
    Second, i am writing XSL File(Predefined)
    Third, Using FOP, i am converting XML to PDF(By Using XSL File)
    Here is My XSL File
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:preserve-space elements="desc"/>
    <xsl:template match="/">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
         <fo:layout-master-set>
              <fo:simple-page-master master-name="simple">
                   <fo:region-body margin-left = "2cm" margin-right = "2cm" margin-top = "2cm" margin-bottom = "2cm"/>
              </fo:simple-page-master>
         </fo:layout-master-set>
         <fo:page-sequence master-name="simple">
              <fo:flow flow-name="xsl-region-body">
                   <xsl:apply-templates select="desc"/>
              </fo:flow>
         </fo:page-sequence>s
    </fo:root>
    </xsl:template>
    <xsl:template match="desc">
    <fo:block font-weight="bold" color = "brown"><xsl:value-of select="."/></fo:block>
    </xsl:template>
    </xsl:stylesheet>
    i used (space preserving) attributes in XML File and XSL File also. But i am getting below output.
    AAACustomer Id: [ customer_id ]Customer Id: [ customer_id ]Customer Id: [ customer_id ] Customer Id: [ customer_id ]Customer Id: [ customer_id ]
    Please help me.

    Thanks for your Response
    I want to preserve space when i convert xml file to pdf. So we need to use FO
    attributes.
    <fo:block wrap-option="no-wrap" white-space-collapse="false"><xsl:value-of
    select="."/>
    </fo:block>

  • Help XSLT Data Mapper and Transformations

    Hi guys,
    I need help in oracle ESB (XSLT Data Mapper and Transformations). I need to use the XSLT Data Mapper and Transformations using Response XML to Request XML.
    Thanks
    Vyas

    The concept is the same as BPEL. Without going into too much detail have a look at the folowing tutorial.
    http://download.oracle.com/docs/cd/B31017_01/integrate.1013/b28212/buildendtoend.htm#BEICEFJD
    Near the bottom they show how to do transformations.
    cheers
    James

  • Unique encoding transformation using XSL

    i know that when u use xsl to trnsform XML, the standart say it support UTF-8/16
    for example in hebrew there are encoding that are not included in UTF-8/16.
    is there any option that during the prosses of transformation, the XSL will know whats the local encoding the system it works on and transform by it.
    tank's
    d'

    XSL is specified at a model above the character encoding layer, so it shouldn't matter what the input encoding is.
    <xsl:output encoding="whatever"/> should do you for encoding the output.
    It's unlikely that there are Hebrew characters that cannot be encoded in UTF-8; if they are, they are not Unicode, and so cannot be represented in any XML. Check that you're encoding the input document properly.
    Pete

  • 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,
    Christina

    Basically:
        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

  • Create an XML Document with HTML Entities?

    I'm writing a program that uses SAX to parse an XML document and generate XHTML from it, but I would like the XML document to allow HTML entities, of course, in the XML markup.
    Each time my parser gets to any entity at all it dies reporting an undefined entity.
    Is there any way I can refer to the HTML entity DTD or perhaps, in my own DTD, copy and paste the HTML entities? How would I make a reference like this in my XML document?
    Thanks

    Seems to me you would just put something like<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">before your root element. Or whichever DTD you actually want. I found out about them here:
    http://www.utoronto.ca/webdocs/HTMLdocs/HTML_Spec/html.html

  • How do I generate HTML from XML & XSL using XSL Processor ?

    I want to generate a HTML from XML & XSL using XDK for C on
    linux-8i.
    I run the XSLSample well.
    But it only generate a XML from a XML & a XSL.
    Can any one give me some advise or sample code?

    Just use HTML tags instead of xml tags in your stylesheet, and
    you'll generate HTML instead.
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <html>
          <body>
            <xsl:for-each select="ROWSET">
              <table border="1" cellspacing="0">
                <xsl:for-each select="ROW">
                  <tr>
                    <td><xsl:value-of select="EMPNO"/></td>
                    <td><xsl:value-of select="ENAME"/></td>
                  </tr>
                </xsl:for-each>
              </table>
            </xsl:for-each>
          </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>

  • XML page cannot be displayed cannot view XML input using XSL style sheet Please correct the error and then click the REfresh

    XML page cannot be displayed cannot view XML input using XSL style sheet Please correct the error and then click the REfresh

    Is the error message displayed in Firefox or in IE, or in a customized window that doesn't identify the browser?
    ''If it displays in Firefox:''
    It's possible that the Troubleshooter doesn't work correctly unless IE is your default browser. You could test that possibility by having IE make itself the default and testing the Troubleshooter again.
    ''If it displays in IE or embedded in another Microsoft application:''
    In a web search I found these suggestions:
    (1) Reset your Internet Explorer settings, according to http://answers.microsoft.com/en-us/ie/forum/ie8-windows_7/cannot-view-xml-using-xsl-style-sheet/ccfe80c6-c0db-4594-a7e3-475f9eac0e85
    (2) Try the System File Checker, according to http://ask-leo.com/why_do_i_get_the_xml_page_cannot_be_displayed_after_running_a_microsoft_troubleshooter.html
    Any luck?

Maybe you are looking for

  • Hi, I updated my version of iTunes and now get the error "The program can't start because MSVCR80.dll is missing from your computer".

    Hi, I hope some one can help as I updated my version of iTunes and now get the error "The program can't start because MSVCR80.dll is missing from your computer". I understand that I need to delete and reinstall iTunes but all of my music has been upl

  • Need to print Header Note from Shipment

    Hi gurus I need to print the Header Note text from shipment. So far I have the following code: Include &xxxxxx-tdname&  object vttk id 0003 paragraph IT The X's are what I need to define.  Is it VBDKL (although that is Header view for Delivery note)

  • File DOS encoding

    Hi experts, we would like to create a text file in DOS format. We specified:   OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE WITH WINDOWS LINEFEED IGNORING CONVERSION ERRORS. Even if "WINDOWS LINEFEED" is specified, the file comes

  • 1 gig Mushkin and K7N2 question

    There is a large retailer here that is selling PC3200 Mushkin High Performance Level II matched 512 sticks for $250.00. This sounds like a great deal, but I want to know if anyone has used these in the K7N2. I noticed that there more than a few that

  • Diff bet. 2000 & 2003

    Hi all, What is the difference in installation of R/3 4.7 in Windows 2000 Advanced Server and 2003 standard Edition. can i use Oracle 8 with ora patches in windows 2003. what is the best DB for SAP. Bidhu