Problem in Casting the encoded string to XML

Hi all,
From dotnet code i have encoded the XML as string and passed this value as XML attribute value in below.
Am not sure if we can have XML as attribute value inside another XML.hence i did with below approach.
Now i have special character '<' in that please refer yellow highlighted.this was having problem in casting to XML.
Kindly assist me.
Thanks in advance. 
DECLARE @XML
XML                       
SET @XML
= '<Utility><Actions><Action Category="ExecuteSp" SettingName="GetDMS" ComponentId="19">
<Parameters Param="SourceXML" Value="&amp;lt;NewDataSet&amp;gt;&amp;lt;Table1&amp;gt;&amp;lt;DocumentName&amp;gt;US OB
&amp;amp;lt; 14 Weeks /Transvaginal&amp;lt;/DocumentName&amp;gt;&amp;lt;/Table1&amp;gt;&amp;lt;/NewDataSet&amp;gt;" /></Action></Actions></Utility>'            
Declare @SourceDMSXML
as varchar(max)                          
SELECT 
@SourceDMSXML = @XML.value('(/Utility/Actions/Action/Parameters[@Param = "SourceXML"]/@Value)[1]','varchar(max)')               
SET @SourceDMSXML
= Replace(@SourceDMSXML
, '&amp;lt;',
'<');                   
SET @SourceDMSXML
= Replace(@SourceDMSXML
, '&amp;gt;',
'>');      
SET @SourceDMSXML
= Replace(@SourceDMSXML
, '&lt;',
'<');                   
SET @SourceDMSXML
= Replace(@SourceDMSXML
, '&gt;',
'>'); 
DECLARE @SourceXML
XML                          
SET @SourceXML
= CAST(@SourceDMSXML
AS XML)    
select  
@SourceXML  

