Any way to generate a single quote (') with XSLT?

Hi:
I guess this is really an XSLT question. I'm using the Transform() method of an XMLType variable to apply a style sheet. The XML in the variable is just something simple like
<TBL>
<LAST_NAME>LIKE|JONES</LAST_NAME>
<FIRST_NAME>=|MARY</FIRST_NAME>
<AGE>=|50</AGE>
</TBL>
I am trying to get a stylesheet to transform something like the above into SQL such as
Select * from foo where LAST_NAME like 'JONES'
and FIRST_NAME ='MARY'
and AGE = 50But to do this, I need to generate the single quotes around the search terms and I can't get anything but LAST_NAME LIKE &apos;JONES&apos;. Is there a way to do this? For now I am generating a ~ and replacing ~ for ' throughout the generated SQL text but that's a pretty sorry solution.
I thought that something like <xsl:text disable-output-escaping="yes">&amp;</xsl:text> was going to work but then found out it has been deprecated. I was thinking character-map might work but that's an XSLT 2.0 thing and apparently 10g is on XSLT 1.0? In any case, it had no idea what I was trying to do with a character map.
So, am I overlooking an obvious way to get my stylesheet to insert apostrophes?
Thanks.

It's 10.2.0.4.
Here's the procedure that accepts the XML/XSL clobs and tries to produce a SQL statement.
PROCEDURE GetSQLQueryFromXML(XMLClob in CLOB, XSLStylesheet in CLOB,
            SQLQuery out CLOB, status out integer) IS
    -- Define the local variables
  xmldata               XMLType;  -- The XMLType format of the XML to transform
  xsldata               XMLType;  -- The XMLType format of the stylesheet to apply
  sqlQuery_XMLType      XMLType;  -- The XMLType format of the SQL query.
  v_SQLQuery            Clob;     -- Holds XML Clob before translating ~ to '
BEGIN
status := -1;  -- Initially unsuccessful
  -- Get the XML document using the getXML() function defined in the database.
  -- Since XMLType.transform() method takes XML data as XMLType instance,
  -- use the XMLType.createXML method to convert the XML content received
  -- as CLOB into an XMLType instance.
  xmldata := XMLType.createXML(XMLClob);
  -- Get the XSL Stylesheet using the getXSL() function defined in the database.
  -- Since XMLType.transform() method takes an XSL stylesheet as XMLType instance,
  -- use the XMLType.createXML method to convert the XSL content received as CLOB
  -- into an XMLType instance.
  xsldata := XMLType.createXML(XSLStylesheet);
  -- Use the XMLtype.transform() function to get the transformed XML instance.
  -- This function applies the stylesheet to the XML document and returns a transformed
  -- XML instance.
  sqlQuery_XMLType := xmldata.transform(xsldata);
  -- Return the transformed XML instance as a CLOB value.   
  v_SQLQuery := sqlQuery_XMLType.getClobVal();
  -- Change tildas to apostrophes.  Currently unable to get an XSLT transformation
  -- to insert single quotes, so we're inserting ~ instead.  Now we need to
  -- translate all ~s to 's in our query.
  SQLQuery := translate(to_char(v_SQLQuery),'~','''');
  status := 1; -- Everything went fine to get here
EXCEPTION
  WHEN OTHERS THEN         
    raise_application_error
    (-20102, 'Exception occurred in GetSQLQueryFromXML :'||SQLERRM);
END GetSQLQueryFromXML;The XML it works off of is
    someXML CLOB :=
    to_clob('<?xml version="1.0" encoding="windows-1252" ?>
<variable table_name="SOME_PERSON_TABLE" query_type="PERSON">
  <item>
    <fieldName><![CDATA[PERSON_KEY]]></fieldName>
    <criteria><![CDATA[=]]></criteria>
    <fieldType><![CDATA[Integer]]></fieldType>
    <value><![CDATA[123456789]]></value>
  </item>
  <item>
    <fieldName><![CDATA[LAST_NAME]]></fieldName>
    <criteria><![CDATA[=]]></criteria>
    <fieldType><![CDATA[String]]></fieldType>
    <value><![CDATA[DOE]]></value>
  </item>
  <item>
    <fieldName><![CDATA[FIRST_NAME]]></fieldName>
    <criteria><![CDATA[=]]></criteria>
    <fieldType><![CDATA[String]]></fieldType>
    <value><![CDATA[JOHN]]></value>
  </item>
  <item>
    <fieldName><![CDATA[MIDDLE_NAME]]></fieldName>
    <criteria><![CDATA[-]]></criteria>
    <fieldType><![CDATA[String]]></fieldType>
    <value />
  </item>
  <item>
    <fieldName><![CDATA[SUFFIX]]></fieldName>
    <criteria><![CDATA[-]]></criteria>
    <fieldType><![CDATA[String]]></fieldType>
    <value />
  </item>
</variable>');And the corresponding XSLT that should translate it is:
  myStylesheet  CLOB :=
  to_clob('<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- <xsl:preserve-space elements="list-of-element-names"/> -->
  <!-- We just want the SQL text output.  No XML declaration etc. -->
  <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<!-- Apostrophes will be made tildas and the PL/SQL will translate those to -->
<!-- apostrophes for the final SQL string. -->
<xsl:variable name="apos">~</xsl:variable>
  <xsl:template match="/">
    select * from
    <xsl:value-of select="variable/@table_name"/>
    where 1=1
    <xsl:for-each select="variable/child::node()">
      <xsl:choose>
        <!-- if the value node is not null... -->
        <xsl:when test="./value/text()[normalize-space(.)]">
        <!-- There is another predicate.  Add the AND term and the predicate -->
          AND <xsl:value-of select="./fieldName"/>
          <xsl:text> </xsl:text>
          <xsl:value-of select="./criteria"/>
          <xsl:text> </xsl:text>       
          <xsl:choose>
            <xsl:when test="string(./fieldType)=''String''">
              <xsl:copy-of select="$apos" />
              <xsl:value-of select="./value"/>
              <xsl:copy-of select="$apos" />
            </xsl:when>         
            <xsl:when test="string(./fieldType)=''Clob''">
              <xsl:copy-of select="$apos" />
              <xsl:value-of select="./value"/>
              <xsl:copy-of select="$apos" />
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="./value"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:when>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>');Basically if the VALUE element has a value then the fieldType is checked. If fieldType is String or Clob then we'll need the apostrophes. For now I'm putting in tildas and changing them later.

Similar Messages

  • How to concatenate single quote with any field like 'VBAK'

    Hi,
    How to concatenate single quote with any fields.
    say for example I have table name as MARA, I have to pass that table name to other fields with single quote , like I have to pass that as
    tab name = 'MARA'.
    but how to do this,
    below statement will not work
    concatenate '''  'MARA'   ''' into string.. it's giving syntax error...
    Regards,
    Mrunal

    gv_name = 'MARA'.
    gc_quote = '''.
    CONCATENATE gc_quote gv_name gc_quote INTO value.
    Pushpraj

  • Is there any way to generate Gantt chart by using oracle 9iDS?

    Is there any way to generate Gantt chart by using oracle 9i reports builder
    Can you please send me the link or more information on oracle 9iDS.
    Thanks

    Hi,
    Oracle9iDS itself doesn't support creating Gantt charts. The option oyu have is to use Oracle Graphics 6i, because there is no Graphics in 9i, and configure it to run with Oracle9i Forms. There exist a whitepaper at otn.oracle.com/products/forms that explains how to make Graphics 6i work with Forms 9i.
    Frank

  • SQL Injection, replace single quote with two single quotes?

    Is replacing a single quote with two single quotes adequate
    for eliminating
    SQL injection attacks? This article (
    http://www.devguru.com/features/kb/kb100206.asp
    ) offers that advice, and it
    enabled me to allow users to search name fields in the
    database that contain
    single quotes.
    I was advised to use "Paramaterized SQL" in an earlier post,
    but I can't
    understand the concept behind that method, and whether it
    applies to
    queries, writes, or both.

    Then you can use both stored procedures and prepared
    statements.
    Both provide better protection than simply replacing
    apostrophes.
    Prepared statements are simple:
    Set myCommand = Server.CreateObject("ADODB.Command")
    ...snip...
    myCommand.CommandText = "INSERT INTO Users([Name], [Email])
    VALUES (?, ?)"
    ...snip...
    myCommand.Parameters.Append
    myCommand.CreateParameter("@Name",200,1,50,Name)
    myCommand.Parameters.Append
    myCommand.CreateParameter("@Email",200,1,50,Email)
    myCommand.Execute ,,128 'the ,,128 sets execution flags that
    tell ADO not to
    look for rows to be returned. This saves the expense of
    creating a
    recordset object you don't need.
    Stored procedures are executed in a similar manner. DW can
    help you with a
    stored procedure through the "Command (Stored Procedure)"
    server behavior.
    You can see a full example of a prepared statement by looking
    at DW's
    recordset code after you've created a recordset using version
    8.02.
    "Mike Z" <[email protected]> wrote in message
    news:eo5idq$3qr$[email protected]..
    >I should have repeated this, I am using VBScript in ASP,
    with an Access DB.
    >

  • Any way to provide components to vendor with-out using 541.

    Hi Friends,
    Is there any way to provide components to Vendor with out movement-541.
    Because, system allowing to do GR 101 for parent model (posted 543 automatically), without performing 541.
    Please advise,
    Best regards,
    RAMAN.

    Hi Ven,
    Your problem is not totally clear, please give more details.
    Standard procedure is to send out the subcon-components to your subcontractor via MVT 541 (MB1B + 541 + with or w/o PO reference; ME2O).
    Then you can receive the subcontracting good via MVT 101 and consume the components via 543.
    You can change the stock level of the components by inventory bookings as well
    Please write some sentences about your requirement!
    Thanks,
    Csaba

  • HT4757 Will this software make my Canon Powershot A700 work with os x 10.8.2 and iPhoto 11 v. 9.4.1?  Is there any way to get my camera compatible with this computer?

    Will this software make my Canon Powershot A700 work with os x 10.8.2 and iPhoto 11 v. 9.4.1?  Is there any way to get my camera compatible with this computer?

    First Try the following:
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
         User/Home/Library/ Preferences folder.
    2 - delete iPhoto's cache file, Cache.db, that is located in your
    User/Home/Library/Caches/com.apple.iPhoto folder (Snow Leopard and Earlier).
    or with Lion and Mt. Lion from the User/Library/Containers/com.apple.iPhoto/
    Data/Library/Caches/com.apple.iPhoto folder
    3 - launch iPhoto and try again.
    NOTE:  In Lion and Mountain Lion the Library folder is now invisible. To make it permanently visible enter the following in the Terminal application window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.
    If that doesn't help apply the two fixes below in order as needed:
    Fix #1
    1 - launch iPhoto with the Command+Option keys held down and rebuild the library.
    2 - run Option #4 to rebuild the database.
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    1 - download iPhoto Library Manager and launch.
    2 - click on the Add Library button and select the library you want to add in the selection window..
    3 - Now that the library is listed in the left hand pane of iPLM, click on your library and go to the Library ➙ Rebuild Library menu option.
    4 - In the next  window name the new library and select the location you want it to be placed.
    5 - Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments.  However, books, calendars, cards and slideshows will be lost. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.

  • Is there any way to delete a single occurrence from a repeating event in Calendar?

    I've got an event that repeats every week...except for next week. Is there any way to delete a single occurrence, or do I just have to stop the repeating event the week before and restart it the week after?

    it depends on the system load as well as the number of records that ur present request is carrying.. if the number of records are huge then obviously the time of deletion will also takes longer time...
    The only way is to maintain the multiple Wp assigning to ur activity.. and thus the deletion will takes place quickly.. and this also needs to be taken into the consideration of the other loads as well..
    Thanks
    Hope this helps

  • Is there any way to lock my messages application with a password or something?

    is there any way to lock my messages application with a password or something?

    http://www.apple.com/feedback/iphone.html

  • Just upgraded to FF 12 from FF 3.6 and most of my favicons are now dotted line squares. Any way to get the favicons associated with each web site to load?

    Just upgraded to FF 12 from FF 3.6 and most of my favicons are now dotted line squares. Any way to get the favicons associated with each web site to load? I've seen some suggested code to add but I'm not web code savvy. Thanx!

    The CheckPlaces extension can restore favicons. It is also great for checking bookmarks to ensure that they are still valid.
    * https://addons.mozilla.org/en-US/firefox/addon/checkplaces/

  • How to replace single quote with double quote

    hai all,
    i have a problem,
    i am trying insert a string containing single quote into ms-access database.
    it is giving error.
    how can i avoid this .if i replace a single quote in the text with double quote it will defenitely
    insert into database.
    in java.lang.String
    replace () will not work to replace quote with double quote.
    any otherway to solve this problem.
    please mail me to [email protected]
    thank you
    sambareddy
    inida

    java.lang.String.replace () will not work to replace quote with double quote.Really?
    String x = ...
    x.replace( "'", "\"" );

  • Replace a string single quote(') with underscore(_)

    I have more than 100 tables in a schema.
    I have to find out if a string has a single quote in the column and replace it with an underscore.
    I have 2 columns CREATE_USER and UPDATE_USER in all the tables. Now i want to update the values if the string has a single quote in it.
    I tried it with execute immediate but it is not allowing underscore in the statement.
    DECLARE
       v_table_name    VARCHAR2 (30);
       v_column_name   VARCHAR2 (30);
       CURSOR c_name
       IS
          SELECT DISTINCT table_name, column_name
                     FROM user_tab_cols
                    WHERE column_name IN ('LOGIN', 'CREATE_USER', 'UPDATE_USER')
                      AND table_name NOT LIKE '%JN';
    BEGIN
       FOR rec IN c_name
       LOOP
          v_table_name     := rec.table_name;
          v_column_name    := rec.column_name;
          EXECUTE IMMEDIATE    'update '
                            || v_table_name
                            || ' set '
                            || v_column_name
                            || ' = REPLACE('
                            || v_column_name
                            || ','''',"_") where '
                            || v_column_name
                            || ' like "%''%"';
       END LOOP;
    END;
    /i am getting the below error:
    ORA-00904: "%'%": invalid identifier
    ORA-06512: at line 17Can anyone let me know what is the error in the statement and how to overcome it

    please try to replace your execute immediate with:
    EXECUTE IMMEDIATE  'update '
                            || v_table_name
                            || ' set '
                            || v_column_name
                            || ' = REPLACE('
                            || v_column_name
                            || ','''''''',''_'') where '
                            || v_column_name
                            || ' like ''%''''%''';You can check the statement when you take a look at the construction before like this:
    declare
      v_sql varchar2(1000);
    begin
       v_sql:= 'update '
                            || v_table_name
                            || ' set '
                            || v_column_name
                            || ' = REPLACE('
                            || v_column_name
                            || ','''''''',''_'') where '
                            || v_column_name
                            || ' like ''%''''%''';
       dbms_output.put_line(v_sql);
       execute immediate v_sql;
       ...Edited by: hm on 23.11.2010 01:43

  • Replace Single Quote with double quote

    Hi All,
    I have a String s="help'me'to'replace";
    i want to replace single quote( ' ) in to double quote ( " )
    The final out put should be like this help"me"to"replace
    ( Actually this string i have to pass in to an XML )
    Please help any one

    s.replaceAll("'","\"");{code}
    or just one of the String#replace() methods.
    Edited by: sabre150 on Mar 17, 2009 11:48 AM                                                                                                                                                                                                                                                               

  • Is there any way to sync Outlook for Mac with iPhone? I have tried everything but not successful. Apple says it is not possible to sync contacts from Outlook for Mac to iPhone 5. Any help will be much appreciated.

    Is there any way to Sync contacts from Outlook for Mac to iPhone 5? Apple support says that only iTune can only sync contacts from "Contact" which is the default contact of Mac. If one is running Outllok on a Mac machine then it is not possible to sync the contacts with iPhone. It is strange that Apple distributors are promoting and offering machines with promise that Windows users can now run MS Office on Mac machines without any problem. While this is true, it is so strange that one cannot sync the contacts from MacBook Pro to iPhone5. If someone has found a way to sync contacts from Outlook to iPhone 5 please help as it is very frustrating to not be able to sync the contacts. Thanks, Amit.

    SEARCH!!!
    http://lmgtfy.com/?q=sync+outlook+mac+to+iphone

  • Is there ANY way to use another email address with iCloud?

    Apple let you use any email address as an Apple ID, but I really want to be able to use a non-Apple email address with my iCloud mail. Just about every email service (Gmail, Hotmail, etc) allows you to send from a third-party address (once you've done a security verification) so that you don't have to change your email address when switching services. iCloud seems to have no such option. Is there any way round this, or any way to put pressure on Apple to add this basic feature???

    rdepom wrote:
    Is there any way round this
    I'm afraid not
    or any way to put pressure on Apple to add this basic feature???
    http://www.apple.com/feedback/icloud.html - but I don't think it's very likely they'll change it.

  • Is there any way of getting Facetime to work with windows?

    I've just used Facetime for the first time and it worked like a dream. Is there any way Facetime can be used to phone someone with a PC using
    Windows?

    No, FaceTime uses a proprietary communications protocol that is incapatable with Windows.
    Allan

Maybe you are looking for

  • My iPod touch won't be recognized by my macbook.

    I plugged in my iPod touch to my macbook this morning and it doesn't even charge. To make sure it wasn't the cable or the USB port, I plugged another USB and it was working fine. It won't appear on either iTunes or Finder. I found a solution that was

  • Generally companys which combination of modules  want to implement crm  in

    hi experts generally companys which combination of modules  want to implement crm  in present scenario in topics like marketing,sales,service,mobilsales, Internet sales,web clint, win clint ,E comers,and so on.............. 1, All combinations 2, bes

  • Diff Between Internal Table with Occurs 0 & Field Groups

    Hi, Is there really any difference between just using an internal table with an OCCURS 0 statement-- which would write the entire table to paging space-- and using field-groups? How is Field-Groups is more effective than Internal tables with occurs 0

  • Rendered Nodes in JTree, Look&Feel Problem

    Hallo, I make a small JTree and write my own TreeNodeRenderer which renders in each case a simple JPanel with Titled-Border an 2 JLabels. If I adjust Metal Look&Feel the rendered Nodes are displayed correctly. (The JPanels size is about 300x200 pixel

  • Struts Request Encoding Problems

    Hi, I am programming a sample struts application using Greek characters. I've got everything turned in UTF-8 (My resourceBundle file, contentType and pageEncoding attributes in the JSP page directive) and everything seems to work fine. However when I