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.

Similar Messages

  • Converting carriage return in HTML spool

    I've written an sql for spooling the result of a Select in HTML format by using "set markup html on spool on head".
    The problem is that when I open the HTML file I no longer find the carriage returns. I mean the carriage returns that were in CLOB field of the table now miss. Could you help me?
    This is the script:
    set pagesize 10000
    set scan off
    set markup html on spool on head ' - '
    column text heading "TEXT"
    spool c:\temp\report.html
    select dbms_lob.substr (t.field, 5000, 1)     text
    from table t;
    spool off;
    exit;
    The "field" contains a long text with carriage returns that aren't in the report.html anymore

    user12180597 wrote:
    I've written an sql for spooling the result of a Select in HTML format by using "set markup html on spool on head".
    The problem is that when I open the HTML file I no longer find the carriage returns. I mean the carriage returns that were in CLOB field of the table now miss. Could you help me?
    This is the script:
    set pagesize 10000
    set scan off
    set markup html on spool on head ' - '
    column text heading "TEXT"
    spool c:\temp\report.html
    select dbms_lob.substr (t.field, 5000, 1)     text
    from table t;
    spool off;
    exit;
    The "field" contains a long text with carriage returns that aren't in the report.html anymoreset preformat to ON:
    set markup html on spool on head ' - ' PRE ON

  • Carriage Returns in HTML Code Creating Extra Spaces Between Elements

    I've looked online all over and can't find the solution to my issue. I've found several pages explaining a similar event, but no solution.
    When placing many divs next to each other, I would like to visually view the code as one div per line: (see image) To get this, I have to use hard returns in my code (this method makes editing a lot easier visually). But doing so adds extra spacing between the divs which turns a 3 column set of thumbnails to 2 colums. I can fix this if I adjust the physical margins between the divs, but this can't be the only fix.
    The other fix is if I place the code back to back to back (see image): This makes the div's behave and appear as they should, but now the code is a visual mess because it's all cluttered.
    What I want is to be able to use as many carriage returns in my code and for browsers to disregard these types of line breaks in the code. So essentially, how can I get away from these extra spaces when using hard returns in code?

    I think that both your pages have a missing </div> at the end somewhere.
    Opps... that happened when I was stripping down the page to create a working example of my issue. I've fixed the missing div and re-uploaded both pages. The problem is still there.
    Change display: inline; to float: left; and add margin: 0 0 4px 4px; (as shown below)
    I had already tried using float, but something else in the code was forcing the columns to 2 instead of 3.
    Have you used "Apply Source Formatting" ?
    I use that religiously. I'm quite anal about visually clean code.
    Well, I just fixed the problem while replying... funny... I removed the margins from the actual img element (.imageThumb img) and placed it on the div which surrounds the img (.imageThumb). I also reapplied the float. Thanks all for the help - it helped me rethink. But I could have sworn I had once placed the margins on .imageThumb before and it didn't work.
    .imageThumb {
        width: 100px;
        height: 75px;
        display: inline;
        float: left;   
        margin: 0px 10px 10px 0px;
        cursor: pointer;
    .imageThumb img {
        /*margin: 0px 10px 10px 0px;*/

  • Replacing carriage return with HTML " br/ "

    All,
    I have a textarea in an HTML page that receives text input from the user. The text is stored in a varchar2 column and then rendered back into the HTML page as static text.
    I'd like to make it easy for the end user and not force them to enter "<br/>" characters (exactly how this forum works) for new lines and paragraphs.
    On the insert trigger for the note text, I'm thinking of using:
    :new.note_text := replace(:old.note_text, chr(0), '<br/>');1) Will this work?
    2) Is this the best way to do this?
    Thanks.

    Yes, I did mean chr(10). So I set up my trigger to include the replace() function on "note_text":
    create or replace trigger "NOTE_INSERT_TGR"
    BEFORE
    insert on "NOTE"
    for each row
    declare
      next_val number(20);
    begin
      select note_id_seq.nextval
        into next_val
        from dual;
      :new.note_id       := next_val;
      :new.note_text     := replace(:old.note_text, chr(10), '<br/>');
      :new.date_created  := sysdate;
      :new.last_modified := sysdate;
    end;
    /but nothing is being inserted into the "note_text" field. In my PL/SQL code block, I'm using the following logic for the insert statement:
      if (:P2_NOTE_TEXT is not null) then
        insert into note(application_id, note_text)
          values(:P2_APPLICATION_ID, :P2_NOTE_TEXT);
      end if;and have even tried placing the replace() function here with no results at all (probably related to some internal processing with HTMLDB).
    When I query my note table, I can verify (null) is being inserted.
    select note_id, note_text
    from note
    returns
    NOTE_ID     NOTE_TEXT
    56     (null)Any ideas why I'm losing the note text?
    Thanks.

  • Check XML file against XSD? Via XSLT?

    Hello,
    we´re using a 6.20 system (XI not available) and want to check XML files against a XML-schema definition file (xsd).
    Is there a function in 6.20 available for this? Is it possible to use "CALL TRANSFORMATION" for it? I´ve seen other XSLT parser in the internet which are able to check a source XML against an XSD before transforming it to the result XML.
    But is this possible with an 6.20 system?
    Thank you for your help,
    best regards,
    Stefan

    Here is the sample XML and the schema.
    XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <book isbn="0836217462">
    <title>
      Being a Dog Is a Full-Time Job
    </title>
    <author>Charles M. Schulz</author>
    <character>
      <name>Snoopy</name>
      <friend-of>Peppermint Patty</friend-of>
      <since>1950-10-04</since>
      <qualification>
        extroverted beagle
      </qualification>
    </character>
    <character>
      <name>Peppermint Patty</name>
      <since>1966-08-22</since>
      <qualification>bold, brash and tomboyish</qualification>
    </character>
    </book>
    XSD:
    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="book">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="title" type="xs:string"/>
            <xs:element name="author" type="xs:string"/>
            <xs:element name="character" minOccurs="0" maxOccurs="unbounded">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="name" type="xs:string"/>
                  <xs:element name="friend-of" type="xs:string" minOccurs="0"
                          maxOccurs="unbounded"/>
                  <xs:element name="since" type="xs:date"/>
                  <xs:element name="qualification" type="xs:string"/>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
          <xs:attribute name="isbn" type="xs:string"/>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    - Suman

  • Generate XML out of internal Table (via XSLT)

    Hi NG,
    is there an easy way to generate an XML document out of an internal ABAP Table? Maybe there is even a chnage to use XSLT as an template to define the structure of the XML file.
    Thanks
    Stefan

    check out following thread you will find more than one answer. I like CL_XML_DOCUMENT solution, that is so simple.
    Re: Convert to XML format
    -Sanjeev

  • 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

  • Carriage Returns in XSLT output

    I need to output a text file with CRLF characters at the end of each line. I've explicitly put both characters into the XSLT file ( &lt;xsl:text&gt;&amp;#xD;&amp;#xA;&lt;/xsl:text&gt; ) but the default oracle.xml.parser.v2 in JDeveloper keeps converting the CR to LF. How can I force the parser to output the CR?

    This is incorrect. You can tell the processor to keep and output whitespace nodes if you use the character encodings (&amp;#xA; &amp;#xD; &amp;#x20; &amp;#x9;) and the output method is text. I am getting the correct output for space-only nodes (&amp;#x20;) and the linefeed character (&amp;#xA;). I am also getting a whitespace-only character for the carriage return (&amp;#xD;) node, it is just the <em>wrong</em> character - the parser is converting it to &amp;#xA;, so I am getting two linefeed characters where my stylesheet specifies &amp;#xD;&amp;#xA;.

  • 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.

  • XSLT - New Line/Carriage Return not displaying when deployed

    Hello everyone,
    I have an XSL Style Sheet that is supposed to transform an XML into plain text using Oracle SOA 11g BPEL transformation. The plain text transformation is working fine, but whenever I try to add a new line or carriage return, the text output doesn't reflect that. I've tried several ways of adding the line break but none of them have worked. This is the XSLT I'm using for testing purposes:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:oracle:b2b:X12/V4010/850" version="1.0">
    <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
    <xsl:template match="/a:Transaction-850">
    <!-- New line -->
    <xsl:variable name='newline'><xsl:text>
    </xsl:text></xsl:variable>
    <xsl:value-of select="a:Internal-Properties/a:Data-Structure/a:Property[@Name='InterchangeUsageIndicator']" />
    <xsl:text>&#xd;</xsl:text>
    <xsl:value-of select="$newline" />
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#13;</xsl:text>
    <xsl:text>&#10;</xsl:text>
    <xsl:text>2000ITITM</xsl:text>
    </xsl:template>
    </xsl:stylesheet>
    When I try it out in an online XSLT test tool, it gives the output as expected:
    P
    2000ITITM
    When I deploy the composite, I noticed that the XSLT in the MDS repository ignores the line breaks, *#xAs, etc. and just closes the <xsl:text/> tags:
    <?xml version='1.0' encoding='UTF-8'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:oracle:b2b:X12/V4010/850" version="1.0">
    <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
    <xsl:template match="/a:Transaction-850">
    <xsl:variable name="newline">
    <xsl:text/>
    </xsl:variable>
    <xsl:value-of select="a:Internal-Properties/a:Data-Structure/a:Property[@Name='InterchangeUsageIndicator']"/>
    <xsl:text/>
    <xsl:value-of select="$newline"/>
    <xsl:text/>
    <xsl:text/>
    <xsl:text>2000ITITM</xsl:text>
    </xsl:template>
    </xsl:stylesheet>
    And so, because of that, it just gives me the following output:
    P2000ITITM
    I have no idea why it's ignoring the new line characters, so any guidance would be appreciated.
    Thank you all for your help and time!
    Edit: I tried concatenating as follows:
    <xsl:value-of select="concat('36','&#xA;')"/>
    <xsl:value-of select="concat('24','&#xD;')"/>
    ...which shows up as is when I look at it in the MDS repository, however the text output still shows no line breaks...
    Message was edited by: dany36

    Ah I'm such a newbie. I was able to get it displayed by doing the following:
    <xsl:variable name="newline" select="'&#xD;&#xA;'" />
    This would show up correctly in the MDS repository, too.

  • How to replace an html br tag in the field to a carriage return?

    Hi All,
    I have a requirement to replace the <<br>> tag in the text field with a carriage return character "
    Currently the data in the Comments field looks like :
    "20100627 -115541 SECURITY WILL MEET AT MAIN ENTERANCE"<<<br>>"20100627 -115605 Officer notified: ALPHA : DF-10-011891; ST VINCENTS HOSPITAL, ST VINCENTS HOSPITAL, SAINT VINCENTS HOSP, MERRION RD, MERRION, BOOTERSTOWN, DUBLIN; FIRE/ALARM ACTIVATION;'<<br>>'20100627 -115609 PDA MOBILISED AFTER AMENDMENT VIN1'<<br>>'20100627 -"
    The <<br>> break tag was used for HTML purpose and now I would like to replace it with a carriage return character for BI Publisher report.
    Appreciate3 your help.
    Regards
    B
    Edited by: Bees on Jul 21, 2010 4:36 AM

    I downloaded your html template and it works fine for that template and the xml, but in my case it is not working. I need to assign the template just for one field called "Comments" where I need <<br>> tag to work.
    I modified the html as you suggested with the Tidy software, here is what I have done may be you can help me here. I very much appreciate your help.
    1. I have imported the template with the tag <<?import:file:///C:/dfb/biPub/code/htmlmarkup.xsl?>> and it works fine.
    2. Assigned the xsl - assign-template to the comments field.
    <xsl:apply-templates select="Fact._COMMENTS_" />
    *** IncidentsFact_._COMMENTS is the field name where it has <<br>><</br>> embedded into the comments data.
    Edited by: Bees on Jul 30, 2010 6:29 AM

  • 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

  • Help Please ! -- transform XML to HTML using xslt tag in JSP

    Hello,
    I have problem to do XSL transform in JSP.
    I have an XSL : test.xsl
    I have an XML : test.xml
    In JSP I have:
    <x:xslt media="html" xml="test.xml">
    <x:stylesheet media="html" uri="test.xsl" />
    </x:xslt>
    But It doesn't work the way it suppose to. What is wrong in my code ? I followed the URL http://e-docs.bea.com/wls/docs81/xml/xml_apps.html
    Thanks in advance,
    Christina

    Basically:
        try{
          //Setting up parameters.
          xml=new StreamSource(new File(xmlInput));
          xsl=new StreamSource(new File(xslInput));
          baos=new ByteArrayOutputStream();
          htmlResult=new StreamResult(baos);
          //Transform input(xml, xsl) onto html output.
          TransformerFactory tfactory=TransformerFactory.newInstance();
          Transformer transformer=tfactory.newTransformer(xsl);
          transformer.transform(xml, htmlResult);
          baos.writeTo(out);
          //System.err.println(htmlResult.getOutputStream().toString());
        catch(...){
        }I havent tested and I havent use this for a while, but I hope this can serve as a staring point.
    Regards,
    OO

  • 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.

  • HTML Textarea removing Carriage Returns

    Hi,
    Hoping someone can assist, I am retrieving some data from a table that currently consists of carriage returns but when I try and retrieve this information via Ajax and pass it back into the HTML page textarea field within ApEx, the value returned is one continuous string.
    All my carriage returns are removed.
    Can someone please assist, possibly using a javascript solution or some other type as to how I can preserve the carriage returns.
    Thanks.
    Tony.

    Hi Tony,
    I suspect the problem is simply due to the way HTML handles line breaks, which is to say, it generally ignores them. For example, this html:
    <p>To be or not to be, that is the question;
    Whether 'tis nobler in the mind to suffer
    The slings and arrows of outrageous fortune,
    Or to take arms against a sea of troubles,
    And by opposing, end them. To die, to sleep;
    No more; </p>would be displayed in a browser as:
    To be or not to be, that is the question; Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles, And by opposing, end them. To die, to sleep; No more;
    One way to get around this is to wrap the string in {font:Courier}&lt;pre&gt;&lt;/pre&gt;{font} tags; another would be to replace the carriage returns with {font:Courier}&lt;br&gt;{font}
    Hope this helps.
    tx, --Jen                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for