How are you generating this value? You need to use TYPE directive for avoiding this
see similar example here
http://visakhm.blogspot.in/2014/01/rowset-concatenation-with-special.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • How to set the encoding of an XML-document

    I need to change the encoding of an xml-document.
    When I convert the document into a string, UTF-8
    is used, I want to use ISO-8859-1.

    use this in your identity transform:
    transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");

  • How to get the encoding of a XML file ...

    Hi,
    How do you get the encoding of a XML file?
    For example,
    <?xml version="1.0" encoding="SJIS"?>
    I am trying to retrieve the above encoding="SJIS", but I can't seem to locate the API for doing so.
    Thanks in advance for any help,
    Eric

    Hi ddossot,
    Thanks for your suggestion.
    However, the xerces.jar file that comes with my old tomcat server is an old version and thus, the getEncoding method is not even present in the DocumentImpl class. The option to update to a newer version of tomcat and xerces is not available. What a pity... :-(
    Well, I just have to try to find a way around. Worst case scenario, parse the first line in the xml file myself.
    Regards,
    Eric

  • How to find out the encoding of an XML input document

    Hello all,
    I read a XML file into a DOM document and would like to save it back in the same encoding as the input. How do I find out the encoding of the input document?
    This is my code for reading the document:
    import java.io.File;
    import java.io.FileInputStream;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMResult;
    import javax.xml.transform.stream.StreamSource;
    import org.w3c.dom.Document;
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    DOMResult domResult = new DOMResult();
    transformer.transform(new StreamSource(new FileInputStream(fileName)),
                          domResult);
    Document doc = (Document)domResult.getNode();
    .

    FileInputStream fis = new FileInputStream(fileName);
    String encoding = new InputSource(fis).getEncoding();
    fis.close();Note that this only works because you can get an InputStream over the document twice. If the document were coming from an HTTP response (for example) it wouldn't work.

  • How to get the "encoding" of a XML file using JDOM

    As in XML file, <?xml version="1.0" encoding="UTF-8" ?> indicates the encoding of this file
    while using JDOM to parse a XML file, how can I get the encoding type?
    thanx!!!

    What my program do is to get the encoding of XML files and convert them to UTF-8 encoding files, while I need this "encoding" information of the original XML document thus I can convert...
    After reading specifications and JDOM docs, the truth turns to be disappointed, no function is provided to get this information in JDOM level 2(the current released one), while it's promissed that this function will be provided in JDOM level API....
    Thanx all for your help and attention!!!

  • Problem figuring out the encoding for filenames with special characters

    I'm not sure if this is the right forum, but this does seem like an OS issue.
    I brought in a lot of mp3 and m3u files from a Windows machine to my new Mac. Some of the mp3 files have accented characters in their names, and these names appear in the m3u files. But if I add the m3u file to iTunes, it fails to recognize these names and so I lose all the mp3's with special characters in their names.
    I tried to fix this by grabbing the files name in Python, but that didn't work either!
    Here's an example: the file's name is "Voilà l'été.mp3"
    The m3u files says "Voil\xe0 l'\xe9t\xe9.mp3" -- this doesn't work.
    From os.listdir(), I get Voila\xcc\x80 l'e\xcc\x81te\xcc\x81.mp3", but sticking it in an m3u files doesn't work either. (Note that here the characters are encoded as unaccented letter + two byte code for the accent).
    When I try these strings from python, e.g. doing os.stat(), they both work; but iTunes doesn't understand any of them!
    I'd appreciate any hints on how to enter these names in the m3u file so that iTunes can read it. Thanks!

    I know nothing about "m3u" files and how iTunes interprets the file names in them, but if it is not a relative/absolute path problem, then how about just putting the raw file names (not the ones with backslash escape) in m3u file? For example, just put
    Voilà l'été.mp3
    in m3u?
    As for Unicode encoding, HFS+ file system uses the "decomposed form" for accented characters. This means, as you write, à is hex "61 cc 80" in UTF-8, i.e., "a + COMBINING GRAVE ACCENT". The pre-composed form is hex "c3 a0". But my experience is that in most cases both pre-composed and decomosed forms work at the user level (not at the lowest file system level).

  • Changing the encoding attribute in xml output

    We are creating an xml file using:
    vc_string_clob := dbms_xmlgen.getxml('select * from mytable');
    then opening the file with UTL_FILE.FOPEN('dir','filename','W',31767)
    then parsing through vc_string_clob and using UTL_FILE.PUT_LINE to write to the file.
    This all works fine, expect the header of the XML file is <?xml version="1.0"?> and our users need it to be <?xml version="1.0" encoding="ISO-8859-1"?>
    Is there a function within dbms_xmlgen that will allow me to change this?
    I'm thinking I can use brute force to change it, but I'm sure there is a 'more correct' way to go about it.
    Thank you,
    Jill Jacomine

    Hi Jill,
    Welcome to the forum.
    There are easier methods to output XML to a file, rather than using line-by-line UTL_FILE operations.
    For example :
    DECLARE
    xml_result xmltype;
    doc        dbms_xmldom.DOMDocument;
    BEGIN
    xml_result := dbms_xmlgen.getXMLType('SELECT * FROM scott.dept');
    doc := dbms_xmldom.newDOMDocument(xml_result);
    dbms_xmldom.writeToFile(doc, 'TEST_DIR/my_file.xml', 'ISO-8859-1');
    dbms_xmldom.freeDocument(doc);
    END;
    /or,
    DECLARE
    xml_result xmltype;
    xml_prolog clob := '<?xml version="1.0" encoding="ISO-8859-1"?>'||chr(10);
    BEGIN
    xml_result := dbms_xmlgen.getXMLType('SELECT * FROM scott.dept');
    dbms_xslprocessor.clob2file(xml_prolog || xml_result.getClobVal(), 'TEST_DIR', 'my_file.xml');
    END;
    /Both will produce :
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <ROWSET>
      <ROW>
        <DEPTNO>10</DEPTNO>
        <DNAME>ACCOUNTING</DNAME>
        <LOC>NEW YORK</LOC>
      </ROW>
      <ROW>
        <DEPTNO>20</DEPTNO>
        <DNAME>RESEARCH</DNAME>
        <LOC>DALLAS</LOC>
      </ROW>
      <ROW>
        <DEPTNO>30</DEPTNO>
        <DNAME>SALES</DNAME>
        <LOC>CHICAGO</LOC>
      </ROW>
      <ROW>
        <DEPTNO>40</DEPTNO>
        <DNAME>OPERATIONS</DNAME>
        <LOC>BOSTON</LOC>
      </ROW>
    </ROWSET>Hope that helps.

  • Converting Base64 encoded String to String object

    Hi,
    Description:
    I have a Base64 encoded string and I am using this API for it,
    [ http://ws.apache.org/axis/java/apiDocs/org/apache/axis/encoding/Base64.html]
    I am simply trying to convert it to a String object.
    Problem:
    When I try and write the String, ( which is xml ) as a XMLType to a oracle 9i database I am getting a "Cannot map Unicode to Oracle character." The root problem is because of the conversion of the base64 encoded string to a String object. I noticed that some weird square characters show up at the start of the string after i convert it. It seems like I am not properly converting to a String object. If i change the value of the variable on the fly and delete these little characters at the start, I don't get the uni code error. Just looking for a second thought on this.
    Code: Converting Base64 Encoded String to String object
    public String decodeToString( String base64String )
        byte[] decodedByteArray = Base64.decode( base64String );
        String decodedString = new String( decodedByteArray, "UTF-8");
    }Any suggestions?

    To answer bigdaddy's question and clairfy a bit more:
    Constraints:
    1. Using a integrated 3rd party software that expects a Base64 encoded String and sends back a encoded base64 String.
    2. Using JSF
    3. Oracle 10g database and storing in a XMLType column.
    Steps in process.
    1. I submit my base64 encoded String to this 3rd party software.
    2. The tool takes the encoded string and renders a output that works correctly. The XML can be modified dynamically using this tool.
    3. I have a button that is binded to my jsf backing bean. When that button is clicked, the 3rd party tool sets a backing bean string value with the Base64 String representing the updated XML.
    4. On the backend in my jsf backing bean, i attempt to decode it to string value to store in the oracle database as a XML type. Upon converting the byte[] array to a String, i get this conversion issue.
    Possibly what is happen is that the tool is sending me a different encoding that is not UTF-8. I thought maybe there was a better way of doing the decoding that i wasn't looking at. I will proceed down that path and look at the possibility that the tool is sending back a different encoding then what it should. I was just looking for input on doing the byte[] decoding.
    Thanks for the input though.
    Edited by: haju on Apr 9, 2009 8:41 AM

  • Messy code problem while translating XString to String in OfficeControl

    Hi Expert,
        I have messy code problem while translating XString to String in XML-Format Word Doc in OfficeControl.
    I upload an XML-Format template Word Doc to server as a MIME Object.
    When OfficeControl is started in Web Dynpro, OfficeControl automatically open the XML-Format template.
    For the first time, I get the XString-type Context attribute bind to the content of the Word Doc,
    then translate it to string, I got the XML-format content, it's great!
    However, after the first time, when I input any new contents in MS Word in Web Dynpro,
    no matter I execute "Ctrl + S" or click the "savedocument" button,
    when I translate the XString Context attribute to String, I got messy code. (but the first time, it is good plain text)
    I use the function module: ECATT_CONV_XSTRING_TO_STRING (good for first time, dump after first time),
    SCMS_XSTRING_TO_BINARY, SCMS_BINARY_TO_STRING (good for first time, messy code after first time).
    My Demo source code is in: (system) SMV --> (local object) zhaode --> (Dynpro Component) ztest_office_control
    core source code is as:
    clear itab.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
    BUFFER = lv_datas
    IMPORTING
    OUTPUT_LENGTH = lv_length
    TABLES
    binary_tab = itab.
    CALL FUNCTION 'SCMS_BINARY_TO_STRING'
    EXPORTING
    input_length = lv_length
    mimetype = 'text/plain; charset=utf-8'
    IMPORTING
    text_buffer = lv_datas_string
    output_length = lv_data_len
    TABLES
    binary_tab = itab.
    Can you give me some advice?
    Many thanks in advance.
    Best Regards,

    You have already posted this same question several times (and some very similiar questions) within the forum.  Please do NOT multiple post your questions. This is against the forum rules of engagement. SAP employee or not, you will find yourself banned from the forums if you don't follow the rules.

  • String to XML conversion without fatal error?

    Can one of you tell me how to convert the folowing string to XML without fatal error?
    String s1 = "<?xml version="1.0" encoding="UTF-6.0"?> <Main> <sub> 12345 </sub> </Main>".

    First, you can't have double quotes (") in a string like that, you need to do (\") instead. If you wrote the below line and saved the file as a file_name.xml It should work fine.
    import java.io.*;
    public class yourclass{
         public static void writeXML(){
              try{
                   File xmlOut = new File("file_name.xml");
                   BufferedWriter xmlWriter = new BufferedWriter(new FileWriter(xmlOut));
                   String s1 = "<?xml version=\"1.0\" encoding=\"UTF-6.0\"?> <Main> <sub> 12345 </sub> </Main>";
                   // you can concatenate the strings using a + 
                   // the \n will create a new line in the file
                   String s2 = "<?xml version=\"1.0\" encoding=\"UTF-6.0\"?>" + "\n" +  "<Main> <sub> 12345 </sub> </Main>";
                   xmlWriter.write(s1);
                   xmlWriter.close();
              }catch(Exception ex){
                   ex.printStackTrace();
    }There are a few other ways to do this, the one above is sloppy. One is XStream to convert xml to Java objects and back again. http://xstream.codehaus.org/tutorial.html

  • How to change the encoding value in jdom?

    When I create a new xml file by using jdom, the encoding value of xml is "UTF-8"
    (<?xml version="1.0" encoding="UTF-8"?>).
    How can I change encoding value to "big5"??
    Thanks

    Use this method (JDom API)
    XMLOutputter.setEncoding(java.lang.String encoding)
    Regards,
    Darren

  • Encoded String

    Hi all
    I'm having problems with decoding an encoded String. The String i have looks like this:
    =?ISO-8859-1?Q?F=E4lt=F6m?=
    The code I use to try and decode the string looks like this:
    fileName = fileName.substring(fileName.indexOf("=?") + 2, fileName.lastIndexOf("?="));
    StringTokenizer st = new StringTokenizer(fileName, "?");
    String encodingType = st.nextToken();
    System.out.println("Encoding type: " + encodingType);
    String type = st.nextToken();
    System.out.println("Type: " + type);
    String name = st.nextToken();
    System.out.println("Name: " + name);
    try {
      String newFileName = new String(name.getBytes(encodingType), encodingType);
      System.out.println("New filename: " + newFileName);
    } catch (Exception ex) {
      ex.printStackTrace();
    }The output is:
    Encoding type: ISO-8859-1
    Type: Q
    Name: F=E4lt=F6m
    New filename: F=E4lt=F6m
    What's wrong with my way of decoding the String?
    Thanks
    Tobias

    This encoding is called "quoted printable". Writing a decoder for it is not hard -- the thing after the = sign is the two character hex code of the actual character -- but there is no built in support for it in J2SE (as there isn't out-of-the-box support for Base64 either).
    There is support for it in the JavaMail-extension package though, by the class javax.mail.internet.MimeUtility. You must be doing something related to email anyway, so I would recommend having a look at it.
    http://java.sun.com/products/javamail/
    Quoted printable is defined at least in section 6.7 of RFC 2045:
    http://faqs.org/rfcs/rfc2045.html

  • How to convert xml String to xml file?

    Hi,
    I got a method that do the following:
    public static String convertXmlToString(String xmlFileName) throws Exception
            File file = new File(xmlFileName);
            FileInputStream insr = new FileInputStream(file);
            byte[] fileBuffer = new byte[(int)file.length()];
            insr.read(fileBuffer);
            insr.close();
            return new String(fileBuffer);
         }The return String is the contents of an existing xml file and one example is shown below:
    <object type="server.WOXReference" id="0"><field name="actualPathObj"><object type="java.lang.String" id="1">C:\restClient\actualXMLObjects\812856084.xml</object></field><field name="object"><object type="server.WOXConstructor" id="2"><field name="className"><object type="java.lang.String" id="3">rec.SimpleRecognizer</object></field><field name="types"><array type="java.lang.String" length="3" id="4"><object type="java.lang.String" id="5">double[].class</object><object type="java.lang.String" id="6">double.class</object><object idref="6" /></array></field><field name="args"><array type="java.lang.Object" length="3" id="7"><array type="double" length="5" id="8">22.33 33.22 33.33 22.0 11.0</array><object type="java.lang.Double" id="9">2.2</object><object type="java.lang.Double" id="10">3.3</object></array></field><field name="retType"><object type="java.lang.String" id="11">act</object></field></object></field></object>
    and I want to change the above string to xml file like below:
    <object type="server.WOXReference" id="0"><field name="actualPathObj"><object type="java.lang.String" id="1">C:\restClient\actualXMLObjects\812856084.xml</object></field><field name="object"><object type="server.WOXConstructor" id="2"><field name="className"><object type="java.lang.String" id="3">rec.SimpleRecognizer</object></field><field name="types"><array type="java.lang.String" length="3" id="4"><object type="java.lang.String" id="5">double[].class</object><object type="java.lang.String" id="6">double.class</object><object idref="6" /></array></field><field name="args"><array type="java.lang.Object" length="3" id="7"><array type="double" length="5" id="8">22.33 33.22 33.33 22.0 11.0</array><object type="java.lang.Double" id="9">2.2</object><object type="java.lang.Double" id="10">3.3</object></array></field><field name="retType"><object type="java.lang.String" id="11">act</object></field></object></field></object>How to I change the above xml String back to xml file again? The appropriate tags must be taken care of like > must be > and < must be <.
    Please advice and can give me some sample code.
    Thanks.

    By writing some code that runs through the file and adds a new line for a new element using these methods here...
    http://java.sun.com/j2se/1.4.2/docs/api/org/xml/sax/ContentHandler.html
    i.e.
    startDocument()
    startElement(String namespaceURI, String localName, String qName, Attributes atts)
    endDocument()

  • How to change the Encoding type of a XML

    Hi all,
    I'm having a XML(generated at run time) with UTF-8 Encoding. If I'm going to parse it, getting an error saying "*Document root element is missing*".
    If I change the encoding to ANSI, it parses without error.
    How can I change the encoding type of a documnet ?
    Any comment welcome.
    Kaushalya

    There's no such thing as the "encoding of a String". If you produced a String from a sequence of bytes using the wrong encoding, you may not be able to repair that problem by hacking about in your code. You're better off to produce the String using the correct encoding in the first place. Read this for more information about XML and encodings as you appear to be misunderstanding basic concepts:
    [http://skew.org/xml/tutorial/]

  • Message Mapping Problem with UTF-16LE Encoded XML

    Hello,
    we have the following scenario:
    IDoc > BPM > HTTP Sync Call > BPM > IDoc
    Resonse message of the HTTP call is a XML file with UTF-16LE processing instruction. This response should then be mapped to a SYSTAT IDoc. However the message mapping fails "...XML Parser: No data allowed here ...".
    So obviously the XML is not considered as well-formed.
    When taking a look at SXMB_MONI the following message appears: "Switch from current encoding to specific encoding not supported.....".
    Strange thing however is if I save the response file as XML and use the same XML file in the test tab message mapping is executed successfully.
    I also tried to use a Java Mapping to switch encodings before executing message mapping, but the error remains.
    Could the problem be, that the codepage UTF-16LE is not installed on the PI system ? Any idea on that ?
    Thank you!
    Edited by: Florian Guppenberger on Feb 2, 2010 2:29 PM
    Edited by: Florian Guppenberger on Feb 2, 2010 2:29 PM

    Hi,
    thank your for your answer.
    This is what I have tried to achieve. I apply the java conversion mapping when receiving the response message - i tried to convert the response to UTF-16, UTF-8 but none of them has helped to solve the problem.
    I guess that using adapter modules is not an option either as it would modify the request message, but not the response, right?

Maybe you are looking for

  • How to generate an Letter in PDF format.. (APEX  4.0)

    Hi All, I want to generate a report in Letter format .. the output format is PDF. For example consider EMP table .. from this im going to query and show the columns of EMP_NAME , ADDRESS, SALARY,DESIGNATION And in this report i ll be have an check bo

  • Site not appearing correctly on browser or on iPhone

    Hi everyone, I have a site - http://www.amsivertson.com - if you go to the "photography" page, you'll see my problem. (tested in current versions of Firefox & Safari and on iPhone 3G) 1.The text on the site can't be selected in order to copy/paste 2.

  • Is there a way to recover corrupted psd. files?

    I recently transferred all my work from a work computer to my mac at home. i am unable to access my work computer until October as we are having a 'break'. However, I have a deadline for September 15th and I need all my files. Some older files open p

  • Itunes update issue restarted computer now cannot start itunes

    Prompted to download latest itunes version, I did this and restarted computer and now cannot restart itunes message "itunes cannot run because some of its required files are missing. Please reinstall." Do I have any options except reinstall will I lo

  • SoftKeyboardBehavior not panning on Android

    Hello all, I've been scratching my head with this for a while now and think I need to ask for help. I have a TextField which is set to TextFieldType.INPUT. On Apple devices, when a user clicks on this text field, it focuses in on the text field like