Carriage return symbol is removed from XML

Hello,
It looks like SQL Server removes \r characters when parsing XML. So when my stored procedure receives values in xml for saving, all line breaks are represented as \n instead of \r\n.
Is there any way I can force SQL Server not to remove \r characters? In the sample below Node1 value doesn't contain \r symbols.
DECLARE @hDoc int
DECLARE @Xml nvarchar(MAX)
SET @Xml = N'<Root><Node1><![CDATA[' + nchar(13) + nchar(10) + N'Some ' + nchar(13) + nchar(10) + N' Value]]></Node1></Root>'
EXEC sp_xml_preparedocument @hDoc OUTPUT, @Xml
SELECT
Node1
,convert(varbinary(max),Node1) -- Contains 0A00 in the start instead of 0D0A,
,charindex(nchar(13),Node1)
FROM
OPENXML(@hDoc, N'/Root', 2) WITH (Node1 NVARCHAR(MAX))
EXEC sp_xml_removedocument @hDoc
Thank you

Hi dalong,
The scenario you pointed is the behavior of the XML processor by default. If any characters with CARRIAGE RETURN (#xD), whenever CARRIAGE RETURN (#xD) is followed by LINE FEED (#xA) or not, will be translate to a single #xA character, to normalize all line
breaks in external parsed entities on input before parsing.
In this case, you may have a try to make use of REPLACE function in the SELECT statement to replace “nchar(10)” to “nchar(13)+nchar(10)”.
Best Regards,
Stephanie Lv
If you have feedback for TechNet Subscriber Support, contact
[email protected]
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Similar Messages

  • Carriage Return/Linefeed Character Removal  for a CLOB variable

    Hi,
    Can anyone let me know how I can remove the carriage return from a CLOB variable.
    I tried the replace function
    REPLACE(D_MessageText, CHR(10)), it doesn't give any error,but the output still has the new line character.
    Any help would be really appreciated.
    Regards,
    Anil.

    chr(10) takes care of LINEFEED
    chr(13) takes care of CARRIAGE RETURN

  • HT4859 how can the itunes symbol & usb cable symbol be removed from screen as phone not working

    how can i remove the itunes&usb symbol from the screen , seems to be stuck at this point?

    You need to Restore...
    Connect to iTunes on the computer you usually Sync with and “ Restore “...
    http://support.apple.com/kb/HT1414
    If necessary Place the Device into Recovery mode...
    http://support.apple.com/kb/HT1808

  • Quotation marks removed from XML formatting

    See http://forums.adobe.com/message/4035539#4035539
    The original data was
    <?xml version="1.0" encoding="utf-8" ?>
    <application xmlns="http://ns.adobe.com/air/application/3.1">
        <id>examples.html.HelloWorld</id>
        <versionNumber>0.3</versionNumber>
        <filename>HelloWorld</filename>
        <initialWindow>
            <content>HelloWorld.html</content>
            <visible>true</visible>
            <width>400</width>
            <height>200</height>
        </initialWindow>
        <icon>
            <image16x16>"-C C:/Program Files (x86)/Adobe/AIRSDK/samples/icons/."</image16x16>
            <image32x32>"-C C:/Program Files (x86)/Adobe/AIRSDK/samples/icons/."</image32x32>
            <image48x48>"-C C:/Program Files (x86)/Adobe/AIRSDK/samples/icons/."</image48x48>
            <image128x128>"-C C:/Program Files (x86)/Adobe/AIRSDK/samples/icons/."</image128x128>
        </icon>
    </application>
    but posting it as XML formatting removed the apostrophes (in the <icon> section).  Not very good if you want to show how you've done something, or instruct another user how to do it...
    Message was edited by: ʇɐb ɹəuəllıʍ - edited multiple times because of "unexpected error has occurred".

    apostrophes = '
    Quotes = "
    Colon = :
    Semicolon = ;
    Comma = ,
    Period = .

  • Carriage Return/Linefeed Character Removal

    I'd like to remove CarriageReturn/Linefeed characters from varchar2 field data whenever I query that field. I was thinking of using the TRANSLATE function to do it, but I cannot figure out how to make SQL recognize that character. I've copied and pasted it from a SQL Plus query, but when I drop that character into my SQL code to TRANSLATE, SQL Plus jumps to the next line. I've tried enclosing that character in single quotes, but that did not work. Is there anyway to have the TRANSLATE function recognize this non-printing character, search for it, and replace it?

    SQL> insert into ttest values ('a','Hi'||chr(10)||'World');
    1 row created.
    SQL> select * from ttest where col1='a';
    COL COL2
    a Hi
    World
    SQL> select * from ttest where translate(col2,chr(10),' ') like 'Hi Wo%';
    COL COL2
    a Hi
    World

  • How can I stop emails. From returning after there removed from trash?

    How can I stop emails from returning after deleted and also deleted from trash?

    Aside from force-quitting the Finder, I've never seen anything that allows for getting rid of the delay.

  • Carriage Returns and Tabs in XML element

    I have a number of carriage returns and tabs within an xml element. When I take that element I would like it to transform to html in which I am then displaying within a JEditorPane. However, when I do this it is one long string. I have tried the xml:space="preserve" within that element and this still is not working.
    Here is part of the xml with the carriage return line feeds. The element that I am talking about is called pseudocode. You can see it is displayed correctly below.
    Design Document XML : <?xml version="1.0" encoding="ISO-8859-1"?><design-doc><title-page><title>Testing Document</title><class-prepared-for>Lloyd</class-prepared-for><authors>Ben Garbers</authors><date-created>September 23, 2004</date-created></title-page><introduction text="This is the introduction. This is the introduction."/><class-definitions><class-definition class-name="ClassOne" visibility="public" class-complexity="not complex"><global-variables><variable visibility="public" name="VariableOne" object="String" comments="This is a String."/><variable visibility="public" name="VariableTwo" object="Integer" comments="This is an Integer."/></global-variables><methods><method name="MethodOne" synopsis="This will do some things." purpose="public" visibility="public"><input-parms><variable visibility="null" name="firstName" object="String" comments="null"/></input-parms><output-parms><variable visibility="null" name="lastName" object="String" comments="null"/></output-parms><local-variables><variable visibility="null" name="age" object="int" comments="null"/></local-variables><pseudocode xml:space="preserve">/* Ensure that player name exist in the system*/
    if (player =null)
         NullPlayerException;
              if (NOT (isPlayerNameExist(player)))
                   throw PlayerNameNotExistException;
              /* Ensure player name exist in the team already*/
              i ? 1;
              while (i <= length(mPlayers)) {
                   if (mPlayers.mPlayerName != playerName)
                        throw PlayerNameNotExistInTeamException;
    this.mPlayers ? this.mPlayers - player;</pseudocode>
    However, when I do the transformation I get the following with the pseudocode:
    /* Ensure that player name exist in the system*/if (player =null)     NullPlayerException;          if (NOT (isPlayerNameExist(player)))               throw PlayerNameNotExistException;          /* Ensure player name exist in the team already*/          i ? 1;          while (i <= length(mPlayers)) {               if (mPlayers[i].mPlayerName != playerName)                    throw PlayerNameNotExistInTeamException;}this.mPlayers ? this.mPlayers - player;
    It looks like it adds some spaces but no carriage returns or line feeds.
    My transformation code is the following:
         public ParseFile(String xmlString) {
              try {
              //Here we will load the correct style sheet for the message
              //that will be formatted.
              String urlString = "DesignDocument.xsl";
              URL url = this.getClass().getResource(urlString);
              System.out.println("URL to style sheet = " + url.toString());
              String styleSheetName = url.getFile();
              System.out.println("Style sheet name : " + styleSheetName);
              InputStream styleSheetInputStream = this.getClass().getResourceAsStream(urlString);
              //We will than load our SAXParerFactory and parse the message.
              SAXParserFactory SPFactory = SAXParserFactory.newInstance();
              SPFactory.setValidating(true);
              SAXParser sp = SPFactory.newSAXParser();
              XMLReader sax2parser = sp.getXMLReader();
              //NO Validation done on for this because we do NOT have a DTD.
              sax2parser.setFeature(
                   "http://xml.org/sax/features/validation",
                   false);
              sax2parser.setContentHandler(new FileContentHandler());
              //we create a character array of the length of the xml message String
              char[] messageCharacterArray =
                   new char[xmlString.length()];
              // we then put the xml string into the character array.
              messageCharacterArray = xmlString.toCharArray();
              // after this ew end up creating a CharArrayReader that will be used by the Sax
              // parser to parse the xml.
              CharArrayReader xmlCharArrayReader =
                   new CharArrayReader(messageCharacterArray);
              // we put the xml character array within the Input Source which will then be parsed
              // by the Sax2 parser.
              InputSource in = new InputSource(xmlCharArrayReader);
              // Use a Transformer for outputting the message into our formatted xml using
              // the stylesheet defined up in a messages own sxl stylesheet file.
              TransformerFactory tFactory = TransformerFactory.newInstance();
              tFactory.setURIResolver(new BasicURIResolver());
              StreamSource stylesource = new StreamSource(styleSheetInputStream);
              Transformer transformer = tFactory.newTransformer(stylesource);
    //          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    //          transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    //          Properties properties = new Properties();
    //          properties.setProperty("indent", "yes");
    //          properties.setProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    //          transformer.setOutputProperties(properties);
              // We will use a ByteArrayOutputStream to put our transformed xml.
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              StreamResult result = new StreamResult(bos);
              SAXSource source = new SAXSource(in);
              transformer.transform(source, result);
              String s = bos.toString();
              StringBuffer sb = new StringBuffer();
              //This will make sure the Version Line is not shown.
              BufferedReader br = new BufferedReader(new StringReader(s));
              String line = "";
              while ((line = br.readLine()) != null) {
                        sb.append(line);
              bos.close();
              br.close();
              formattedXmlString = sb.toString();
              System.out.println("--------------------------------");
              System.out.println(formattedXmlString);
              System.out.println("--------------------------------");
              } catch (Exception e) {
                   e.printStackTrace();
    I have been searching and trying to figure this out forever. Any help would be greatly appreciated. Bottom line is that I want carriage returns and tabs to work when transferring from the xml to xsl.

    I get the following line when adding the <pre> tags.
    /* Ensure that player name exist in the system*/if (player =null)     NullPlayerException;          if (NOT (isPlayerNameExist(player)))               throw PlayerNameNotExistException;          /* Ensure player name exist in the team already*/          i ? 1;          while (i <= length(mPlayers)) {               if (mPlayers[i].mPlayerName != playerName)                    throw PlayerNameNotExistInTeamException;}this.mPlayers ? this.mPlayers - player;
    On the screen this is shown on 1 line. It looks like the tabs are working correctly. However, the carriage return, line feeds do not seem to be working. The xml that is pushed into the transformation has the carriage returns and line feeds and is formatted correctly. There has to be something happening when the xsl takes the xml String. When I add <BR></BR> within the xml that doesn't seem to work either.
    I am really sumpted. If you could help DrClap I would really be appreciated.

  • Removing new lines and carriage returns

    Hi,
    SO I am new to regular expressions in java and I want to remove all the new lines and carriage returns from some text, and change them into <p>
    I have tried,
    Pattern pat = Pattern.compile("\n");
    Matcher mat = pat.matcher(text);
    StringBuffer sb = new StringBuffer();
    boolean result = mat.find();
    while (result){
    mat.appendReplacement(sb,"<p>");
    result = mat.find();
    mat.appendTail(sb);
    text=sb.toString();
    But it seems to have no effect. Anyone know what I'm doing wrong?
    Cheers
    Sandra

    Hello, i've got the same problem. I want to replace "carriage return" and "new line" from an text file. and i use the replace all function for a String object. The problem is, if i call the replace function like this:
    row = row.replaceAll ("\\r", "<p>");
    The "carriage return" is replaced, but not with the "<p>" characters, only with nothing.
    Lines from my original textfile:
    This is an example.
    I want to replace.
    After replacing with the function call row = row.replaceAll ("\\r", "<p>");
    This is an example.I want to replace.
    What is wrong. If i insert tab spaces and replace them, everything is fine. it is abug in my Java Version?
    I use j2re1.4.2_05
    I hope, anybody can help me

  • Receiver File channel for XML files: with carriage return

    Hi all,
    we are using a receiver FILE channel to generate an XML file that is sent to an external partner.
    The XML file looks good in a parser (IExplorer). But in fact there are not carriage return / line feeds between the XML tags
    of the XML payload in the file.
    Our partner now requires the XML file in a more vertical structure which means: for every tag a separate line (like it is displayed in a parser)
    Does anybody know a more general way to convert to a vertical XML structure (so with carriage return line feed).
    There is one entry in the SDN dealing with this topic but suggesting using an UDF. I think this is a very specific way.
    I don't think it is a good way to change/enhance the message mapping just because of a general formating change.
    Is it better to use an XSLT mapping as a second step in the interface mapping or a JAVA adapter module to convert ?
    any experiences? suggestions? examples?
    Thank you very much
    best regards
    Hans
    examples:
    original by XI receiver FILE adapter
    <?xml version="1.0" encoding="UTF-8"?>
    <MT_batchStatus><type>BS</type><header><message><messageSender>SENDER</messageSender><messageDate>20090723143720</messageDate> ... and so on
    required:
    <?xml version="1.0" encoding="UTF-8"?>
    <MT_batchStatus>
    <type>BS</type>
    <header>
    <message>
    <messageSender>SENDER</messageSender>
    <messageDate>20090723143720</messageDate>
    ... and so on

    >
    Hans Georg Walter wrote:
    > Is it better to use an XSLT mapping as a second step in the interface mapping or a JAVA adapter module to convert ?
    > any experiences? suggestions? examples?
    In such a case, the best is to write an generic XSLT or Java mapping that will attempt to do the pretty printing/formatting of the xml.
    The advantage of a generic one is that you can reuse the same class/jar for many other scenarios.
    so the flow will be as below in your interface mapping;
    1. your specific source to target mapping
    2. the generic formatting class

  • Carriage returns in RTF export

    Hello, one of my clients is complaining that RTF output has carriage returns at the end of each line, making him unable to copy and paste the text somewhere else and continue to work with it further. Can this be turned off and what options are available here? Thanks.
    Here's sample output. This was a free-flowing paragraph in the database.
    All matters listed hereunder constitute a Consent Agenda, are considered to be routine by the Board of
    Supervisors and will be acted upon by a single roll call vote of the Board. There will be no separate
    discussion of these items unless a member of the Board so requests, in which event the matter shall be
    removed from the Consent Agenda and considered as a separate item.
    \cf1\i All matters listed hereunder constitute a Consent Agenda, are considered to be routine by the Board of \par\pard\sl-231\i0\cf0\tx637     \cf1\i Supervisors and will be acted upon by a single roll call vote of the Board. There will be no separate \par\pard\sl-231\i0\cf0\tx637     \cf1\i discussion of these items unless a member of the Board so requests, in which event the matter shall be \par\pard\sl-231\i0\cf0\tx637     \cf1\i removed from the Consent Agenda and considered as a separate item.
    I am using CR 2008 SP3 to troubleshoot this issue.
    Please take a look at this file: http://software1.legistar.com/RTFProblem.zip - It contains the .rpt file with data, the problematic .rtf file with hard returns at the end of each line, and a screenshot of the problem.
    A large project hinges on this one issue. Please help. Thanks.

    This is something CR does to try to keep the report visually similar between formats. I don't know of any setting in CR that will alter this behavior.
    The 2 options are...
    1) Export as a .csv file. csv is a machine readable format that doesn't have any visual formatting.
    2) Remove the carriage returns and line feeds from MS Word. The find & replace (Ctrl + h) can be used. In the "Find what:" window, enter ^p and leave the "Replace with:" blank. This will remove all of the CR & LFs.
    HTH,
    Jason

  • How to use carriage return in formcalc

    I'm sure the answer to this question is simple, but being new to formcalc (and scripting in general) I am having problems with it.
    The details:
    I have a dynamic form in livecycle. The two fields I am having problems with currently are a drop down list, and a text box (not field) associated with it. What is listed in the text box is dependant upon the choice from the dropdown list. So far everything is, functionally, working. I have the formcalc scripting event set to change on the dropdown list with the following script
    if (xfa.event.newText == "Office 1") then
         OfficeAddress1 = "123 Street Road #xD Town City, US 12121 #xD (111) 555-1414"
    endif
    "Office 1" being the dropdown selection
    OfficeAddress1 being the name of the text field
    The fake address being the address, seperated by carriage return symbols (#xD) to indicate where I want it to jump to the next line.
    The script is working fine except that the #xD symbols are showing up on the final form. How do I prevent this?
    Thanks for you assistance.

    Thanks Paul, good advice.
    For anyone that would want to do this in formcalc, the embarrassingly simple way of using a carriage return in the script is... hitting the enter button... no syntax required.
    Don't bother trying to line it up in the scripting screen (my mistake), that only puts more spaces than is necessary and will mess up the text orientation on the final form. Just hit enter and don't worry if it's not lined up, it will be.

  • XI: Remove Carriage Return +Line Feed at end of XML

    Hi All,
    Scenario
    Currently, we have a JMS --> XI --> IDOC scenario. The Sender Service always sends a CRLF (Carriage Return & Line Feed+) without fail at the end of each xml file once this non-sap system finishes its transaction.
    Example
    <STARTOFXML>
    Data------
    </ENDOFXML>CR+LF
    Question
    Is it possible to remove this from XI JMS Sender Adapter? From the receiver Service (JMS) this is possible.
    Cheers!
    Sulaiman

    Why do you want to remove this? Does this lead to errors?
    Regards
    Stefan

  • Remove Carriage Return from a TextEdit field

    Hi All,
    I have a tableview, of which the last field Description, is of type TextEdit. Not only this, when the data was migrated from a legacy system to SAP, either the last field with the value (If Description has value, Description field, else the field before Description) has 2 '##' at the end of it.
    The 2nd # is EQ to
    cl_abap_char_utilities=>newline
    , which I can remove using
    REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>newline IN <fs> WITH ''.
    But the first # is having the Hex Value 0D00, which is EQ to Carriage Return. CR_LF is Carraige Return and Line Feed, but here, I need to remove only CR.
    Can anyone give me the right solution?
    I tried moving this data to a string field and then do a REPLACE All... IN BYTE MODE, but again, it didn't work.
    Thanks and Regards
    Gladson Jacob

    Hi Patrick,
    The program's ending with a Short Dump. The code snippet is as below.
    DATA: it_contract TYPE TABLE OF zbpa_bp_contract,
          xstring_val TYPE x VALUE '0D00',
          value2 TYPE x VALUE '2000',
          string_value TYPE string,
          xstring_value TYPE xstring,
          stringtable TYPE TABLE OF string,
          reply_value TYPE TABLE OF tline.
    FIELD-SYMBOLS <fs> TYPE zbpa_bp_contract.
    SELECT * FROM zbpa_bp_contract
      INTO TABLE it_contract.
    *  WHERE id BETWEEN 2316 AND 2328.
    LOOP AT it_contract ASSIGNING <fs>.
      string_value = <fs>.
      APPEND string_value TO stringtable.
      CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
        TABLES
          text_stream = stringtable
          itf_text    = reply_value.
    ENDLOOP.
    The dump description is as follows
    Error analysis
        At the statment "DESCRIBE" only character-type data objects are supported at the argument position "TEXT_STREAM", but no strings are supported (data types STRING and XSTRING).
        In this particular case, the operand "TEXT_STREAM" has the type "g".
    <b>Please help.</b>
    Thanks in advance.
    Gladson
    Message was edited by:
            Gladson Jacob
    Message was edited by:
            Gladson Jacob

  • Remove carriage returns from a field in an oracle table

    I have a field that is defined as a LONG in my oracle table; the data contained in this field has carriage returns/line feeds (it's free form text); as i'm selecting data from this field, i need the carriage returns removed so that the data from this field all appears on one line.
    I tried using the TRANSLATE function to convert the carriage returns to something else, but that doesn't work.
    Example:
    Select comment from Notes:
    COMMENT
    the applicant called for an appointment;
    an exam was scheduled for 4/1/05 at 9am;
    called applicant to confirm app
    this needs to be extracted as: "the applicant called for an appointment; an exam was scheduled for 4/1/05 at 9am; called applicant to confirm app"
    How can i do this? Can the decode function be used to remove the carriage returns in this field?

    when i used translate its giving correctly,
    SQL> ed
    Wrote file afiedt.buf
    1 select translate('the applicant called for an appointment;
    2 an exam was scheduled for 4/1/05 at 9am;
    3 called applicant to confirm app
    4 this needs to be extracted as: "the applicant called for an appointment; an exam was scheduled
    5 How can i do this? Can the decode function be used to remove the carriage returns in this field
    6* ',' ') from dual
    SQL> /
    TRANSLATE('THEAPPLICANTCALLEDFORANAPPOINTMENT;ANEXAMWASSCHEDULEDFOR4/1/05AT9AM;CALLEDAPPLICANTTOCONF
    the applicant called for an appointment; an exam was scheduled for 4/1/05 at 9am; called applicant t
    SQL> ed
    Wrote file afiedt.buf
    1 select 'the applicant called for an appointment;
    2 an exam was scheduled for 4/1/05 at 9am;
    3 called applicant to confirm app
    4 this needs to be extracted as: "the applicant called for an appointment; an exam was scheduled
    5* How can i do this? Can the decode function be used to remove the carriage returns in this field
    SQL> /
    'THEAPPLICANTCALLEDFORANAPPOINTMENT;ANEXAMWASSCHEDULEDFOR4/1/05AT9AM;CALLEDAPPLICANTTOCONFIRMAPPTHIS
    the applicant called for an appointment;
    an exam was scheduled for 4/1/05 at 9am;
    called applicant to confirm app
    this needs to be extracted as: "the applicant called for an appointment; an exam was scheduled for 4
    How can i do this? Can the decode function be used to remove the carriage returns in this field?
    SQL>

  • Remove Carriage return from string

    I have a free text area on a BSP (a form). When users type continuously in this area the text gets wraped. When the BSP is submitted it generates a sapscript form and the text area is printed on the form, but it has '##' which are placed where the text wrapped round. I would like to remove '##', so tried the following:
    replace all occurrences of '##' in text_area with ' '.
    This did not work as the '##' are not recognised presumably because they are some type of carriage return and not in fact has marks.

    If you dont have access to the class CL_ABAP_CHAR_UTILITIES, do this instead:
    DATA: crlf(2)   TYPE x VALUE '0D0A',
          itab      TYPE TABLE OF string,
          w_input   TYPE string.
       w_input = '<contains the text with the line feed.>'.
       SPLIT w_input AT crlf INTO TABLE itab.
    Regards Michael.

Maybe you are looking for

  • How to read sql from properties file in database control

    Hey Guys, I want to know that how a properties file can be used in bea built-in database control to read SQL. Any help would be greatly appreciated. Thanks, Deepak Kumar Qwest, India

  • Time stamp problem

    Hi Every one,    I have file to upload from application server.        file name is like 'PPRICE'TIMESTAMP'.CSV' from this file name i have to read the TIMESTAMP I can read it like tstamp = file+10(leng of timestamp). now this tsamp is in character f

  • From dw mx 2004 to dw cs4

    Hello, I'm planning to upgrade from dw MX 2004 to CS4. My sites rely on dw MX's Library items. I don't use templates though. Will CS4 work flawlessly with dw MX's library items? Also, does CS4 play well with SourceGear Vault?

  • 1 iweb account, 2 computers.

    So i started my iweb account on my laptop and now i want to work on it from my desktop. i put my domain file on my desktop after transferring through a thumb drive. I tried opening it, but whenever i open iweb it wants to start a new site. What do i

  • HT4236 how to transfer photo from pc to i phone

    I am trying to sent my photo from pc to my i phone 4s through usb cable. i can import the photo from i phone, but cannot push photo from pc to iphone, please help me how to do this