Character escaping

I'm trying to escape all apostrophes in a String so that it can be used inside a javascript function as a parameter. However to replace all "'" with "\'" it seems I need to write the following:
str = str.replaceAll("'", "\\\\'");I don't understand why I need 4 backslashes to get one in the output. Thanks

The parameter is becoming a regex argument, and in regex, the backslash is a special char and needs to be escaped by another backslash.

Similar Messages

  • Double character escaping???

    My problem is the following:
    The value of a column in the database called 'Titel' is: 'Oracle & J2EE'
    When doing a query using the oracle.jbo.html.databeans.XmlData object the output comes as following in the XML stream: <Titel>Oracle &#38;amp; J2EE</Titel>
    I'm not able to get this back to the original text again.
    <xsl:value-of select="Titel" /> gives 'Oracle &;#38;amp; J2EE' with displays as 'Oracle &#38;amp; J2EE' in HTML
    <xsl:value-of select="Titel" disable-output-escaping="yes" /> gives 'Oracle &#38;amp; J2EE' with displays as 'Oracle &; J2EE'.
    Does any body know how to get this to display correctly?
    The same applies when HTML tags as stored in database fields. They get escaped over and over.
    (The database field is an VARCHAR2( n ) )
    Thanks in advance,
    Robert Willems of Brilman

    Sorry... the examples are mixed up a little.... I had the wrong data at hand:
    The Database value is:
    'Bla bla bla<br>Bla bla bla'
    We want to get this data out of the Database using the XMLData object and transform it to HTML using an XSL Stylesheet. However we cannot seem to get the tags to the brower.
    With disable-output-escaping="yes" it will be output as 'Bla bla bla<br>Bla bla bla'.
    With disable-output-escaping="no" it will be output as 'Bla bla bla&&#38;lt;br&#38;gt;Bla bla bla'
    How can we get <br> to the browser?
    Thank you in advance,
    Robert Willems of Brilman

  • XML Character Escaping Issue

    Hello all,
    At my current project we are interfacing between SAP and PeopleSoft.
    The target system peoplesoft expects an xml exactly formed as follows.
    So within the CDATA area "<" and ">" are expected. NOT "&lt ;" and "&gt ;" AND NOT  "&#60 ;" and "&#62 ;"
    <?xml version="1.0"?>
    <IBRequest>
         <ContentSections>
              <ContentSection>
                   <Data>
    <![CDATA <?xml version="1.0"?><SNS_UPDATE_DEB><MsgData><Transaction>
    <EXTERNAL_SYSTEM class="R"><EMPLID IsChanged="Y">500000005</EMPLID>
    <EFFDT IsChanged="Y">2008-01-22</EFFDT><EXTERNAL_SYSTEM_ID>SAP99003</EXTERNAL_SYSTEM_ID>
    </EXTERNAL_SYSTEM></Transaction></MsgData></SNS_UPDATE_DEB>]>
                                                    </Data>
              </ContentSection>
         </ContentSections>
    </IBRequest>
    However the sending system does send the "<" and ">" within the CDATA are in 'escaped mode'.
    Like below.
    <?xml version="1.0"?>
    <IBRequest>
         <ContentSections>
              <ContentSection>
                   <Data>
    <!CDATA &lt ;SNS_UPDATE_DEB&gt ;&lt ;MsgData&gt ;&lt ;Transaction&gt ;>
    </Data>
              </ContentSection>
         </ContentSections>
    </IBRequest>
    Trying an XSLT with: disable-output-escaping="yes" gave no results. Furthermore a UDF with a FindAndReplace function also doesn't work.
    Does anyone have an idea how to fix this problem?

    Hi Ramon,
    I assume that the UDF is no help because XI escapes the XML after it's passed through the mapping again. Have you tried a Module in the adapter engine that reverts the escaping right at the end of processing? This at least should make sure that no further modifications are done by anybody afterwards.
    On the other hand, this is technically more challenging and a bit harder to monitor.
    What adapter are you using to commnunicate with your target system?
    regards,
    Peter

  • Include-owa and character escaping

    Hi.
    We are using include-owa to return user entered databse text within well formatted tags.
    Sometimes text contains & and other XML characters.
    We then "get XML returned from PLSQL agent was not well-formed error"
    How can we easily escape all text values returned?
    Thanks
    Lionel

    Normally you can enclose the text in the CDATA element.

  • What every developer should know about character encoding

    This was originally posted (with better formatting) at Moderator edit: link removed/what-every-developer-should-know-about-character-encoding.html. I'm posting because lots of people trip over this.
    If you write code that touches a text file, you probably need this.
    Lets start off with two key items
    1.Unicode does not solve this issue for us (yet).
    2.Every text file is encoded. There is no such thing as an unencoded file or a "general" encoding.
    And lets add a codacil to this – most Americans can get by without having to take this in to account – most of the time. Because the characters for the first 127 bytes in the vast majority of encoding schemes map to the same set of characters (more accurately called glyphs). And because we only use A-Z without any other characters, accents, etc. – we're good to go. But the second you use those same assumptions in an HTML or XML file that has characters outside the first 127 – then the trouble starts.
    The computer industry started with diskspace and memory at a premium. Anyone who suggested using 2 bytes for each character instead of one would have been laughed at. In fact we're lucky that the byte worked best as 8 bits or we might have had fewer than 256 bits for each character. There of course were numerous charactersets (or codepages) developed early on. But we ended up with most everyone using a standard set of codepages where the first 127 bytes were identical on all and the second were unique to each set. There were sets for America/Western Europe, Central Europe, Russia, etc.
    And then for Asia, because 256 characters were not enough, some of the range 128 – 255 had what was called DBCS (double byte character sets). For each value of a first byte (in these higher ranges), the second byte then identified one of 256 characters. This gave a total of 128 * 256 additional characters. It was a hack, but it kept memory use to a minimum. Chinese, Japanese, and Korean each have their own DBCS codepage.
    And for awhile this worked well. Operating systems, applications, etc. mostly were set to use a specified code page. But then the internet came along. A website in America using an XML file from Greece to display data to a user browsing in Russia, where each is entering data based on their country – that broke the paradigm.
    Fast forward to today. The two file formats where we can explain this the best, and where everyone trips over it, is HTML and XML. Every HTML and XML file can optionally have the character encoding set in it's header metadata. If it's not set, then most programs assume it is UTF-8, but that is not a standard and not universally followed. If the encoding is not specified and the program reading the file guess wrong – the file will be misread.
    Point 1 – Never treat specifying the encoding as optional when writing a file. Always write it to the file. Always. Even if you are willing to swear that the file will never have characters out of the range 1 – 127.
    Now lets' look at UTF-8 because as the standard and the way it works, it gets people into a lot of trouble. UTF-8 was popular for two reasons. First it matched the standard codepages for the first 127 characters and so most existing HTML and XML would match it. Second, it was designed to use as few bytes as possible which mattered a lot back when it was designed and many people were still using dial-up modems.
    UTF-8 borrowed from the DBCS designs from the Asian codepages. The first 128 bytes are all single byte representations of characters. Then for the next most common set, it uses a block in the second 128 bytes to be a double byte sequence giving us more characters. But wait, there's more. For the less common there's a first byte which leads to a sersies of second bytes. Those then each lead to a third byte and those three bytes define the character. This goes up to 6 byte sequences. Using the MBCS (multi-byte character set) you can write the equivilent of every unicode character. And assuming what you are writing is not a list of seldom used Chinese characters, do it in fewer bytes.
    But here is what everyone trips over – they have an HTML or XML file, it works fine, and they open it up in a text editor. They then add a character that in their text editor, using the codepage for their region, insert a character like ß and save the file. Of course it must be correct – their text editor shows it correctly. But feed it to any program that reads according to the encoding and that is now the first character fo a 2 byte sequence. You either get a different character or if the second byte is not a legal value for that first byte – an error.
    Point 2 – Always create HTML and XML in a program that writes it out correctly using the encode. If you must create with a text editor, then view the final file in a browser.
    Now, what about when the code you are writing will read or write a file? We are not talking binary/data files where you write it out in your own format, but files that are considered text files. Java, .NET, etc all have character encoders. The purpose of these encoders is to translate between a sequence of bytes (the file) and the characters they represent. Lets take what is actually a very difficlut example – your source code, be it C#, Java, etc. These are still by and large "plain old text files" with no encoding hints. So how do programs handle them? Many assume they use the local code page. Many others assume that all characters will be in the range 0 – 127 and will choke on anything else.
    Here's a key point about these text files – every program is still using an encoding. It may not be setting it in code, but by definition an encoding is being used.
    Point 3 – Always set the encoding when you read and write text files. Not just for HTML & XML, but even for files like source code. It's fine if you set it to use the default codepage, but set the encoding.
    Point 4 – Use the most complete encoder possible. You can write your own XML as a text file encoded for UTF-8. But if you write it using an XML encoder, then it will include the encoding in the meta data and you can't get it wrong. (it also adds the endian preamble to the file.)
    Ok, you're reading & writing files correctly but what about inside your code. What there? This is where it's easy – unicode. That's what those encoders created in the Java & .NET runtime are designed to do. You read in and get unicode. You write unicode and get an encoded file. That's why the char type is 16 bits and is a unique core type that is for characters. This you probably have right because languages today don't give you much choice in the matter.
    Point 5 – (For developers on languages that have been around awhile) – Always use unicode internally. In C++ this is called wide chars (or something similar). Don't get clever to save a couple of bytes, memory is cheap and you have more important things to do.
    Wrapping it up
    I think there are two key items to keep in mind here. First, make sure you are taking the encoding in to account on text files. Second, this is actually all very easy and straightforward. People rarely screw up how to use an encoding, it's when they ignore the issue that they get in to trouble.
    Edited by: Darryl Burke -- link removed

    DavidThi808 wrote:
    This was originally posted (with better formatting) at Moderator edit: link removed/what-every-developer-should-know-about-character-encoding.html. I'm posting because lots of people trip over this.
    If you write code that touches a text file, you probably need this.
    Lets start off with two key items
    1.Unicode does not solve this issue for us (yet).
    2.Every text file is encoded. There is no such thing as an unencoded file or a "general" encoding.
    And lets add a codacil to this – most Americans can get by without having to take this in to account – most of the time. Because the characters for the first 127 bytes in the vast majority of encoding schemes map to the same set of characters (more accurately called glyphs). And because we only use A-Z without any other characters, accents, etc. – we're good to go. But the second you use those same assumptions in an HTML or XML file that has characters outside the first 127 – then the trouble starts. Pretty sure most Americans do not use character sets that only have a range of 0-127. I don't think I have every used a desktop OS that did. I might have used some big iron boxes before that but at that time I wasn't even aware that character sets existed.
    They might only use that range but that is a different issue, especially since that range is exactly the same as the UTF8 character set anyways.
    >
    The computer industry started with diskspace and memory at a premium. Anyone who suggested using 2 bytes for each character instead of one would have been laughed at. In fact we're lucky that the byte worked best as 8 bits or we might have had fewer than 256 bits for each character. There of course were numerous charactersets (or codepages) developed early on. But we ended up with most everyone using a standard set of codepages where the first 127 bytes were identical on all and the second were unique to each set. There were sets for America/Western Europe, Central Europe, Russia, etc.
    And then for Asia, because 256 characters were not enough, some of the range 128 – 255 had what was called DBCS (double byte character sets). For each value of a first byte (in these higher ranges), the second byte then identified one of 256 characters. This gave a total of 128 * 256 additional characters. It was a hack, but it kept memory use to a minimum. Chinese, Japanese, and Korean each have their own DBCS codepage.
    And for awhile this worked well. Operating systems, applications, etc. mostly were set to use a specified code page. But then the internet came along. A website in America using an XML file from Greece to display data to a user browsing in Russia, where each is entering data based on their country – that broke the paradigm.
    The above is only true for small volume sets. If I am targeting a processing rate of 2000 txns/sec with a requirement to hold data active for seven years then a column with a size of 8 bytes is significantly different than one with 16 bytes.
    Fast forward to today. The two file formats where we can explain this the best, and where everyone trips over it, is HTML and XML. Every HTML and XML file can optionally have the character encoding set in it's header metadata. If it's not set, then most programs assume it is UTF-8, but that is not a standard and not universally followed. If the encoding is not specified and the program reading the file guess wrong – the file will be misread.
    The above is out of place. It would be best to address this as part of Point 1.
    Point 1 – Never treat specifying the encoding as optional when writing a file. Always write it to the file. Always. Even if you are willing to swear that the file will never have characters out of the range 1 – 127.
    Now lets' look at UTF-8 because as the standard and the way it works, it gets people into a lot of trouble. UTF-8 was popular for two reasons. First it matched the standard codepages for the first 127 characters and so most existing HTML and XML would match it. Second, it was designed to use as few bytes as possible which mattered a lot back when it was designed and many people were still using dial-up modems.
    UTF-8 borrowed from the DBCS designs from the Asian codepages. The first 128 bytes are all single byte representations of characters. Then for the next most common set, it uses a block in the second 128 bytes to be a double byte sequence giving us more characters. But wait, there's more. For the less common there's a first byte which leads to a sersies of second bytes. Those then each lead to a third byte and those three bytes define the character. This goes up to 6 byte sequences. Using the MBCS (multi-byte character set) you can write the equivilent of every unicode character. And assuming what you are writing is not a list of seldom used Chinese characters, do it in fewer bytes.
    The first part of that paragraph is odd. The first 128 characters of unicode, all unicode, is based on ASCII. The representational format of UTF8 is required to implement unicode, thus it must represent those characters. It uses the idiom supported by variable width encodings to do that.
    But here is what everyone trips over – they have an HTML or XML file, it works fine, and they open it up in a text editor. They then add a character that in their text editor, using the codepage for their region, insert a character like ß and save the file. Of course it must be correct – their text editor shows it correctly. But feed it to any program that reads according to the encoding and that is now the first character fo a 2 byte sequence. You either get a different character or if the second byte is not a legal value for that first byte – an error.
    Not sure what you are saying here. If a file is supposed to be in one encoding and you insert invalid characters into it then it invalid. End of story. It has nothing to do with html/xml.
    Point 2 – Always create HTML and XML in a program that writes it out correctly using the encode. If you must create with a text editor, then view the final file in a browser.
    The browser still needs to support the encoding.
    Now, what about when the code you are writing will read or write a file? We are not talking binary/data files where you write it out in your own format, but files that are considered text files. Java, .NET, etc all have character encoders. The purpose of these encoders is to translate between a sequence of bytes (the file) and the characters they represent. Lets take what is actually a very difficlut example – your source code, be it C#, Java, etc. These are still by and large "plain old text files" with no encoding hints. So how do programs handle them? Many assume they use the local code page. Many others assume that all characters will be in the range 0 – 127 and will choke on anything else.
    I know java files have a default encoding - the specification defines it. And I am certain C# does as well.
    Point 3 – Always set the encoding when you read and write text files. Not just for HTML & XML, but even for files like source code. It's fine if you set it to use the default codepage, but set the encoding.
    It is important to define it. Whether you set it is another matter.
    Point 4 – Use the most complete encoder possible. You can write your own XML as a text file encoded for UTF-8. But if you write it using an XML encoder, then it will include the encoding in the meta data and you can't get it wrong. (it also adds the endian preamble to the file.)
    Ok, you're reading & writing files correctly but what about inside your code. What there? This is where it's easy – unicode. That's what those encoders created in the Java & .NET runtime are designed to do. You read in and get unicode. You write unicode and get an encoded file. That's why the char type is 16 bits and is a unique core type that is for characters. This you probably have right because languages today don't give you much choice in the matter.
    Unicode character escapes are replaced prior to actual code compilation. Thus it is possible to create strings in java with escaped unicode characters which will fail to compile.
    Point 5 – (For developers on languages that have been around awhile) – Always use unicode internally. In C++ this is called wide chars (or something similar). Don't get clever to save a couple of bytes, memory is cheap and you have more important things to do.
    No. A developer should understand the problem domain represented by the requirements and the business and create solutions that appropriate to that. Thus there is absolutely no point for someone that is creating an inventory system for a stand alone store to craft a solution that supports multiple languages.
    And another example is with high volume systems moving/storing bytes is relevant. As such one must carefully consider each text element as to whether it is customer consumable or internally consumable. Saving bytes in such cases will impact the total load of the system. In such systems incremental savings impact operating costs and marketing advantage with speed.

  • Does the . character a reserved character?

    Hi,
    I would like to search the following information in a full text index: *10.1139/f91-051* I am then submit the following query:
    select * from mytable where contains(my_column,'"10.1139/f91-051" WITHIN doi') > 0
    but it does not return any data. However, when I replace the *.* character by a _*, I can retrieve my document:
    select * from mytable where contains(my_column,'"10_1139/f91-051" WITHIN doi') > 0
    Does the *.* character a reserved character? But when I try to escape it, it does not work neither:
    select * from mytable where contains(my_column,'"10\.1139/f91-051" WITHIN doi') > 0
    What did I do wrong?
    In the same way, what query should I submit to find all the I.B.M. words from my index for exemple?
    Kind regards,
    Fred
    Edited by: user503159 on 31 juil. 2009 02:29

    I'm unable to reproduce this exactly as you've stated.
    A few things to note:
    - The double quotes in your query have no effect. There is no "phrase" operator in Oracle Text, tokens that follow each other are a phrase by default
    - The "-" character is a special operator, and needs to be escaped to be treated as a literal (you can precede it with a backslash or put braces (curly brackets) round the whole search term)
    - "\" and "/" are break characters by default.
    - "." is a join character ONLY within numbers. It's a break character within normal alphabetic text.
    Run the folliowing:
    -- drop table t;
    create table t (x varchar2(2000));
    insert into t values ('<doi>10.1139/f91-051</doi>');
    create index ti on t(x) indextype is ctxsys.context parameters ('section group ctxsys.auto_section_group');
    select token_text, decode(token_type, 0, 'Normal', 2, 'Zone Section') as "Token Type" from dr$ti$i order by token_type;The last query shows us what tokens are indexed. We should see:
    TOKEN_TEXT                                                       Token Type
    051                                                              Normal
    F91                                                              Normal
    10.1139                                                          Normal
    DOI                                                              Zone SectionSo we can run a query without the break characters
    SQL> select * from t where contains (x, '10.1139 f91 051 within doi') > 0;
    X
    <doi>10.1139/f91-051</doi>or we can run a query with the break characters in it, but with the "-" character escaped:
    SQL> select * from t where contains (x, '10.1139/f91\-051 within doi') > 0;
    X
    <doi>10.1139/f91-051</doi>The query that you claimed worked does not work for me because the "-" operator is not escaped (I'm on 11g - it's possible the behaviour is different in earlier versions, but unlikely)
    SQL> select x from t where contains(x,'"10_1139/f91-051" WITHIN doi') > 0;
    no rows selectedAs for your question about searching for "I.B.M.", you can search for "I.B.M." or "I B M" and it will find it. You can also set "." to be a SKIPJOINS character, in which case you can search for "I.B.M." or "IBM" (but not "I B M").
    Note there is a gray area for tokens which are partly numeric - "1.23ABC" will probably be indexed as a single token, whereas "ABC1.23" will probably be indexed as two tokens "ABC1" and "23". This is because for performance reasons the lexer does not backtrack - when it hits the "." in the first example it thinks it is handling a pure number and therefore treats the "." as a numeric join character.

  • Keyword Escape Sequences: Big Problem

    Is there any character escape sequence for LR 1.1 that will allow the use of restricted characters in keywords?
    In PSE/CS, if you want to use a comma as part of a keyword, you put the whole phrase inside double quotes.
    "Harmon, Anthony" shows up in cataloging apps and others as:
    Harmon, Anthony
    Well, under LR 1.1 that no longer works and thousands of keywords/files and cross-references need to be redone unless I can find a solution.
    Any über-experts out there?

    Preferences will allow you to use . as a Keyword separator.
    Richard Earney
    http://inside-lightroom.com

  • Escaping ' and " characters in XML message

    Hello,
    I have the following issue with XML character escaping. The following characters need to be escaped: < > & ' and ".
    When I receive the message in the integration engine &lt and &gt are already escaped as expected. However ' and " are not.
    I have implemented a Java Mapping to replace " and ' with it escape characters & quot; and & apos;
    Problem however is that ALL " are escaped (including the XML prolog xml version = "1.0" )
    The XML then results in a parsing error when executing a test for the mapping.
    Do you have any idea how I can resolve this?`
    Thank you very much!
    Edited by: Florian Guppenberger on Jan 20, 2010 10:49 PM
    Edited by: Florian Guppenberger on Jan 20, 2010 10:49 PM

    When the message arrives everything is escaped, however after executing the XSLT mapping &apos; and &qot; are de-escaped again.
    I think both the SAX parster or the regex are a good approach to solve the problem.
    Christophe, do you have any sample code available for the replacement with a regex? Guess that I have to find the relevanr substrings first, and then having a replace all run on that. But it would be very helpful to see a code sample there....
    Thank you!
    Edited by: Florian Guppenberger on Jan 21, 2010 2:20 PM
    Edited by: Florian Guppenberger on Jan 21, 2010 4:02 PM

  • Add a logo to the header definition of an Interactive Report

    Hi Folks.
    Using Apex 3.1 and BI Publisher.
    I am enabling an Interactive Report region to output to PDF & Excel.
    Has anyone managed to add a logo to the Header/footer definition in the Print Attributes section?
    Is it possible? The region definition does not understand simple HTML syntax.
    If anyone would let me know if a) They've done it or b) It ain't possible that would be great.
    Many thanks.
    Dogfighter.

    Just reading through this thread. So perhaps a few comments might be helpful:
    - Interactive report regions do currently not support Report Layouts, you're limited to the built-in generic layout and won't be able to include images
    - You can add a button to your interactive report region page which could initiate the download of a report query, when doing this, you would get the result set of your report query not the interactive report region, so even if the queries are the same, you might have different filters applied to your interactive report
    - You can in fact include static images in your RTF report layouts using the BI Publisher Desktop Word Plug-In and MS Word, so you can have logos etc in your PDF documents. But report layouts currently only work with report queries and classic report regions
    - You can also include dynamic images in your PDF, e.g. based on images stored in a BLOB column, there's currently a character escaping issue causing some trouble with this, which will be fixed in 3.1.1, more on that once 3.1.1 is out (soon)
    - the print server overwrite is designed to point to a different print server than the one configured for your APEX instance, not to point to a specific report. So if your instance has BI Publisher configured, but for a specific report you want to do some special rendering using your own code, you can write e.g. a JSP, Servlet, etc that's doing the rendering, and then point yout report to that URL
    Hope this helps, we do plan to add support for report layout to interactive report regions in the next full release of Application Express
    Regards,
    Marc

  • Regular expressions in Workshop 8.1

    Hello,
    I'm posting this question here because I don't see a "jdk" subcategory in this
    newsgroup and it might be problem peculiar to Workshop.
    I'm trying to use the Pattern and Matcher classes in java.util.regex (JDK 1.4.2)
    in BEA Workshop 8.1, but I'm getting "ERROR: Unknown escape code" (red squiggly
    line appears under the regex and this message is the screen tip) whenever I try
    to use the backslash to escape a special character in the Pattern.compile() and
    the Pattern.matches() methods.
    For example, it doesn't allow "\d" to mean "any digit". For this particular one,
    I can get around the problem by specifying "[0-9]", but in the case of the period
    character, I'm stuck. I cannot use "\." However, the JDK API doc (http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html)
    says the backslash is to be used for this purpose, if I'm reading it correctly.
    Is this a problem with Workshop, and is there a workaround? I need to specify
    that I require one and exactly one period.
    Any help would be most appreciated!
    Thanks.

    Yes, I had read the Java doc, but I guess I hadn't fully understood it. Now I
    do! Thanks!!
    David
    Josh Eckels <[email protected]> wrote:
    This isn't particular to Workshop, but you'll need to use two
    backslashes in your source code. Inside a string, backslash is used to
    escape the next character so that you can enter special characters like
    newlines ('\n'), tabs ('\t'), etc.
    So, in order to enter a backslash character into your string, you need
    to escape it, like '\\'.
    There's a small section on this in the java.util.regex.Pattern JavaDoc,
    under the "Backslashes, escapes, and quoting" header:
    Backslashes within string literals in Java source code are interpreted
    as required by the Java Language Specification as either Unicode escapes
    or other character escapes. It is therefore necessary to double
    backslashes in string literals that represent regular expressions to
    protect them from interpretation by the Java bytecode compiler. The
    string literal "\b", for example, matches a single backspace character
    when interpreted as a regular expression, while "\\b" matches a word
    boundary. The string literal "\(hello\)" is illegal and leads to a
    compile-time error; in order to match the string (hello) the string
    literal "\\(hello\\)" must be used.
    Josh
    David Chang wrote:
    Hello,
    I'm posting this question here because I don't see a "jdk" subcategoryin this
    newsgroup and it might be problem peculiar to Workshop.
    I'm trying to use the Pattern and Matcher classes in java.util.regex(JDK 1.4.2)
    in BEA Workshop 8.1, but I'm getting "ERROR: Unknown escape code" (redsquiggly
    line appears under the regex and this message is the screen tip) wheneverI try
    to use the backslash to escape a special character in the Pattern.compile()and
    the Pattern.matches() methods.
    For example, it doesn't allow "\d" to mean "any digit". For this particularone,
    I can get around the problem by specifying "[0-9]", but in the caseof the period
    character, I'm stuck. I cannot use "\." However, the JDK API doc
    (http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html)
    says the backslash is to be used for this purpose, if I'm reading itcorrectly.
    Is this a problem with Workshop, and is there a workaround? I needto specify
    that I require one and exactly one period.
    Any help would be most appreciated!
    Thanks.

  • Returning XML String From Servlet

              Is there a simple way to disable the HTML character escaping when returning
              a string from a servlet. The returned string contains well formed XML, and
              I don't want the tags converted to > and < meta characters in the
              HTTP reply.
              The code is basically "hello world", version 7.0 SP2.
              Thanks
              > package xxx.servlet;
              >
              > import weblogic.jws.control.JwsContext;
              >
              >
              > /**
              > * @jws:protocol http-xml="true" form-get="false" form-post="false"
              > */
              > public class HelloWorld
              > {
              > /** @jws:context */
              > JwsContext context;
              >
              > /**
              > * @jws:operation
              > * @jws:protocol http-xml="false" form-post="true" form-get="false" soap-s
              tyle="document"
              > * @jws:return-xml xml-map::
              > * <HelloWorldResponse xmlns="http://www.xxx.com/">
              > * {return}
              > * </HelloWorldResponse>
              >
              > * ::
              > * @jws:parameter-xml xml-map::
              > * <HelloWorld xmlns="http://www.xxx.com/">
              > * <ix>{ix}</ix>
              > * <contents>{contents}</contents>
              > * </HelloWorld>
              >
              > * ::
              > */
              > public String HelloWorld(String s)
              > {
              > return "<a> xyz </a>";
              > }
              > }
              

              Radha,
              We have a client/server package which speaks SOAP over a
              streaming HTTP channel for which we are writing a WebLogic
              servlet. For reasons of efficiency, we want to deserialize
              only the very top-level tags of the messages as they pass
              through the servlet. Yes, in theory, we should probably
              deserialize and validate the entire message contents...
              When we add support for other clients, we will fully
              deserialize inside those servlets.
              I have not looked any further into how to stop the inner
              tags from being escaped yet -- it is an annoyance more than
              a disaster, since the client handle meta escapes.
              My current guess is to use ECMAScript mapping...
              -Tony
              "S.Radha" <[email protected]> wrote:
              >
              >"Tony Hawkins" <[email protected]> wrote:
              >>
              >>Is there a simple way to disable the HTML character escaping when returning
              >>a string from a servlet. The returned string contains well formed XML,
              >>and
              >>I don't want the tags converted to > and < meta characters in the
              >>HTTP reply.
              >>
              >>The code is basically "hello world", version 7.0 SP2.
              >
              >>
              >>Thanks
              >>
              >>> package xxx.servlet;
              >>>
              >>> import weblogic.jws.control.JwsContext;
              >>>
              >>>
              >>> /**
              >>> * @jws:protocol http-xml="true" form-get="false" form-post="false"
              >>> */
              >>> public class HelloWorld
              >>> {
              >>> /** @jws:context */
              >>> JwsContext context;
              >>>
              >>> /**
              >>> * @jws:operation
              >>> * @jws:protocol http-xml="false" form-post="true" form-get="false"
              >>soap-s
              >>tyle="document"
              >>> * @jws:return-xml xml-map::
              >>> * <HelloWorldResponse xmlns="http://www.xxx.com/">
              >>> * {return}
              >>> * </HelloWorldResponse>
              >>>
              >>> * ::
              >>> * @jws:parameter-xml xml-map::
              >>> * <HelloWorld xmlns="http://www.xxx.com/">
              >>> * <ix>{ix}</ix>
              >>> * <contents>{contents}</contents>
              >>> * </HelloWorld>
              >>>
              >>> * ::
              >>> */
              >>> public String HelloWorld(String s)
              >>> {
              >>> return "<a> xyz </a>";
              >>> }
              >>> }
              >>
              >>
              >Hi Tony,
              >
              > Can you let me know for what purpose you want to disable the
              >HTML character
              >escaping.In case if you
              >
              >have tried this using someway,pl. let me know.
              >
              >rgds
              >Radha
              >
              >
              

  • XML to CSV routine using XSLT.  Oracle bugs?

    I'm trying to write some XSLT so that I can apply it to any given XML using  XMLTransform to generate a flattened CSV structure.  My input can be any XML document, with any number of nested levels so the structure isn't known to the XSLT.  I'm fairly new to XSLT but am having problem with Oracle's version of it.  I've tested on both 10gR2 and 11gR2.
    CSV Rules :
    Adjacent fields must be separated by a comma
    Embedded commas in fields are escaped e.g. 15, Maple Street => "15, Maple Street"
    Embedded quotes in fields are escaped.  e.g. O'Brien => "O'Brien" or John "Jonner" McNabb => "John ""Jonner"" McNabb"
    Embedded CR / LF or CRLF in fields are escaped with quotes.
    Records are separated with CRLF pairs
    Flattening Rules :
    The text of leaf elements (elements without children) are output even if they are empty
    Any element with text is output
    A new line occurs whenever the nesting level changes. i.e. If an element has children.
    When I run the following XML and my XSLT through Oracle I get results inconsistent with results I get when I run the XML and XSLT through online XSLT utils (including W3C's test pages).
    with qryXML as (
      select xmltype(q'[
      <email>
        <to>Steve O'Brien</to>
        <cc/>
        <from>Jane "The Smiler" Griff</from>
        <heading>Reminder</heading>
        <body>Hey, don't forget me this weekend!  I've enclosed some pics from last weekend
      Love Jane
      </body>
        <attachments>
          <attachment>
            <filename>Dance.jpg</filename>
            <encoding>MIME</encoding>
          </attachment>
          <attachment>
            <filename>Signature.txt</filename>
            <encoding/>
          </attachment>
        </attachments>
      </email>
      ]') as XMLDATA from dual)
    select
       XMLTransform(q.XMLDATA,
          xmltype(q'[
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="text"/>
        <xsl:strip-space elements="*"/>
        <xsl:template match="*[text() or not(*)]">
            <xsl:if test="position() &gt; 1">
                <xsl:text>,</xsl:text>
            </xsl:if>
        <xsl:call-template name="display_csv_field">
          <xsl:with-param name="field" select="."/>
        </xsl:call-template>
            <xsl:if test="not(following-sibling::*[text() or not(*)])">
                <xsl:text>
    </xsl:text>         
            </xsl:if>
        </xsl:template>
      <xsl:template name="display_csv_field">
        <xsl:param name="field"/>
        <xsl:variable name="CRLF">
          <xsl:text>&#13;&#10;</xsl:text>
        </xsl:variable>
        <xsl:variable name="CR">
          <xsl:text>&#13;</xsl:text>
        </xsl:variable>
        <xsl:variable name="LF">
          <xsl:text>&#10;</xsl:text>
        </xsl:variable>
        <xsl:variable name="apos">'</xsl:variable>   
        <xsl:choose>
          <xsl:when test="contains( $field, '&quot;' )">
            <!-- Field contains a quote. So escape  -->
            <xsl:text>"</xsl:text>
            <xsl:call-template name="escape_quotes">
              <xsl:with-param name="string" select="$field" />
            </xsl:call-template>
            <xsl:text>"</xsl:text>
          </xsl:when>
          <xsl:when test="contains( $field, ',' ) or
                          contains( $field, $apos ) or
                          contains( $field, $CRLF ) or
                          contains( $field, $CR ) or
                          contains( $field, $LF )" >
            <!-- Field contains a comma, apostrophe and/or a linefeed, so quote -->
            <xsl:text>"</xsl:text>
            <xsl:value-of select="$field" />
            <xsl:text>"</xsl:text>
          </xsl:when>
          <xsl:otherwise>
            <!-- No need to enclose this field in quotes. -->
            <xsl:value-of select="$field" />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>
      <xsl:template name="escape_quotes">
        <xsl:param name="string" />
        <xsl:value-of select="substring-before( $string, '&quot;' )" />
        <xsl:text>""</xsl:text>
        <xsl:variable name="substring_after_first_quote"
                      select="substring-after( $string, '&quot;' )" />
        <xsl:choose>
          <xsl:when test="not( contains( $substring_after_first_quote, '&quot;' ) )">
            <xsl:value-of select="$substring_after_first_quote" />
          </xsl:when>
          <xsl:otherwise>
            <!-- The substring after the first quote contains a quote.
                 So, we call ourself recursively to escape the quotes
                 in the substring after the first quote. -->
            <xsl:call-template name="escape_quotes">
              <xsl:with-param name="string" select="$substring_after_first_quote" />
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template> 
    </xsl:stylesheet>
    )) from qryXML q  
    Output from Oracle (which appears incorrect)
    &quot;Steve O&apos;Brien&quot;&quot;Jane &quot;&quot;The Smiler&quot;&quot; Griff&quot;Reminder&quot;Hey, don&apos;t forget me this weekend!  I&apos;ve enclosed some pics from last weekend
      Love Jane
      &quot;
    Dance.jpgMIME
    Signature.txt
    Output from most other XSLT test environments (which appears correct):
    "Steve O'Brien",,"Jane ""The Smiler"" Griff",Reminder,"Hey, don't forget me this weekend!  I've enclosed some pics from last weekend
    Love Jane
    Dance.jpg,MIME
    Signature.txt,
    Oracle's XSLT handling appears incorrect in several ways:
    1. There is no comma delimiter separating fields and on investigation, position() is always returning 1, which is incorrect.  From XSLT reference "The position function returns a number equal to the context position from the expression evaluation context." ...."the position, or index number, of the node, relative to all the selected nodes in the node list."  Therefore any node in a node list should be indexable with position.   I am selecting a node list *[text() or not(*)] => Any nodes with text or with no children, yet position of each node in this list is always 1.
    2. My XSLT says the output is text, yet Oracle is still using HTML character escaping which is not text!  &quot; instead of " and &apos; instead of '.  I could search and replace, but I shouldn't have to.
    Can anyone explain why Oracle's XSLT differs from other XSLT processors and offer suggestions to solve these issues.  Are these bugs?

    Here's an example tested on 11.2.0.2 :
    SQL> set scan off
    SQL> set long 5000
    SQL> set lines 200
    SQL> var doc clob
    SQL> begin
      2   :doc := '<email>
      3      <to>Steve O''Brien</to>
      4      <cc/>
      5      <from>Jane "The Smiler" Griff</from>
      6      <heading>Reminder</heading>
      7      <body>Hey, don''t forget me this weekend!  I''ve enclosed some pics from last weekend
      8    Love Jane
      9    </body>
    10      <attachments>
    11        <attachment>
    12          <filename>Dance.jpg</filename>
    13          <encoding>MIME</encoding>
    14        </attachment>
    15        <attachment>
    16          <filename>Signature.txt</filename>
    17          <encoding/>
    18        </attachment>
    19      </attachments>
    20    </email>';
    21  end;
    22  /
    PL/SQL procedure successfully completed.
    SQL> select xmlcast(
      2           xmlquery(
      3           'declare function local:formatField ($e as element()) as xs:string
      4            {
      5              let $t := ora:replace($e, "&quot;", "&quot;&quot;")
      6              return if (    contains($t, "&quot;")
      7                          or contains($t, ",")
      8                          or contains($t, "&apos;")
      9                          or contains($t, "&#13;")
    10                          or contains($t, "&#10;") )
    11                     then concat("&quot;", $t, "&quot;")
    12                     else $e
    13            }; (::)
    14            string-join(
    15              for $i in //*[*[text() or not(node())]]
    16              return
    17                string-join(
    18                  for $j in $i/*[text() or not(node())]
    19                  return local:formatField($j)
    20                , ","
    21                )
    22            , "&#13;&#10;"
    23            )'
    24             passing xmltype(:doc)
    25             returning content
    26           )
    27           as clob
    28         ) as result
    29  from dual ;
    RESULT
    "Steve O'Brien",,"Jane ""The Smiler"" Griff",Reminder,"Hey, don't forget me this
    weekend!  I've enclosed some pics from last weekend
      Love Jane
    Dance.jpg,MIME
    Signature.txt,
    We could also use a single ora:matches function in place of the OR'ed contains but it doesn't appear to work on 11.2.0.3, got an internal error :
    ORA-00600: code d'erreur interne, arguments : [qmxqrs_xvm_popLastFuncArgAsStr:1], [], [], [], [], [], [], [], [], [], [], []

  • How to include CDATA in xml generated from XQuery

    I need to include Cdata in the xml generated from my xquery which is given below:
    I tried using XMLCDATA, but not getting the desired output. What am I doing wrong?
    SELECT XMLQuery('<InsUpdDel>
    for $crv in ora:view("RELATION")
    return
    <first>
    <eff_date>{$crv/ROW/EFF_DATE/text()}</eff_date>
    <source>{$crv/ROW/SOURCE/text()}</source>
    <key>
    <fld>
    <id>from_type</id>
    <val>XMLCDATA({$crv/ROW/FROM_ENT_TYPE/text()})</val>
    </fld>
    <fld>
    <id>from_ent_id</id>
    <val>{$crv/ROW/FROM_ENT_ID/text()}</val>
    </fld>
    </key>
    </first>}</InsUpdDel>'
    RETURNING CONTENT)
    FROM dual;
    The output I get is XMLCDATA(C), while the desired output is <![CDATA[C]]>

    Forgive me my vanity to think I can contribute by kicking doors open that are probably already wide open....I might create more confusion, but perhaps it helps some of the readers of this thread....
    In general it is not such a good idea to use "string" functions to create (serialized) XML. XML tools (including Oracle XML DB) go through a lot of effort to make sure that when a "native" XML structure is serialized to a string, the XML rules are strictly obeyed (e.g. special character escaping).
    Just assume e.g. that the $i/Reference from above contains something like ]]><
    The resulting XML would not be valid.
    More info on serializing XML in the context of XQuery is available from
    - http://www.w3.org/TR/xquery/#id-serialization
    - http://www.w3.org/TR/xslt-xquery-serialization/
    - http://www.w3.org/TR/xslt-xquery-serialization/#XML_CDATA-SECTION-ELEMENTS
    Unfortunately I do not think Oracle XML DB currently implements these parts of the spec (perhaps 11g will)...leaving the OP's question unanswered.
    Anyway, if going the route of serializing the XML through string functions, it is always good to realize the dangers of such an approach.
    Peter

  • HTTP XML return special characters?

    hi!
    we implemented a dynamic report with an http request from BI to a php page which returns the XML dataset.
    works pretty good apart from the fact that the report crashes, when there are special chars (e.g. & ; @ ...)
    within the element values (e.g. <email>...@... . de</email>).
    we tried to encode the XML dataset with utf8 but unfortunately that doesnt help either.
    anybody an idea how to solve that problem?
    thanks in advance.
    cheers,
    john

    Hi John,
    keep in mind that you should quote such special characters. For example:
    incorrect: <blah>this & that</blah>
    correct:   <blah>this &amp; that</blah>Your program that generates the XML datafile needs to do this correct character escaping/quoting.
    Check these pages for more information on this:
    http://www.xml.com/pub/a/2001/01/31/qanda.html
    http://en.wikipedia.org/wiki/XML#Numeric_character_references
    best regards,
    David.

  • Making an rxvt-unicode (urxvt) cursor act the same as a console cursor

    Is there a way to emulate the exact same cursor behavior in urxvt as one would find on the Linux console (i.e. not under X11).
    I am used to working at the console and in this environment, the cursor is a blinking underscore by default.  However, it's color, shape, and blinking behavior can be controlled via character escape sequences.  Some applications take advantage of these facilities.
    I can configure urxvt to show the cursor as either a block or underscore, and also enable or disable blinking, but these options are either set in a configuration file or at the command line.  I cannot figure out how to enable them at run time.  The usual to set the cursor escape sequences seem to be ignored.
    Has anyone successfully managed this?

    bohoomil wrote:
    If you mean blinking underscore, put the following to your .Xresources:
    URxvt.cursorBlink: 1
    URxvt.cursorUnderline: 1
    -- or launch urxvt with -bc -uc parameters.
    Thanks, though unfortunately these are the configuration options and command line switches that I was referring to.  Do you know if there is a way to change the appearance of the cursor at run time?  In other words, when the program is running?
    Ideally, I'd like urxvt to respond to the ANSI cursor codes which affect the cursor appearance.  I've been hunting around trying to determine if this is implemented in urxvt but I haven't found much on the subject in the urxvt man pages.

Maybe you are looking for

  • Duplicates in Users form (FND_USER)

    Hi, In System Admin: Security User: Define, When I queried for some user "ABC", i got the error < ORA-01422:exact fetch returns more than requested number of rows >. Refer below link for reference. https://docs.google.com/leaf?id=0B5DraJWCbaqSMDkwZDl

  • What is the best way to shorten a song so it will fit on a slideshow.

    What is the best way to shorten a song so it will fit on a slideshow so I do not have to remove or add pictures. Thank you in advance

  • Directory Traversal and Empty Directory Issue. Please Help!

    Hi I am building an application which is aimed at traversing the entire hard disk or a given folder and extract files from the folder, sub-folders and so on. I am able to currently traverse the disk and able to gain access to the files which are nest

  • WSDL JSP creation problem

    Hi, I'm triyng to build a Web Service for WLS6.1SP2, using Ant 1.4.1. Because our WS project should compile with other Projects, I cannot use WebLogic's ant and thus 'wsgen' task. I tried <taskdef name="wsgen" classpath="${ANT_HOME}/lib/ant.jar;${WL_

  • Software window off-screen

    For some reason, when I run software for a online poker site the "table view" window will not appear on screen. (This occurs when i click on "open table view", etc.). I know it is open b/c I can hear the sounds from the window. I do not know how to h