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.

Similar Messages

  • XSL mapping of ARTMAS IDoc - carriage returns and white space

    Hi all. I have tried all sorts here and am completely stuck. I am mapping an article master ARTMAS IDoc using XSL mapping and an extra carriage return and white space characters are being added to the FIELD1 and FIELD2 fields of the E1BPE1MARAEXTRT segment and I don't know why! These fields contain all our bespoke field values joined together so they are 229 and 250 characters long respectively, which I think is related to the problem. The mapping program looks like this:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="yes"/>
    <xsl:template match="/">
    <ARTMAS04>
    <IDOC>
      <xsl:copy-of select="//ARTMAS04/IDOC/EDI_DC40"/>
      <xsl:copy-of select="//ARTMAS04/IDOC/E1BPE1MATHEAD"/>
      <xsl:copy-of select="//ARTMAS04/IDOC/E1BPE1MARART"/>
      <xsl:copy-of select="//ARTMAS04/IDOC/E1BPE1MARAEXTRT"/>
      <xsl:copy-of select="//ARTMAS04/IDOC/E1BPE1MAKTRT"/>
      <xsl:for-each select="//ARTMAS04/IDOC/E1BPE1MARCRT">
        <xsl:if test="(PLANT='D100') or (PLANT='D200') or (PLANT='D300')">
          <xsl:copy-of select="."/>
        </xsl:if>
      </xsl:for-each>
      <xsl:copy-of select="//ARTMAS04/IDOC/E1BPE1MARMRT"/>
      <xsl:copy-of select="//ARTMAS04/IDOC/E1BPE1MEANRT"/>
    </IDOC>
    </ARTMAS04>
    </xsl:template>
    </xsl:stylesheet>
    I have a test IDoc going through this and the first 3 characters of the FIELD1 are "BIK". If I look at the source of the XML file, the problem area looks like this:
    <E1BPE1MARAEXTRT SEGMENT="1">
          <FUNCTION>004</FUNCTION>
          <MATERIAL>000000000000895649</MATERIAL>
          <b><FIELD1>
            BIK</b>      0  0.00 T                                    000000001CARRERA FURY 04 20"     CARRERA FURY 04 20" 2005092420040622    X                    00000000   20031104 00200406140000000000                    0.00 0000000
          </FIELD1>
    You can't really see it above, but there is a carriage return and 8 white spaces before the BIK. Where does this carriage return and white space come from?! Any help would be really appreciated - this is driving me crazy!
    Many thanks,
    Stuart Richards

    Stuart,
    I think I know the cause to your problem. I am not an XSLT programmer but based on searching this forum I found how I can acheive the carriage return at the end of my document. Your xsl statement is as follows:
    <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="yes"/>
    Change the indent value from yes to no. This should remove the carraige return. Hope this works for you.
    I actually need a carriage return and line feed on my document so I am still stuck. All I have acheived is the carraige return.
    Thanks,
    Jim

  • How to find a carriage return and Line feed?

    I need to detect if a crriage retunr and line feed present on each row in my text file before allowing user to upload the text file
    I know how to remove them from each line but what I need is to detect them no removing them from file.
    Our concern is when the a row does not have carriage return and line feed.
    Is there a way to find this using CF? Please help
    thanks

    That is exactly the problem Dave, if some rows do not have line feed, they're not being inserted into DB, it skips other steps and go right to finish. It looks
    like the file is done processing.
    So I need to do early rejection to this kind of file.
    I used cfloop to catch anything else that do not follow the formatting rules.
    Here is what I already done:
    Right after the file got uploaded, I have these codes:   
    <cfloop  index="x" file="#MyFile#" >
      <CFSETMyLine = Replace(x,chr(9),"|", "ALL")>
      I'm using a few functions, such as, Left(), Mid(), Right(), etc to make sure certain rules are followed.
      Up till here, it's done and tested, everything is working.
      The only problem is when 1 or more rows don't end up with line feed and or carriage return.
      I plan to add some codes to check the end of each row for chr(10) since it is looping for every row anyway.
      If detected, process file normally otherwise stop processing.
    </cfloop>
    So this can't be done in CF?

  • File sender  - carriage return and new line as endseparator

    Hi All,
    I'm stumbled with a problem to set carriage return and newline character as the endseparator (record delimiter)
    Scenario: The input file PI is receiving has got few fields which has text in it and the content in this text has got newline characters. So to identify record separator, at  the end of each record the combination of carriage return and new line is added.
    In file sender content conversion I've set the folllowing parameters to achieve this:
    Row.fieldSeparator :   ,  (comma)
    Row.endSeparator  :  '0x0D''0x0A'
    Problem: In my sample input file, the first row has a text field with a newline character. When executed PI is splitting the record at the newline character in the text field (instead of combination of carriagereturn and newline which is set in the endSeparator paramter).
    Pls advice on how to resolve this .
    Happy Holidays!!
    amar

    Rajesh..Thanks for your quick response
    I'm trying with the actual file being provided by the trading partner. I did not generate the file nor changed the file..
    Before identifying the combination of carraige return and new line, the adapter is splitting the record when encountered with new line character within one of the text fields.
    As you said it worked for you, you do have new line characters within fields in a record?..pls throw some light..let me know for any information..
    Thank you
    amar--

  • How to retain carriage return and spaces in a report..

    Hi everyone,
    I have a TEXT AREA where users enter comments in that like
    First record
    Hi           Carriage returns          spaces
    Second  record
    Hi
    carriage returns
    spaces
    Third record
    Hi
         carriage returns
                                 spaces
    Is it possible to retain the carriage returns and spaces when i am displaying the records in a report.
    For carriage returns i replaced  chr(10) with '
    (without the single quotes). I works fine. But how i can i retain the spacesplease give me some suggestions
    Thanks
    phani

    Hi dimitri,
    Thanks for the reply
    For carriage returns i am doing like this replace(column_name,chr(10),'<"br">') (Ignore the double quotes)
    For spaces is there any ASCII code like chr(10) for carriage returns..
    I mean how to identify Number of spaces in database..
    Thanks
    phani
    Message was edited by:
    phani marella

  • Carriage Returns & Line Feeds in XML documents

    Does anyone know why the PL/SQL XML parser will NOT work with Carriage Returns (0x0D) within the XML document?
    Currently I'm having to strip them out, leaving just the Line Feed (0x0A).
    I only realised this after looking at the family.xml example document.
    T.I.A.
    Geoff

    I forgot to mention that I'm running Oracle 8i on Windows NT.

  • Search for multiple values separated by carriage return and not commas

    I have developed a report in BI Publisher that allows a user to enter multiple values that are separated by commas.
    Is there any way of entering multiple values that are separated by carriage return and not commas?
    Any help would be appreciated.
    Thanks

    Here below, without function :
    SQL> with tbl as
      2  (select 0 c1, 'j' c2 from dual union all
      3   select 1 c1, 'k' c2 from dual union all
      4   select 2 c1, 'l' c2 from dual union all
      5   select 3 c1, 'm' c2 from dual union all
      6   select 4 c1, 'n' c2 from dual )
      7  select *
      8  from   tbl
      9  where   c1 in (select substr(mystring,instr(mystring,',',1,rownum)+1,instr(mystring,',',1,rownum+1)-instr(mystring,',',1,rownum)-1)
    10                 from   (select ','||'&str'||',' mystring from dual)
    11                 connect by  level <= length(mystring)-length(replace(mystring,','))-1);
    Enter value for str: 1,2,3
    old  10:                from   (select ','||'&str'||',' mystring from dual)
    new  10:                from   (select ','||'1,2,3'||',' mystring from dual)
            C1 C
             1 k
             2 l
             3 m
    SQL> /
    Enter value for str: 0
    old  10:                from   (select ','||'&str'||',' mystring from dual)
    new  10:                from   (select ','||'0'||',' mystring from dual)
            C1 C
             0 j
    SQL> Nicolas.

  • XML is cluttered with carriage returns and line feeds - how to suppress?

    Hi all,
    at least within text paragraphs we would prefer 'clean' XML without carriage returns. Can Framemaker be configured to avoid these control character?
    Below is an example of a DITA file produced by Framemaker. Evidently this is related to the Pretty Printing feature and I do admit that it increases the readability. However they cause some issues for us. Note that the carriage returns in the paragraph are at arbitrary positions, not at the end of the lines as they appear in the Framemaker editor (I inserted the word "End" at the end of the first line).
    Robert

    By default, FrameMaker adds a CR at around 70-80 characters unless instructed to do otherwise.
    Also, soft returns (SHIFT+ENTER) are lost unless you're in a pre formatted element like a <codeblock> (which is probably why there's no CR after your "End" text.
    If you want to limit the seemingly arbitrary CRs, you must tell FM where to put them. Add the following rule to the structure application rules file ..
    element "p"
      writer line break is 99999 characters;
    …scott

  • How do i add a newline or carriage return to make my xml file look pretty?

    Hi guys
    I'm writing an xml file with jsp, the problem is, it writes it in one big chunk of text. e.g.
    <start>hello, my name is joe</start><middle>I like trees</middle><end>boo</end>
    Now what I want to do is present this xml file in a decent manner,
    e.g.
    <start>hello my name is joe</start>
    <middle>i like trees</middle>
    <end>boo</end>
    i've tried
    xmlFile = "<start>Hello my name is joe</start>"+\n\r;
    and
    xmlFile ="<start>Hello my name is joe</start>"+"\n\r";
    neither work, can anyone provide me with some insight into how I can add a carriage return / new line to make my xml file look pretty?
    Many thanks for any responses!

    u r right <BR> tag will not work...
    I wrote following code to generate xml file and it works fine...U can try the same...
    try
    FileOutputStream fos = new FileOutputStream("c:\\temp.xml");
    String xmlString = "<root>\n<start>Hello my name is joe</start>"+"\n";
    xmlString = xmlString +"<middle>blah blah</middle>\n</root>";
    fos.write(xmlString.getBytes());
    fos.close();
    fos = null;
    catch(Exception e)
    e.printStackTrace();
    }

  • Storing carriage return and other special characters in a TestStand variable and passing to LabVIEW

    I am using TestStand step to call a LabVIEW VI that writes commands to a serial device.  The device expects a carriage return at the end of the command.  I can create a constant string in TestStand with the carriage return, e.g., "ATA\x0D" and pass that to a LabVIEW string control which shows ATA\r and the VI works properly.
    To provide consistency and flexibility in my code, I want to store the terminator character(s) in a TestStand variable.  However, when I try to use an expression to create the command string, i.e. "ATA" + "Locals.Terminator", where Locals.Terminator is set to "\x0D", my LabVIEW VI string control shows "ATA\\x0D" which doesn't work.  And when I try Locals.Terminator set to "\r", the LabVIEW string control shows "ATA\\r" which doesn't work either.
    Is there a way to store special characters in a TestStand variable and pass them to LabVIEW as special characters?  I saw in another post that if you edit the TestStand variable by pressing Cntl-Enter, it will store  the newline \n properly and it can be sent to LabVIEW - that works for me as well for \n.  But  I need to send a carriage return.
    I've attached my test sequence and the corresponding LabVIEW VI with a string control.
    Hans
    Attachments:
    Special Chars.seq ‏27 KB
    String Passing.vi ‏13 KB

    Hi Hans, 
    Thanks for your detailed explanation and examples.  In TestStand, change the String parameter's String Type to Binary String instead of ASCII.  Then it will pass the desired value.
    Cheers,
    David Goldberg
    National Instruments
    Software R&D

  • Carriage Return and Line Feed in Receiver FTP

    Hi,
    what parameter needs to be used in receiver File content conversion to accomodate <CR> and <LF>
    The generated file from XI is CSV format and am now used only this option in the content conversion.
    record.fieldSeparator ,
    I did find something like record.endseparator '0x0D"0x0A' but not sure whether this is right

    If I were creating an output file, it would look something like this (this is off top of head...not from my actual code, so bug removal might be required):
    types: begin of outx,
                line(1024) type c,
             end of outx.
    data: out_file type table of outx.
             out_line type             outx.
    data: p_field(15) type p decimals 0,
             a_field(17).
    constants: gc_tab type x value '09',
                     gc_crlf(2) type x value '0D0A'.  "those are zeroes...
    field-symbols: <fs> type (same as your internal table),
                           <fsx> type any.
    loop at internal table assigning <fs>.
       if <fs> is assigned.
          do.
          assign component sy-index of structure <fs> to <fsx>.
        if sy-subrc ne 0.  "end of row encountered...exit do loop
          exit. 
       endif.
    * insert logic to do any data conversions (i to p to a, etc.), like:
    * if sy-index eq <somenumber>.
    * P_field =  <fsx>. " any I field.
    * a_field = p_field.
    * assign a_field to   <fsx> casting type char17.
    *endif.
    if sy-index eq 1.
       out_line-line= <fsx>.
    else.
       concatenate out_line-line <fsx> into out_line-line separated by gc_tab.
    endif.
    enddo.
    if outline-line is not initial.
    concatenate outline-line gc_crlf into outline-line.
    condense out_line-line.  "add no-gaps if appropriate
    append out_line to out_file.
    clear out_line.
    endif.
    endif. "is assigned
    endloop."internal table
    Edited by: BreakPoint on Dec 1, 2010 3:39 PM
    can't spell concatenate correctly.

  • Removing the carriage return / Tab during data extraction

    Hi ,
      I have an issue with removing the carriage return / Tab from the extracted (Flat File) data from SAP EKPO table.
      1) While uploading(Long Back) the Legacy data to SAP tables the carriage returns and Tabs in Product description were uploaded to SAP tables.
      2) Now I am extracting data from bkpf,..EKPO.. tables  to a flat file . 
    3) When I extract the data i. PO number, Product description,......
    The Product description is going to 3 to 5 lines depending on the carriage returns and Tabs in the Product description.  Ekpo-txz01
    Ex : Mfg # DS104NA / NET######GEAR DS104 Hub######model
        I want  this product description in one continuous line. It is possible only  by removing the Carriage returns and tabs from product description before concatenating and TRANSFERING the file to Server.
    4) What is  getting:  The line is breaking @gear @ Hub due to Carriage return/Tab
    Mfg  D  NET
    GEAR DS104 Hub
    model   .
    5) What is required is: in one line
    Mfg  D  NETGEAR DS104 model
    In the process I am extracting product description from Ekpo-txz01 . So it is internal table. Now I want to remove the carriage return / Tab .
    How these can be removed.
    Thanks,
    Vasu

    Dear Vasu,
    Sometimes there is a problem that cannot be solved normally. This is one of them.
    The reason why the mentioned methods do not work is because you need to remove actually two characters CR and LF in one stroke. You can identify one but then not the other. So approach it from the other side.
    Simply define what your correct characters might be AND only use them to export.
    Below you will find a FORM routine that does just that (only passes defined valid characters and NOT others).
    FORM validate_field USING    VALUE(field_in)
                        CHANGING field_out.
    CONSTANTS:
    All low caps characters
      validlow(26)  TYPE c VALUE 'abcdefghijklmnopqrstuvwxyz',
    All upper caps characters and all figures
      validhigh(36) TYPE c VALUE '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
    All other characters (starting with space)
      validrest(32) TYPE c VALUE ' <,>.?/:;"{[}]|\~`!@#$%^&*()_-+=',
    Single quote
      validquote           VALUE ''''.
      DATA:
        pos(1) TYPE c,         " Container to hold 1 character
        l      TYPE i,         " Length
        i      TYPE i.         " Indexer
    Determine length
      l = STRLEN( field_in ).
    Stripping loop
      WHILE i LT l.
      Get one character 
        pos = field_in+i(1).
      Check its validity
        IF pos CO validlow
        OR pos CO validhigh
        OR pos CO validrest
        OR pos EQ validquote.
        When valid, use it
          concatenate field_out
                      pos
                 into field_out.
        ENDIF.
      ENDWHILE.
    ENDFORM.
    Hopes this helps solving your problem.
    Regards,
    Rob.

  • Outputting XML carriage return in HTML via XSLT

    Hi,
    I have a scenario where I execute a View Object query in ADF to retrieve results from a particular table in the Database. I then iterate through the results in my Java managed bean and manually construct an XML file with all the appropriate tags. I then pass the XML file through a Transformer class in the Java bean based on an XSLT I have created to produce an HTML page. However I have an issue when it comes to handling carriage returns. One of the database table columns can contain carriage returns within its value but in the final HTML page the carriage returns don't have any effect and the text just displays on one line.
    In the database, the values are stored with the carriage return and in SQL Developer, Toad etc this can be seen e.g. Text1 Text2 Text3 Text4 will display on separate lines. In the XML, the carriage return seems to still be there as when I open the file my element which contains the carriage returns shows each part on a new line e.g. <textElement>Text1
                                                           Text2
                                                           Text3
                                                           Text4</textElement>     (The Text2, Text3 and Text4 all start on a new line at the beginning and there's no prior white space as shown in this post)
    The XML file in JDeveloper also shows carriage return arrow symbols where there is one.
    The HTML page just shows them as Text1 Text2 Text3 Text4 all on one line. Inspecting the source of the HTML shows that the carriage return is in fact there as it also displays as per the XML with the values on separate lines.
    Outputting the value from the View Object in Java to the log shows the value coming out like this - Text1 Text2Text3Text4, which is strange but I know the carriage returns are there so I'm not too fussed about this.
    I have tried escaping the characters in the Java by doing str.replaceAll("[\\r\\n]", ""); (but replacing the "" with &#xD; &#xA; or &x0A;) so in the XML it replaces carriage returns and line feeds with these escaped characters. However, when the XSLT parses the XML it doesn't pick these up and instead actually outputs these actual characters as they are e.g. Text1&x0A;Text2&x0A;Text3&x0A;Text4
    So I can confirm that the carriage return is carrying all the way through to the XSL but I can't help but think that maybe I need to do something in the XSL to process this somehow, e.g. doing the equivalent of the 'replace' in Java but I don't know what I need to search for in the XML and also what to actually replace it with..Do I just replace it with a </BR> in HTML?
    We also parse the XML using PDF and Excel XSL Transformer class and see the same results.
    Any help would be appreciated.
    Thanks

    That's a very commonly asked question.
    HTML doesn't preserve linefeeds, except for the <pre> tag.
    You'll have to replace those characters with <BR/> tags in the XSLT.
    Search the Internet for terms like "XSLT HTML LF", you'll find some XSLT sample templates to handle the replacement.

  • Read Only TextAreas with Carriage Return, Line Breaks and Word Wrapping

    Hi all,
    I know there are a few posts around this subject but I cannot find the answer to the exact problem I have.
    I have a page that has a 'TextArea with Character Counter' (4000 Chars) that is conditionally read only based on the users credentials (using the 'Read Only' attributes of the TextArea item).
    When the field is editable (not Read Only) everything works fine but when I make the field Read Only I start to have problems:
    The first problem is that the Carriage Return and Line Breaks are ignored and the text becomes one continuos block. I have managed to fix this by adding pre and post element text of pre and /pre tags. This has made the Carriage Return and Line Breaks word nicely and dispaly correctly.
    However, it has introduced a second problem. Long lines, with no Carriage Returns or Line Breaks, now extend to the far right of the page with no word wrapping, making my page potentially 4000+ characters wide.
    How can I get the field to be display only, with recognised Carriage Returns and Line Breaks, and Word Wrapping inside a fixed width of, say, 150 characters?
    Many thanks,
    Martin

    Hi,
    Just a cut and paste of yours with the field name changed:
    htp.p('<script>');
    htp.p('$x("P3_COMMENTS").readonly=true;');
    htp.p('</script>');I also have the following in the page HTML Header, could they be conflicting?
    <script type="text/javascript" language="JavaScript">
    function setReleaseToProd(wpTypeCode){
       //setReleaseToProd($v(this))
      var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=set_release_to_prod',0);
      get.addParam('x01',wpTypeCode);
      gReturn = get.get();
      if(gReturn) {
         $s('P3_RELEASE_TO_PROD',gReturn);
      get = null;
    </script>I am a long way from knowing much about Javascript (this page code was written by someone else) so all help is much appreciated.
    Martin

  • 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

Maybe you are looking for