Using Translate() function of XSLT ...
Hi guys
I have an xml document that i am converting into an html document using XSLT. I need to replace the XML new lines(
) with html new lines (<br>) while the xslt transform takes place on my xml document.
For this I have found the translate function of XSLT but I need to use it on a specific tag and not all the tags in the xml document.
<ExampleTag>
1 first line
2 second line
3 third line
</ExampleTag>
translate(string, replaced_text, replacement_text)
so I need to get my tags value in the variable string which is:
1 first line
2 second line
3 third line
and replaced_text: '
' and replacement_text: '<br>'
but the problem is XSLT syntax is so bad that i just cant devote enough time to learn it. Any suggestions for the syntax guys?? an example would be extremely useful.
cheers :)
Hey
after a bit of struggle came up with this:
<xsl:template match="ExampleTag">
<xsl:variable name="string" select="."> </xsl:variable>
translate(string, "
", "</br>" )
<xsl:value-of select="$string"/>
</xsl:template>
but its not working :(
any suggestions??
Similar Messages
-
Hi
in XSQL i am one getting one row like this
<REASON_FOR_REJECTION>1.Overhead line is not existing in front of the premises,2.The distance from the pole to the serice is more than 30 meters.,3.Another service is existing in the same premises with arrears.</REASON_FOR_REJECTION>
In the above String for every comma i want to put <br>
the output should come like this:
1.Overhead line is not existing in front of the premises
2.The distance from the pole to the serice is more than 30 meters.
3.Another service is existing in the same premises with arrears
i have used translate function like this <xsl:value-of select="translate($REASON_FOR_REJECTION,',',<br>)'"/>
but i couldnt get proper result;how can i do this ??? PLZZ HELPHi Jayant,
please have a look at the following link: http://help.sap.com/saphelp_nw04s/helpdata/en/ae/48e7428d877276e10000000a1550b0/frameset.htm
Regards,
Christophe -
Using Saxon Functions Within XSLT
Hi,
Please let me know how to use saxon functions within XSLT.
E.g.: If I want to implement saxon:base64Binary-to-string() function in XSLT in "xsl:value-of" function, then what will be the format for implementation.
I have selected the Processor as Saxon 8.9.0.3 (the one available) and using xmlns:saxon="http://saxon.sf.net/" in the xsl:stylesheet tag.
I am using Stylus Studio 2007 XML Enterprise Suite for XSLT.
Thanks,
Abhishek.Hi,
Yes I intended to use the XLST mapping within PI...but now will have to change the plan...is there any other way to do it?....is this the problem with the SP?.....anybody who can put more light on this topic.....
Thanks,
Abhishek. -
Using translate function to correct character set problem....
I have a table(TBL_STOCK) on Oracle XE.
Rows come from sql server 2005 with a trigger on sql server table via the linked server.
But there is a character set problem with some character like İ,Ş,Ğ.
They change to Ý,Þ,Ð. in Oracle.
How can i correct these ? Do you suggest the TRANSLATE function ?
What do u think, if i create an After Insert trigger on Oracle table(TBL_STOCK) and convert these character using the Translate function when they inserted from sql server.
Anyone have any other ideas that can be more efficient. Any thoughts appreciated.
Thanks in advance.
Adam
PS:The NLS_CHARACTERSET of Oracle is AL32UTF8.It is sql server 2005 and Collation is SQL_Latin1_General_CP1_CI_AS
-
Using translate function for one to many character translation
Hi friends!
Can anybody tell me whether it is possible to use built in translate function for converting some text from a one alphabet to another one, if these alphabets are of different length. Something like
SELECT TRANSLATE('текст',
'АБВГДЕЕЖЗИКЛМНОПРСТУФХЦЧШЩЭЮЯ',
'ABCGDEF"*GH*"HIJKLMNOPQRSTYVWXYZ') FROM dual;
Or there is another function for this, or it is impossible?
ThanksHi,
Maybe you could use REPLACE just once, and then TRANSLATE the rest?
Something like:
SELECT TRANSLATE(REPLACE('ABcDE', 'c', 'xz'),
'ABCDE',
'abcde') from dual;
TRANSLATE(REPLACE('ABCDE','C','XZ'),'ABCDE','ABCDE')
abxzde
1 row selected.Regards
Peter -
Use document() function in xslt
Hi I want to use the xslt function document() to import a data file into the transformation.
However I don't seem to be able to import the xml file onto the osb. can this be done ?
Basically can you use the document() function?
I've tried googling and searching the docs but i think i'm missing something basic :-)
Thanks in advanceNot an answer to the particular point but i've got round the issue by adding a stage which inserts the data xml into the xml document being transformed.
I then supress the data injected from being copied to the output tree and use a variable which references the data nodes rather than a variable referencing
an external doc variable name="myvar" select="//injecteddatanode" /> rather than <variable name="myvar" select="document("path/doc.xml")
The question still stands though : how do you import an xml doc which can then be used by the document function in a transform -
Using summation function in xslt transformation
Hi,
I'm new to SOA and i'm just exploring the functions in SOA suite. I couldn't add more than one parameter in summation function.
summation function takes only one parameter as input I hope. How to use it.
Thanks and Regards
KarthickYes. You are right.
Nilesh -
How to translate translate 'i' to 'İ' without using translate function?
My database is "Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit".
is there any other solution than this one;
create or replace function tr_upper(str varchar2) return varchar2 is
begin
return upper(translate(str,'i','İ')) ;
end;
select tr_upper('izmir') from dual;
my NLS_SESSION_PARAMETERS are;
PARAMETER VALUE
NLS_LANGUAGE TURKISH
NLS_TERRITORY TURKEY
NLS_CURRENCY TL
NLS_ISO_CURRENCY TURKEY
NLS_NUMERIC_CHARACTERS ,.
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD/MM/RRRR
NLS_DATE_LANGUAGE TURKISH
NLS_SORT TURKISH
NLS_TIME_FORMAT HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT DD/MM/RRRR HH24:MI:SSXFF
NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
NLS_TIMESTAMP_TZ_FORMAT DD/MM/RRRR HH24:MI:SSXFF TZR
NLS_DUAL_CURRENCY YTL
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
17 rows selected
here is the output for the upper/lower functions;
SELECT upper('i'),
lower('İ'),
upper(lower('İ')),
lower(upper('i')),
upper('ı'),
lower('I'),
upper(lower('I')),
lower(upper('ı'))
FROM dual ;
UPPER('I') LOWER('İ') UPPER(LOWER('İ')) LOWER(UPPER('I')) UPPER('I') LOWER('I') UPPER(LOWER('I')) LOWER(UPPER('I'))
I i I i I i I i
Thank you,
Kind regards.
Tonguçmaybe
select nls_upper('i','NLS_SORT=turkish') from dual; or
select nls_upper('i','NLS_SORT=xturkish') from dual;but I am not sure and do not have the right characterset to test -
Error in XSLT mapping while using string functions
Hi All,
While using tokenize() and substring-before() functions in XSLT mapping,we are getting an error.The error message is Unexpected symbol "" So while using string functions in XSLT mapping do we have to use any header functions.
Please through light on syntax etc.,of string functions in XSLT.
Thanx in advance,
Lokesh Dhulipudi
Edited by: LOKESH DHULIPUDI on Dec 27, 2007 7:32 AMHi,
Hope you have gone thru this help:
http://w3schools.com/xsl/default.asp
Rgds, Moorthy -
Hi All,
I am trying to use date function in XSLT, I am using the below code, please correct me if i am wrong
<corecom:EffectiveDate>
<xsl:value-of select='xp20:format-dateTime(ns0:Segment-DTM/ns0:Element-373,"[YYYY][M01][D01]")'/>
</corecom:EffectiveDate>
Regards
FrancisHi Francis,
It doesn't seem to be anything wrong with the code itself, but what's the content of ns0:Segment-DTM/ns0:Element-373 ???
The xp20:format-dateTime function will work if the date on the first parameter is on ISO 8601 format...
http://www.w3.org/TR/NOTE-datetime
Examples
1994-11-05T08:15:30-05:00 corresponds to November 5, 1994, 8:15:30 am, US Eastern Standard Time.
1994-11-05T13:15:30Z corresponds to the same instant.
Cheers,
Vlad -
hi,
How to use Translate function in VC? Please tell me with one exmple.
Points will be given to correct solution.
Cheers,
JayantHi Jayant,
please have a look at the following link: http://help.sap.com/saphelp_nw04s/helpdata/en/ae/48e7428d877276e10000000a1550b0/frameset.htm
Regards,
Christophe -
Encrypt/Decrypt using REPLACE/TRANSLATE function
Hi,
Can someone please provide me any procedure/function which encrypts/decrypts a string using REPLACE/TRANSLATE function?
Thanks
Dinakarexample with TRANSLATE:
CREATE OR REPLACE function temp_encrypt (p_value IN VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
RETURN(TRANSLATE(p_value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'BCDEFGHIJKLMNOPQRSTUVWXYZA'));
END;
CREATE OR REPLACE function temp_decrypt (p_value IN VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
RETURN(TRANSLATE(p_value, 'BCDEFGHIJKLMNOPQRSTUVWXYZA', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'));
END;
SQL> SELECT temp_decrypt('MY TEST') FROM dual;
TEMP_DECRYPT('MYTEST')
LX SDRS
SQL> SELECT temp_encrypt('LX SDRS') FROM dual;
TEMP_ENCRYPT('LXSDRS')
MY TESTyou may combine this with REPLACE() ... -
Need help in using replace function with special characters
I have a column in a table where the data can contain ascii code for special characters such as an apostrophe.
The data looks like this:
CREEK'S LANE
ie for a street named CREEK'S LANE.
I want to replace the ascii representation with the apostrophe and have the returned data show up as: CREEK's LANE
When I try the query below I get prompted for substitution variable value.
I don't seem to be able to find the right syntax to make this query work.
SELECT REPLACE (street_name, ''', '''')
FROM
streets WHERE street_id = 1
Does anybody know how to do this?
Any help would be much appreciated.
Thanks.
Georgegeorge91 wrote:
I have a column in a table where the data can contain ascii code for special characters such as an apostrophe.
The data looks like this:
CREEK'S LANE
ie for a street named CREEK'S LANE.
I want to replace the ascii representation with the apostrophe and have the returned data show up as: CREEK's LANE
When I try the query below I get prompted for substitution variable value.
I don't seem to be able to find the right syntax to make this query work.
SELECT REPLACE (street_name, ''', '''')
FROM
streets WHERE street_id = 1
Does anybody know how to do this?
Any help would be much appreciated.
Thanks.
GeorgeHa! The codes you specified rendered in the HTML, but showed properly when I listed your original posting above. I didn't understand what you meant initially because the 5-character string represenation got rendered as the quote that you said you weren't able to get - a display problem.
You're getting prompted for the substituon variable because of the ampersand; you appear to be doing this in SQL*PLUS. The first thing I would try is to SET DEFINE OFF when using the ampersands to see if that works. If That doesn't work check the docs to delmit the ampersand (I think its a backslash before it but can't remember offhand). Another, harder option might be to use the TRANSLATE function replacing the literal character instead of using REPLACE (though replacing a quote will be a little tricky). If you're on 10g also consider using the advanced quoting
Good luck!
Edited by: riedelme on May 22, 2009 12:45 PM -
File scenario error in Used defined function
Hi Everyone,
I was doing file to file scenario, i want to get the same source file name in target also.
I created the structure as FileName, Company, Address. I did direct mapping for Company and Address
but for field FileName, i created a userdefined function as i want the same file name.
I mentioned the following code in Used defined function
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String ourSourceFileName = conf.get(key);
return ourSourceFileName;
When i test the mapping in IR, with sample data, i am getting this error.
RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /ns0:Target_File_MT/FileName. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._Source_File_to_Target_File_MM_ method DynamicFile$[, com.sap.aii.mappingtool.tf3.rt.Context@1763e46]
Could anyone please help me with the issue.
I have done only IR part, I didnot configured ID.
Regards,
Varun.HI,
Check Adapter Specific Message attributes.This blog will help you
The specified item was not found.
You can also go for variable substitution :-
When you specify the target directory and file name schema, you have option of setting variables and defining them in a table. The variables are replaced by elements from the XML structure at runtime.
http://help.sap.com/saphelp_nw2004s/helpdata/en/8e/464442c1a1c253e10000000a1550b0/content.htm
links on the dynamic variable substitution
The specified item was not found.
The specified item was not found.
Dynamic File Name Part 1
Dynamic File Name using XI 3.0 SP12 Part - I
Dynamic File Name Part 2
Dynamic file name(XSLT Mapping with Java Enhancement) using XI 3.0 SP12 Part -II
Thanks -
Mail sending using sender importing parameter using so_object_send function
Hi all,
I using so_object_send function module to send mail. My requirement is with respect to any user
logged in the sender mail address should be taken by V_SENDER parameter in exporting
parameter.
<code>
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
folder_id = wa_folder_id
forwarder = w_forwarder
object_fl_change = wa_object_fl_change
object_hd_change = wa_object_hd_change
object_id = wa_object_id
object_type = w_object_type
outbox_flag = w_outbox_flag
owner = w_owner
store_flag = w_store_flag
IMPORTING
object_id_new = wa_object_id_new
sent_to_all = w_sent_to_all
sender = v_sender
TABLES
objcont = i_objcont
objhead = i_objhead
objpara = i_objpara
objparb = i_objparb
receivers = i_receivers
EXCEPTIONS
active_user_not_exist = 1
communication_failure = 2
component_not_available = 3
folder_not_exist = 4
folder_no_authorization = 5
forwarder_not_exist = 6
note_not_exist = 7
object_not_exist = 8
object_not_sent = 9
object_no_authorization = 10
object_type_not_exist = 11
operation_no_authorization = 12
owner_not_exist = 13
parameter_error = 14
substitute_not_active = 15
substitute_not_defined = 16
system_failure = 17
too_much_receivers = 18
user_not_exist = 19
originator_not_exist = 20
x_error = 21
OTHERS = 22.
IF sy-subrc 0.
ENDIF.
</code>
My Requirement is V_SENDER can be any user of that SAP system,noot particularly logged in user.
I tried using this functionality my sy-subrc is zero. but i am not able to get any mails with that user name in V_SENDER.
Do i need to do any further settings or any more code is required.
Even i tired giving SUBMIT rsconn01 .
still its not working.
Please suggest any solutions if we have.
Thanks,
satishHi,
to send mails check this:
FORM docu_send_email USING pv_otfdata TYPE tsfotf
pv_emailid TYPE any
pv_formname TYPE any.
DATA: lv_filesize TYPE i,
lv_buffer TYPE string,
lv_attachment TYPE i,
lv_testo TYPE i.
DATA: li_pdfdata TYPE STANDARD TABLE OF tline,
li_mess_att TYPE STANDARD TABLE OF solisti1,
li_mtab_pdf TYPE STANDARD TABLE OF tline,
li_objpack TYPE STANDARD TABLE OF sopcklsti1,
li_objtxt TYPE STANDARD TABLE OF solisti1,
li_objbin TYPE STANDARD TABLE OF solisti1,
li_reclist TYPE STANDARD TABLE OF somlreci1,
li_objhead TYPE soli_tab.
DATA: lwa_pdfdata TYPE tline,
lwa_objpack TYPE sopcklsti1,
lwa_mess_att TYPE solisti1,
lwa_objtxt TYPE solisti1,
lwa_objbin TYPE solisti1,
lwa_reclist TYPE somlreci1,
lwa_doc_chng TYPE sodocchgi1.
CONSTANTS: lc_u TYPE char1 VALUE 'U',
lc_0 TYPE char1 VALUE '0',
lc_1 TYPE char1 VALUE '1',
lc_pdf TYPE char3 VALUE 'PDF',
lc_raw TYPE char3 VALUE 'RAW',
lc_ordform TYPE char15 VALUE 'ZORDCONFIRM_01',
lc_attachment TYPE char10 VALUE 'ATTACHMENT'.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = lc_pdf
max_linewidth = 132
IMPORTING
bin_filesize = lv_filesize
TABLES
otf = pv_otfdata
lines = li_pdfdata
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT li_pdfdata INTO lwa_pdfdata.
TRANSLATE lwa_pdfdata USING ' ~'.
CONCATENATE lv_buffer lwa_pdfdata INTO lv_buffer.
CLEAR lwa_pdfdata.
ENDLOOP.
TRANSLATE lv_buffer USING '~ '.
DO.
lwa_mess_att = lv_buffer.
APPEND lwa_mess_att TO li_mess_att.
CLEAR lwa_mess_att.
SHIFT lv_buffer LEFT BY 255 PLACES.
IF lv_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Object with PDF.
REFRESH li_objbin.
li_objbin] = li_mess_att[.
DESCRIBE TABLE li_objbin LINES lv_attachment.
Object with main text of the mail.
lwa_objtxt = space.
APPEND lwa_objtxt TO li_objtxt.
CLEAR lwa_objtxt.
DESCRIBE TABLE li_objtxt LINES lv_testo.
Create the document which is to be sent
lwa_doc_chng-obj_name = text-008.
lwa_doc_chng-obj_descr = text-008.
lwa_doc_chng-sensitivty = lc_0.
lwa_doc_chng-obj_prio = lc_1.
lwa_doc_chng-doc_size = lv_testo * 225.
Pack to main body.
CLEAR lwa_objpack-transf_bin.
header
lwa_objpack-head_start = 1.
The document needs no header (head_num = 0)
lwa_objpack-head_num = 0.
body
lwa_objpack-body_start = 1.
lwa_objpack-body_num = lv_testo.
lwa_objpack-doc_type = lc_raw.
APPEND lwa_objpack TO li_objpack.
CLEAR lwa_objpack.
Create the attachment.
Fill the fields of the packing_list for the attachment:
lwa_objpack-transf_bin = gc_x .
header
lwa_objpack-head_start = 1.
lwa_objpack-head_num = 1.
body
lwa_objpack-body_start = 1.
lwa_objpack-body_num = lv_attachment.
lwa_objpack-doc_type = lc_pdf.
lwa_objpack-obj_name = lc_attachment.
lwa_objpack-obj_descr = text-008.
lwa_objpack-doc_size = lv_attachment * 255.
APPEND lwa_objpack TO li_objpack.
CLEAR lwa_objpack.
lwa_reclist-receiver = pv_emailid.
lwa_reclist-rec_type = lc_u.
lwa_reclist-notif_del = gc_x.
lwa_reclist-notif_ndel = gc_x.
APPEND lwa_reclist TO li_reclist.
IF li_reclist IS NOT INITIAL.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_doc_chng
put_in_outbox = gc_x
TABLES
packing_list = li_objpack
object_header = li_objhead
contents_bin = li_objbin
contents_txt = li_objtxt
receivers = li_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " DOCU_SEND_EMAIL
Maybe you are looking for
-
Error while Creating a request to assign PD profile
Hello Experts, I am trying to create a Change request to assign only the PD profile to the user . However when i submit the request i get an error message "Select at least one role". I am not sure is it mandatory to select any role even when you just
-
I got an email this morning from apple saying my bumper has been shipped. Has this happened to anybody else and do you know how long apple's regular shipping is?
-
No internet connection after change
I've had my WRT54GL for a few months now and have two computers that are wired and 3 that are wireless. I started having problems with conflicting IP's a couple days ago on one of my wired computers which was set for auto DHCP so I changed the settin
-
Technical content ** NW 2004s ** Please help
Hi, When i check the reports of the technical content, i can only see the the Techcnical name of the Info Package. Even if i choose display as " Key & Text " still unable to see the Ipak descreption in the report. I have checked old 3.X statistics, i
-
How to create epub book in indesign in details.
I have found lots of time regarding epub in indesign, but couldn't get full details tutorials on any other blogs. I would like each and every step in details in indesign. Could you please send me link so I will complete my epub book in indesign.