How to escape special characters in Simple Transformation

Hi Experts,
I have got a problem to get a well formed xml document from the below simple transformation. The content of maktx contains
special characters like & <, which are not allowed in a well formed XML-Document. But the result of the Simple Transformation
contains this charcters even after the transformation as you can the in the result below. Has anyone a hint how to escape the
characters included in the maktx.
The transformation for maktx, should be something like
Before: Material & < TEST
After: Material &amp &lt TEST
Report wihich calls the simple transformation
types:
BEGIN OF t_mat,
   matnr type matnr,
   maktx type maktx,
end of t_mat.
Data:
  mat type t_mat,
  xml_stream type xstring.
START-OF-SELECTION.
mat-matnr = '4711'.
mat-maktx = 'Material & < Test'.
CALL TRANSFORMATION ztest_st2
        SOURCE mat = mat
        RESULT XML xml_stream.
CALL FUNCTION 'DISPLAY_XML_STRING'
  EXPORTING xml_string = xml_stream.
Simple Transformation
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="MAT"/>
  <tt:template>
    <Leistungsschild>
        <CHARACT> MATNR </CHARACT>
        <CHARACT_DESCR> Materialnummer </CHARACT_DESCR>
        <VALUE tt:value-ref="MAT.MATNR"/>
        <CHARACT> MAKTX </CHARACT>
        <CHARACT_DESCR> Materialkurztext </CHARACT_DESCR>
        <VALUE tt:value-ref="MAT.MAKTX" />
    </Leistungsschild>
  </tt:template>
</tt:transform>
RESULT
<?xml version="1.0" encoding="utf-8" ?>
<Leistungsschild>
  <CHARACT>MATNR</CHARACT>
  <CHARACT_DESCR>Materialnummer</CHARACT_DESCR>
  <VALUE>4711</VALUE>
  <CHARACT>MAKTX</CHARACT>
  <CHARACT_DESCR>Materialkurztext</CHARACT_DESCR>
  <VALUE>Material & < Test</VALUE>   </Leistungsschild>

Hi Sandra,
First of all thaks for your quick answer to my problem.
I see what you mean and get the same result, if I am using data-type string instead of xstring. But the recommendation in the XML-Books of SAP is to use XSTRING to save memory and circumflex problems between Codepages, when writing the XML-Stream to a filesystem.
As you can see in the code abvoe I am using a SAP-FM to display the XML-Stream and this FM works only with XSTRING´s,
that is one reason why I don´t understand that it displays it in the wrong way.
Even the Debugger shows me for the XSTRING the wrong result. Does all that mean that the escaping will not be applyed if you are working with XSTING´s??

