Embedding HTML in XML CDATA and encoding issues

Hi all,
I'm embedding HTML code in a CDATA section. My problem is that, depending on the document, the HTML can be encoded in many formats. I borrowed a piece of code that sniffs that format so i can create String in the "right" encoding (or at least the one that was guessed).
- If I directly injected those in the CDATA section, i guess they'd be encoded in UTF-8 and some character would be misinterpreted?
- What if i would transcode the HTML from the sniffed format to utf-8?
-Are there any issues woth doing this?
Sorry if this is a dumb question but I'm quite new to that kind of encoding issues.
BTW i'm using DOM.
Thanks
lexo

I don't know if it's a dumb question. I just don't understand it at all. Encoding issues only arise when you write data from a Java program to an external location, or when you read data from an external location into a Java program. And none of the activities you mentioned there have anything to do with that.
When you write your XML to an external file, or wherever you write it to, it gets encoded at that moment. The whole thing. Elements, attributes, CDATA sections, the whole thing. Doesn't matter what's in it, the whole thing gets encoded in whatever charset was chosen.
Does that help?

Similar Messages

  • Problems embedding HTML into XML with CVIXMLSetElementValue - unwanted &lt and &gt

    I'm using the CVI XML functions. When I try to insert some pre-exsting HTML as the element value with CVIXMLSetElementValue, it dutifuly converts all the HTMLangle brackets into &lt and &gt, which is NOT what I want.
    (I can protect the XML integrity by wrapping it in [CDATA[ ....]] but that does not solve the conversion issue here.)
    Any suggestions?
    Thanks,
    Ian
    Solved!
    Go to Solution.

    To explain a bit further, below is a code snippet and the unwanted result that I see. Does this behavior - even with CDATA - make good design sense?
    From my perspective CVIXMLSetElementValue should respect CDATA elements. Am I right? Or just biased?
    stat = CVIXMLSetElementValue (test1_element, "Hello");
    stat = CVIXMLSetElementValue (test2_element, "<p>Hello</p>");
    stat = CVIXMLSetElementValue (test3_element, "<! [CDATA[<p>Hello</p>]] >");
    // Problematic Output:
    // <?xml version="1.0"?>
    // <root>
    // <test1>Hello</test1>
    // <test2>&lt;p&gt;Hello&lt;/p&gt;</test1>
    // <test3>&lt;! [CDATA[&lt;p&gt;Hello&lt;/p&gt;]] &gt;</test1>
    // </root>

  • Embedding html in xml tags, when rednering text as html

    Quick question,
    I have a site that reads all content from an external xml.
    The text box that reads this info renders the content as html; does
    anyone know how to go about putting an html tag in an xml tag so
    that flash can read it?
    So would it be possible to do:
    <content>
    " Welcome to the site<br>we are happy to have you
    here<br><img src="logo.jpg"> "
    </content>

    I completed deleted the old way, so I have to recreate this
    from scratch...but here is how I used to be able to do it (which,
    looking at how I do it now since HTML wasn't parsing, this was so
    stupid).
    <chair id="1" price_point="High-end">
    <image>&lt;a
    href='/dsn/catalog/viewproductpage.asp?OwnerID=1&amp;PageID=%7B7A0FB858%2D2184%2D4033%2DB 474%2D2B22D89BBD96%7D'&gt;&lt;img
    src='/images/s/dshe/mini/7/79219.jpg border='0'
    /&gt;&lt;/a&gt;</image>
    <description>&lt;a
    href='/dsn/catalog/viewproductpage.asp?OwnerID=1&amp;PageID=%7B7A0FB858%2D2184%2D4033%2DB 474%2D2B22D89BBD96%7D'&gt;Toni&lt;/a&gt;</description>
    <brand>Kwalu</brand>
    <composition>Kwalu</composition>
    <leg_style>Chippendale</leg_style>
    <overall_style>Transitional</overall_style>
    </chair>
    And now in 1.1, having that, it prints this on screen:
    <a
    href='/dsn/catalog/viewproductpage.asp?OwnerID=1&PageID=%7B7A0FB858%2D2184%2D4033%2DB474% 2D2B22D89BBD96%7D'><img
    src='/images/s/dshe/mini/7/79219.jpg border='0' /></a>
    whereas before, it would be that image and it would link to
    the page specified in the href.
    I'm about to take off from work for the night, but I'll check
    back when I get home if you need anything else from me.
    Thanks for your help, Kin. :)
    Kyle

  • Xml deserialization and namespace issue.

    I have an xml file something like:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <NS1:NodeA xmlns:NS1="FooSpace">
    <NS1:NodeB>
    <NS1:NodeC>
    <NS1:ElementA>text</NS1:ElementA>
    </NS1:NodeC>
    <NS1:NodeD>
    <Attributes>
    <Name>xxx</Name>
    <Value>yyy</Value>
    </Attributes>
    <Attributes>
    <Name>www</Name>
    <Value>zzz</Value>
    </Attributes>
    </NS1:NodeD>
    </NS1:NodeB>
    </NS1:NodeA>
    I can parse every thing upto the contents of NodeD. For the classes which expose elements (NodeA to NodeD), I decorate the properties as follows:
    [XmlElement("property_name", Namespace = "FooSpace")]
    The Attributes class has properties without the Namespace key.
    Anyone know what I am missing?
    Thanks!

    I am glad to know you solved this problem and thanks for sharing the solution.
    It will be very beneficial for other community members who have the similar questions.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • XML editor with buttons to add HTML tags via CDATA

    Hi:
    Does anyone know an XML editor with buttons to add HTML tags via CDATA?
    <?xml version="1.0" encoding="UTF-8"?>
    <content1>
    <text1>
    <![CDATA[<p><b>]]>THE ORIGINS.<![CDATA[</b><br />]]>
    He was born ...
    <![CDATA[<br /><br /><p>]]>
    Thanks in advance

    I just did a google search of "XML editor with buttons to add HTML tags via CDATA" and found this.
    I usually just write in all my XML by hand that included the CDATA tags if needed.
    http://activeden.net/item/flash-xml-editor-version-2/47884
    I hope this helps?

  • Continuing font encoding and tag issues with snow leopard and CS4oI

    I am looking for help with a font handling issue with snow leopard and cs4 Indesign. Despite numerous calls and hours on the phone neither Apple nor Adobe has been helpful. I have had this issue open with Adobe since oct 5 but they remain totally unresponsive to date. I need to be able to use Type 1 fonts and do the following , export a pdf from Indesign with the following attributes: 1) xml tags for stories and objects. 2) have the fonts encoded as ansi and embedded.
    Some additional information  - exporting to ps is not an option as it destroys the xml tags. and doesn't guarantee that the fonts won't become CID or some other odd encoding.
    As it stands now,
    Leopard (10.5.8) and CS3 creates ansi encoded fonts with xml tags.
    Leopard (10.5.8) and CS4 creates ansi encoded fonts with xml tags.
    Snow leopard and CS3 creates ansi encoded fonts and xml tags
    Snow leopard and CS4 creates custom subsetted fonts and some xml tags.
    If any one has any advice on how to force specific font encodings from CS4 pdf exports so that i can preserve the tags and get the correct fonts I would be grateful.

    The font encoding is not a function of the OS version, but rather of how a font is internally encoded and the content you are representing with the font.
    If you are seeing a difference between MacOS 10.5 and 10.6 with the same Adobe software, it probably has something to do with use of a system font that is somehow different from one version of the OS to another. InDesign does not use any of the OS' font handling software.
    Assuming that the fonts are embedded, subset or not, what is your issue with whether a font is ANSI-encoded, custom-encoded, or CID-encoded? It should make no difference for purposes of workflow beyond InDesign for software that adheres to the PDF specification (including all versions of PDF from 1.3 and up to 1.7 plus ISO 32000-1 PDF and all versions of PDF/X and PDF/A).
    Neither InDesign or any other Adobe application provides user choices for the encoding since it shouldn't make a difference. The encodings chosen by Adobe's core technology components are for a combination of optimization and to support proper text search, copy, etc.
              - Dov

  • Composition widget and embedded html

    Hi, I'm trying to embed html from a wazala store, within a compostion widgit.
    It works very well the first time using the desired rollover effect but when the target is hidden after rollout (as expected) and one rolls back over the trigger the embeded html in the target doesn't reapear except if the browser window is refresehed.
    I've uploaded the example, the grey box in the top left corner is the trigger.
    http://imberg.at/beerbottle/
    Thanks in advance for any help
    Andy

    Put the text into a CDATA section. Like this:
    <![CDATA[<html><body>This is HTML</body></html>]]>
    Or escape the characters (< and & at least) that need to be escaped in text nodes:
    &lt;html>&lt;body>This is HTML&lt;/body>&lt;/html>
    Or even better, just use standard XML software and ask it to output your data to an XML document instead of writing your own code to output XML to a file. It takes care of this problem and many others.

  • Encoding Issue : JMS and Mapping : utf-8 iso8859-1

    Hi All,
    I am facing some problem with encoding issue.
    Scenario :  JMS -->  SAP PI --> JMS
    Requirment : Input plain text file contain some special characters,"©®" . Based on this condition,In Java Mapping
                       we check the Payload and changed the 'encoding' tag to UTF-8 or   ISO8859-1.                                                     
                   : <?xml version="1.0" encoding="UTF-8"?>     in the target XML output.
    While testing in Operation mapping our Java mapping works fine. as the encodeing tag changes from
                 UTF-8 to ISO8859-1 if the special character exists.But if I test the same in Integration Directory(Test Configuration)
                 or did a end to end  testing. The encoding tag did'nt changes.
    For testing we had to a set of Plain Text files with UTF-8 and ISO8859-1 .
    I tried the options of using beans in Adapter modules in Sender JMS channel.
    MessageTransformBean, TextCodepageConversionBean, XmlAnonymizerBean
    These doc & threads ,was also referred[How to Handle Encoding in PI|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42]
    Regards,
    Ashutosh R

    Hi
    public static boolean fixSpecialCharforWeb(String text) {
            int i = 0;
            Character c = null;
            char[] ctext = null;
            StringBuffer newText = new StringBuffer("");
            //boolean encodingType = false;
            if ((text == null) || (text.trim().length() == 0)) {
                return encodingType;
            } else {
                try {
                                   for (i = 0; i < text.trim().length(); i++) {
                        ctext = text.trim().substring(i, i + 1).toCharArray();
                        c = new Character(ctext[0]);
                        //Single quote
                        if ((text.trim().substring(i, i + 1).equals("'")) || (c.hashCode() == 8217) || (text.trim().substring(i, i + 1).equals("?")) || (c.hashCode() == 146) || (c.hashCode() == 145)) {
                            //newText.append("'");
                            encodingType = true;
                            return encodingType;
                        //Double quotes
                        if ((c.hashCode() == 8220) || (c.hashCode() == 8221) || (c.hashCode() == 147) || (c.hashCode() == 148)) {
                            //newText.append(""");
                            encodingType = true;
                            return encodingType;
                        // bullet point
                        if ((c.hashCode() == 8226) || (c.hashCode() == 149)){
                            encodingType = true;
                            return encodingType;
                        // tilde
                        if ((c.hashCode() == 732) || (c.hashCode() == 152)){
                            encodingType = true;
                            return encodingType;
                        // Soft Hypen
                        if (c.hashCode() == 173){
                            encodingType = true;
                            return encodingType;
                        // En-Dash
                        if ((c.hashCode() == 8211) || (c.hashCode() == 150)) {
                            encodingType = true;
                            return encodingType;
                        // Em-Dash
                        if ((c.hashCode() == 8212) || (c.hashCode() == 151)) {
                            encodingType = true;
                            return encodingType;
                        // Euro Sign
                        if ((c.hashCode() == 8364) || (c.hashCode() == 128)) {
                            encodingType = true;
                            return encodingType;
                        // Yen Sign
                        if (c.hashCode() == 165) {
                            encodingType = true;
                            return encodingType;
                        // Pound Sign
                        if (c.hashCode() == 163) {
                            encodingType = true;
                            return encodingType;
                        // 1/2 sign
                        if (c.hashCode() == 189) {
                            encodingType = true;
                            return encodingType;
                        // 1/4 sign
                        if (c.hashCode() == 188) {
                            encodingType = true;
                            return encodingType;
                        // 3/4 sign
                        if (c.hashCode() == 190) {
                            encodingType = true;
                            return encodingType;
                        // Sword/dagger
                        if ((c.hashCode() == 8224) || (c.hashCode() == 134)) {
                            encodingType = true;
                            return encodingType;
                        // Trademark
                        if ((c.hashCode() == 8482) || (c.hashCode() == 153)) {
                            encodingType = true;
                            return encodingType;
                        // Ampersand &
                        if ((text.trim().substring(i, i+1).equals("&")) || (c.hashCode() == 38)) {
                            encodingType = true;
                            return encodingType;
                        //Registered mark
                        if ((text.trim().substring(i, i + 1).equals("?")) || (c.hashCode() == 174)) {
                            //newText.append("®");
                            encodingType = true;
                            return encodingType;
                        //Copyright mark
                        if ((text.trim().substring(i, i + 1).equals("?")) || (c.hashCode() == 169)) {
                            encodingType = true;
                            return encodingType;
                        // Question.
                        if (c.hashCode() == 63 && c.toString().equals("?")){
                            //newText.append("?");
                            encodingType = true;
                            return encodingType;
                        //handling symbol ?
                        if ((text.trim().substring(i, i+1).equals("?")) || (c.hashCode() == 233)) {
                            encodingType = true;
                            return encodingType;
                        if ((text.trim().substring(i, i+1).equals("?")) || (c.hashCode() == 232)) {
                            encodingType = true;
                            return encodingType;
                        if (c.hashCode() == 144) {
                            encodingType = true;
                            return encodingType;
                } catch (Exception e) {
                    e.printStackTrace();
            return encodingType;

  • XML Parser and Content-type/encoding problem

    I've write a little and simple XML parser and a simple "trasformer" that recive an XML file and an XSL one and return HTML, here is the code:
    public static String toHTML(Document doc, String xslSource){
            ByteArrayOutputStream testo = new ByteArrayOutputStream();
            try{
                DOMSource source = new DOMSource(doc);
                TransformerFactory tFactory = TransformerFactory.newInstance();
                System.out.println("----> " + xslSource);
                Transformer transformer = tFactory.newTransformer(new StreamSource(xslSource));
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
                transformer.setOutputProperty(OutputKeys.METHOD, "html");
             transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
             transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
                transformer.transform(source, new StreamResult(testo));
            }catch(Exception ioe){
                System.out.println("2 XMLTool.toHTML " + new java.util.Date());
                System.out.println(ioe);        
            return testo.toString();
        }the problem is that I would like to put the HTML code its return into a JEditorPane; now I'm trying with this code:
    JEditorPane jep1 = new JEditorPane();
    jep1.setContentType("text/html");
    jep1.setText(v);
    // 'v' is the string returned by the code posted up (the XML/XSL transformer)but I can't see anything in my JEditorPane.
    I think that the problem is this line of code that the transformer add automaticaly ad HTML code:
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">Infact if I try to delete this line from the code I can see what I want but is'n good delete a line of code without understend where is the problem.
    So, can anyone help me?

    good.
    when u set ur output properties to html , transformer
    searches for all entity references and converts accordingly.
    if u r using xalan these files will be used for conversion of
    Character entity references for markup-significant
    output_html.properties
    (this should be in templates package)
    and HTMLEntities.res(should be in serialize package)
    vasanth-ct

  • CDATA / html to xml

    How do i take the content of an html file and put in in an
    xml.
    The part that's in the CDATA are now individual html files so
    I want to
    take
    the content of that html file and put it in the CDATA. I'm
    not sure if
    that's the best way to do it though... might be better to
    store the HTML in
    the DB and then write it out from there???
    <emailMessage>
    <messagetype>Welcome</MessageTpye>
    <Subject>Welcome</Subject>
    <MessageContent>
    <![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN"
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=UTF-8" />
    <title>test</title>
    </head>
    <body>
    welcome to our site<br /> you are blah blah<br
    /><br />
    <p>blah blah</p>
    <table><tr><td>whatever</td></tr></table>
    </body>
    </html>
    ]]>
    </MessageContent>
    </emailMessage>
    The part that's in the CDATA are now individual html files so
    I want to
    take
    the content of that html file and put it in the CDATA. I'm
    not sure if
    that's the best way to do it though... might be better to
    store the HTML in
    the DB and then write it out from there???
    Suggestions?

    It is possible that your HTML, if it attempts to conform to
    XHTML standard, could include a CDATA section and I don't think
    you're permitted to nest a CDATA section inside another CDATA
    section.
    quote:
    I'm not sure if that's the best way to do it though... might
    be better to store the HTML in the DB and then write it out from
    there???
    It depends on your goal. If you're creating a content
    management system using a database for storage is probably a better
    option.

  • Web Intelligence: Save Report as PDF and with embedded HTML code

    Hi all.
    Sorry but I'm not able to find any post about this matter, please feel free to provide links if you know existing topics about this problem.
    We created a beautiful report with HTML5 code embedded into a blank cell and we are now trying to export it in a printable format (e.g.: PDF or HTML).
    As you know (as per manual information) it is not possible to export a report with embedded HTML code and keeping it in the output (cell with embedded HTML code is rendered blank).
    My question is: is there a known workaround or an alternative solution to export the report and keep its content?
    Print screen is not a valid option :-P
    Thanks for the support or any suggestions
    Stecas

    Product limitation; vote for change on ideaplace, etc. I don't believe there is an *easy* workaround, but see:
    https://scn.sap.com/thread/3149287
    HTH
    NMG

  • Premiere and Media Encoder CC encoding issue

    Hi all,
    I am having an encoding issue with PP and ME CC. My video assets are fine, and on the timeline they appear how they should, but when I look at the rendered h264 video there are encoding errors in the video. I have attached two images, the black is how it should look and the white is the error. The video plays fine and then it flickers between the images shown. 
    It has done this on a few different videos I have rendered over the last few days and I don't know why. It also happens to a different machine on CC as well. Does anyone have any suggestions?

    Hi James,
    I've never seen this before. Can you give us more info? Answer all the questions on this FAQ: What information should I provide when asking a question on this forum?
    Thanks,
    Kevin

  • XML Parser for PL/SQL and related issues

    I need to have further information about some of the following
    issues and XML features and make a determination useful for
    evaluation and recommendation:
    ISSUES
    1) Is there a maximum size for an XML document to provide data
    for PL/SQL(or SQL) across tables, provided that no CLOB are used?
    2) How about from Oracle to an XML document ?
    3) Is there a ratio between XML document size and main memory and
    SGA size. What are Oracle's recommendations /
    4) Can the Oracle Application Server run on a DHCP NT server when
    using XML parsing ? Is it NT Service Pack 3 and 4 compatible ?
    5) How parsers can interact with one another or related tools ?
    For example, how the XML parser for c/c++ could be useful when
    using Pro*C/C++ (programmer 2000) or OCI interfaces ? In other
    words, what is the business logic in using these tools ?
    null

    Anthony D. Noriega (guest) wrote:
    : I need to have further information about some of the following
    : issues and XML features and make a determination useful for
    : evaluation and recommendation:
    : ISSUES
    : 1) Is there a maximum size for an XML document to provide data
    : for PL/SQL(or SQL) across tables, provided that no CLOB are
    used?
    The limit should be what can be inserted into an object view.
    : 2) How about from Oracle to an XML document ?
    The limit should be what can be retrieved from an object view.
    : 3) Is there a ratio between XML document size and main memory
    :and SGA size. What are Oracle's recommendations /
    Not directly due to the relationship between XML metadata and
    data not being constrained.
    : 4) Can the Oracle Application Server run on a DHCP NT server
    : when using XML parsing ?
    If it can run a JavaVM with the correct permissions there are no
    other special requirements.
    :Is it NT Service Pack 3 and 4 compatible ?
    No special requirements here.
    : 5) How parsers can interact with one another or related tools ?
    : For example, how the XML parser for c/c++ could be useful when
    : using Pro*C/C++ (programmer 2000) or OCI interfaces ? In
    other
    : words, what is the business logic in using these tools ?
    Not really sure of your question. The XML components are useful
    in any application where I am processing documents or data with
    an XML structure. The choice to use XML can be based on quite a
    range of requirements due to its declarative syntax and open
    standards. If you give me a specific application, I can perhaps
    be more helpful.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • Using CDATA tags in XML program and parsing to J2ME

    Hi,
    Can anybody tell me how to use CDATA tag in a xml file and parse it to my J2ME code. is there any sample code available for this? I want to use this CDATA tag for sending Binary data. plzzzzzzz Help....!

    I think what you want is to parse a CDATA text from a xml file and let this text to execute.
    Very innovative idea!
    If I am right, I think you might mix some concept.
    Java code need to be changed to ByteCode before pased to the JVM. Furthermore, Java ME code must be verified before downloading to your machine.
    I figure that your attempt is impossible.

  • XML and encoding

    I'm being considered for a video encoding position that I would very much like to get.
    It is for a TV network. I've used Compressor, Sorenson Squeeze and MPEG Streamclip mostly. Do you know what I should be prepared to encounter at a major network?
    Also, they mentioned using XML. How is XML used for encoding video?
    Any help is greatly appreciated.

    I guess this might not be a good place to post this since it doesn't relate to a specific Apple product. S, apologies if that's the case. I have gotten some good help here before, so I thought I'd try.

Maybe you are looking for

  • Why doesn't my reedem code work

    I bought yesterday a bundle of photoshop elements and premiere elements. I wanted the serial number to retrieve the reedem code contained on the card, but it stands always there, that the code not activated. That can not be, because on the sales slip

  • Video Not Supported

    I have a 2TB NAS drive with over 300 hundred movies on. Sometimes when I try to watch a movie with ATV I get the message on the screen that the video format is not supported (when its fine they are all m4v) I go to itunes and see an ! next to the mov

  • SQL*Loader permission issue?

    I have set up a run_all script on LINUX to invoke SQL*Loader for each table to be loaded. I can run this as the Oracle owner just fine. When I try to let the developer run this on dev, they get the following: SQL*Loader: Release 9.2.0.1.0 - Productio

  • Query regarding fields in the material master

    Hi Gurus, We have a requirement where client wants to know the relevance of u201CBasic data textu201D and u201Cinspection textu201D tabs in material master (these appear when we click on additional data tab in material master) and also if we maintain

  • Looking for the pefect Linux Netbook

    Hi all. I'm making this first thread on the forum after reading it as an anonymous user for a couple of weeks. There is much interesting stuff in here, but I haven't quite found what I want answers to. I'll first of state my needs: I'm in of a netboo