Similar Messages

  • How to escape special characters in a region title

    I have created a drill down report where the second report is filtered by a value chosen in the first report. I am using &Pn_field. syntax to pass the name of the select value to the region title of the second report. Some of the returned values have a ':' in them and therefore the text does not print after the ':'. How do I escape the ':' in the region title?
    regards
    Paul P

    Paul,
    I think your question is "How do I use f?p URL syntax to pass data values to a page where the data includes a colon?" (Please correct me if that's not the issue.) The answer is, you can't. Same with commas. HTML DB reserves those two characters for the f?p request syntax. You'll have to save the string into the item before the page branch. There is no restriction on what characters can be used in a region title, it's just HTML-formatted text, except that you must escape anything that looks like HTML unless you want the browser to treat it as HTML. There are restrictions, however, on what characters you can pass in URLs in general and you must take care to escape them properly, e.g., ?, &, whitespace.
    And do speak up if I've missed the point.
    Scott

  • How to escape special characters in expression

    Hi all,
    I have to build a wildcard search expression, some key words, such as "%%%", "___%" will list out all records, which is not allowed in our application.
    In oralce sql , we have an key word: "escape", but I can't translate it into an expression.
    Any one can help me?
    Any help will be appreciated. Thank you.
    Regards,
    Roger

    Are using using like()? Expression also defines like() with two arguments, the second is the escape.
    JPQL also defines this.
    James : http://www.eclipselink.org

  • How to display special characters in APEX Classic Report column

    Ref: Thread: How to display newline characters as new lines
    Version: APEX 3.2
    Hi,
    I have created an classic SQL Report with one of the columns being a decode that gives a value 'Post'(the value should be highlighted in Red) on one condition and 'Pre' on another. I have followed the advice given in the page (URL provided above) , i.e. I have changed Strip HTML to 'No', changed Display as to 'Display as text (escape special characters, does not save state)'. I have also passed this value back to the same page to be stored in a page item each time a link (another column in report) in report is clicked. I have tried passing it as #DEADLINE# and \#DEADLINE#\. The issue I face is, instead of the value being highlighted in Red, it gets passed back as a string holding the value 'Post'. Is there any way I can get this to display as it should without the Strip HTML being changed to 'Yes'.
    Thanks very much.
    Rohi
    Edited by: Rohi on 18-Jul-2012 04:21

    876651 wrote:
    Hi,
    Thanks for your response.
    I am trying to display a page item that is derived from a report column based on a click on the URL link (*view >*>)
    This page item (here, it is Manager_ID) should ideally be highlighted when a particular condition is satisfied (achieved using a DECODE in the report).
    But it is not displayed like it should be.
    I do not want the value to be displayed along with the html tags as a string.
    I want the html tags to take effect and highlight the value within it.
    Initially, I had set Strip HTML to Yes and the value was returned without any highlighting .
    So I changed it to 'No' and and it contained the html tags.
    I am not sure what setting in APEX Report Attributes can help me achieve that effect I want.None of the report settings are relevant. They affect the rendering of the report and none of the columns you were changing the properties of were actually rendered.
    You can't pass HTML and CSS around in URL parameters.
    I suggest you pass *2* values in the column link: the MGR ID and a simple class or colour value computed by the DECODE in the report. I've suppressed the first version of the report and created a new one that does this:
    decode(dept.deptno, '30', 'c00', '000') highlight The link column now passes the MGR ID and the HIGHLIGHT colour (red when the condition is satisfied and black when it is not).
    I created another hidden and protected page item <tt>P0_HIGHLIGHT</tt> as the target for the highlight value, and used the Pre/Post Element Text properties of the <tt>P0_G_MGR</tt> to wrap it in a <tt>span</tt> whose colour is changed using the <tt>P0_HIGHLIGHT</tt> value as a subtitution string:
    <span style="color: #&P0_HIGHLIGHT.;">Having done that, I still don't really get the requirement here. I'm sure that given the full picture I'd be using a completely different approach...

  • How to print Special Characters in Sap-Scripts

    How to print Special Characters in Sap-Scripts
    Thanks,
    Ravi

    Hi
    if u want print special characters we can use hot codes i.e '  '  (single inverted commas). in between these hot codes insert u r special characters.
    write    '    !@#$%^&*( )  '.
    for the above write statement output is
    output is   !@#$%^&*( )

  • How to write special characters in PDF using iText

    How to write special characters encoded with UTF-8 in PDF using iText.
    Regards,
    Pandharinath.

    I don't know what your problem is but that's almost certainly the wrong question to ask about it. Java (including iText) uses only Unicode characters. (You may consider some of them to be "special" if you like but Unicode doesn't.) And when it does that, they aren't encoded in UTF-8 or any other encoding.
    So can you describe your problem? That question doesn't make sense.

  • How to display special characters in Script...

    hi all,
    Can any one tell me how to display special characters in script...
    how to write in text element
    thanks in advance,
    prashant

    Hi Prashant ,
      What special characters would you like to include .
    There are a set of characters / icons /symbols that can be included in Script , for that open a window in edit mode and in the menu there will be an option called Insert  , here you can find a lot of characters/symbols that can be included .
    Regards,
    Arun

  • SQL Injections and XSS - Escaping Special Characters

    Hi, hope someone can help in regards to security and SQL Injections and XSS.
    We are using APEX 4.0.2 on Oracle 11.2.0.2.
    1. It seems the special characters we have entered into normal 'Text Items' 'Text Areas' etc are not being escaped (ie <,>,&, '). If I enter them into the field (ie Surname) they are saved as is into session state and the database - no escaping. Am I missing something such as an environment setting as I thought the "smart" oracle escaping rules would cater for this.
    Surely I don't have to manually do each of then.
    Just to confirm, am I looking in the correct places to assess if the characters are escaped or not - ie should they show as '&amp;&lt;&gt;' in session state and/or the database ?
    2. Also, for the Oracle procedures such as '‘wwv_flow.accept’ , ‘wwv_flow.show’ , 'wwv_flow_utilities.show_as_popup_calendar' - do these escape special characters. If not, then they must be vulnerable to SQL Injections attacks.
    Thx
    Nigel

    Recx Ltd wrote:
    Just to pitch in, escaping values internally (either in the database or session state) is extremely problematic. Data searches, string comparison, reporting and double escaping are all areas which suffer badly when you do this.
    Stripping characters on input can also cause problems if not considered within the context of the application. Names such as "O'Niel", statistical output such as "n < 300", fields containing deliberate HTML markup can be annoying to debug. In certain situations stripping is totally ineffective and may still lead to cross-site scripting.
    Apex applications that share the database with other applications will also be affected.
    The database should contain 'raw' unfettered data and output should be escaped properly, as Joel said, at render time. Either with Apex attributes or using PLSQL functions such as htf.escape_sc() as and when required.Do not needlessly resurrect old threads. After a couple of months watches expire and the original posters are not alerted to the presence of your follow-up.
    Shameless plug: If you are in the game of needing to produce secure Apex code, you should get in touch.This crosses the line into spam: it violates the OTN Terms of Use&mdash;see 6(j).
    Promotional posts like this are liable to be removed by the moderators.

  • How to remove special characters while typing data in edit cell in datagrid in flex4

    Hi Friends,
    I am facing this problem "how to remove special characters while typing data in edit cell in datagrid in flex4".If know anyone please help in this
    Thanks,
    Anderson.

    Removes any characters from
    @myString that do not meet the
    provided criteria.
    CREATE FUNCTION dbo.GetCharacters(@myString varchar(500), @validChars varchar(100))
    RETURNS varchar(500) AS
    BEGIN
    While @myString like '%[^' + @validChars + ']%'
    Select @myString = replace(@myString,substring(@myString,patindex('%[^' + @validChars + ']%',@myString),1),'')
    Return @myString
    END
    Go
    Declare @testStr varchar(1000),
    @i int
    Set @i = 1
    while @i < 255
    Select
    @TestStr = isnull(@TestStr,'') + isnull(char(@i),''),
    @i = @i + 1
    Select @TestStr
    Select dbo.GetCharacters(@TestStr,'a-z')
    Select dbo.GetCharacters(@TestStr,'0-9')
    Select dbo.GetCharacters(@TestStr,'0-9a-z')
    Select dbo.GetCharacters(@TestStr,'02468bferlki')
    perfect soluction

  • How to escape special xml characters in ALSB

    Hi
    Can some one tell me how to replace special xml characters < ,> with &lt; and &gt;
    I have xml node like below
    <payload>
    <RatingDetails>
    <Action>Add</Action>
    </payload>
    Using fn-bea:serialize i got xml string as
    <payload><RatingDetails><Action>Add</Action></payload>
    I want output as below
    <payload>&lt;RatingDetails&gt;&lt;Action&gt;Add&lt;/Action&gt;</payload>
    Appreciate your help
    Thanks in Advance

    when i use fn-bea:serialize my request xml node converted to xml string.To that string i had escaped special xml characters.
    Original request:
    <abc>
    <a1 >123</a1>
    <payload>
    <d>345</d>
    <e><678></e>
    </payload>
    </abc>
    After using serialize it became as below (everything in one line)
    <abc><a1>123</a1><payload><d>345</d><e><678></e></payload></abc>
    then i used java callout for replacing special xml chars in payload element,
    now my request is
    <abc><a1>123</a1><payload><![CDATA[& lt;d& gt;345& lt;/d& gt;& lt;e& gt;& lt;678& gt;& lt;/e& gt;]]></payload></abc>
    i dont want my payload data to be enclosed within CDATA but by default i am getting it when i run my xquery for generating request.
    This might be because & will not get parsed in xml parser so enclosing evrything in CDATA.
    Need solution to remove CDATA and send the payload data as it is..

  • How to handle special characters in Apex

    Hi ,
    In my application I have two regions - one is Report Region (Interactive Report) and other one is HTML region with two text items - Empno and name
    My Report has two columns Empno(varchar2) and Ename(varchar2).
    When I click the edit link in the report column, the empno should have a read only EMPNO value and ename is a text field with ENAME value.
    When I run my application I have encountered the following problems :
    1. if my empno has special characters like ' # ', the characters after that is not getting displayed
    2. if my empno has special characters like ',' - the characters after comma is treated as a next texitem value
    Here is my credential ,
    Workspace CTSAN_ORACLE_DB
    Username [email protected]
    Password lakshmi321
    URL : http://apex.oracle.com/pls/apex/f?p=9444:19:4292839314890159:::::
    Plz. suggest me how to rectify the above problems.
    Thanks,
    Anoo..
    Edited by: Anoo on Aug 13, 2010 3:05 AM

    Don't pass data values in URLs. Whilst it is possible to escape values to make them URL- and APEX parameter-safe, it is much better practice to avoid the problem altogether.
    Create a surrogate primary key on the table that is an immutable discrete numeric identifier and only use this as a URL parameter. In target pages/regions, use this PK value to retrieve the required data from the table.

  • How to convert special characters in ABAP to XML?

    Hi All.
    We have a scenario where from XI (exchange Infrastructure), a BAPI is called which returns an XML. From that XML, a PDF is generated.
    Now, if the XML contains any special characters, it will fail.
    So if any CHinese char or >, # etc signs are there, it fails.
    Can you please tell me how to convert my string in ABAP to a proper XML?
    I am new to it and I was trying the following code
    DATA: today TYPE string,
          result TYPE string.
    today = 'This is testing'.
    CALL TRANSFORMATION ID
         SOURCE today = today
         RESULT XML result.
    IF sy-subrc = 0.
      WRITE result.
    ENDIF.
    But it does not return me anything.
    Thanks in adv.

    hi
    good
    go through these links,hope these would help you to solve your problem
    http://www.sap-press.de/download/dateien/792/sappress_abapreference_2edition.pdf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf80665d
    thanks
    mrutyun^

  • How to handle special characters in Stage web view with Load URL method?

    Hi,
      I have Latin special characters in my text. My HTML content contains the text as well as the image. If I use stage webview LoadString,  images will not be displayed. But my latin characters are displayed correctly.
    If I use LoadURL method, the images are displayed correctly but I have problem in displaying the latin special characters. How to solve this issue?

    Don't pass data values in URLs. Whilst it is possible to escape values to make them URL- and APEX parameter-safe, it is much better practice to avoid the problem altogether.
    Create a surrogate primary key on the table that is an immutable discrete numeric identifier and only use this as a URL parameter. In target pages/regions, use this PK value to retrieve the required data from the table.

  • How to export special characters into an XML file?

    Dear experts,
    We read files from our customers and save data into our customized table without any character changed, including some address fields. In those address fields, some special characters (not in our code page) are also kept. When we want to write these address fields into an XML file or flat file, the special charcters become "##" or not readable, can anyone help us to solve this issue?
    Question1: How to write special code to an external file?
    Question2: how to use 'CALL TRANSFORMATION' from an internal table to an XML file?
    Your answer is highly appreciated!
    Joanne

    Hi Joanne.
    Please check the below link.
    CALL TRANSFORMATION
    Before that u have to create one transformation program in STRANS tcode for using it in call transformation statement.
    Hope it will be useful.
    Regards,
    Lakshman

  • Escape special characters in url for redirection

    In my web page, I want all the characters of the URL to be lower case. For that I created the following method:
    private bool UrlFormatoCorrecto(string url)
    bool formatoCorrecto = true;
    bool upperCa = url.Any(c => char.IsUpper(c));
    if (url.Any(c => char.IsUpper(c)))
    formatoCorrecto = false;
    if (url.Contains(" ") || url.Contains("+"))
    formatoCorrecto = false;
    return formatoCorrecto;
    This works like a charm until a special character appears. The url that I get then will be the following:
    http://localhost/web/coches/proven%C3%A7a-aribau,-08036-barcelona,-barcelona
    So I have upper case characters. When I redirect it using the following code:
    if (!UrlFormatoCorrecto(urlActual))
    Response.RedirectPermanent(urlActual.Replace(" ", "-").Replace("+", "-").ToLower());
    I get the code again with the same URL with upper case. How can I escape the special characters so they won't bother me anytime I want to make the redirection?

    hello,
    you could escape special caracters with :
    Regex.Escape Method
    Regards
    Cédric

Maybe you are looking for