Clarity

  • 1.  Are You Double-Escaping Apostrophes in XOG?

    Broadcom Employee
    Posted Mar 11, 2019 04:47 PM

    Special Characters

    Escape special characters in XOG requests to ensure a successful XOG read or write request. You can escape special characters or can use CDATA.

     

    Escape Rules (in Docs from 2004 to 2018)
    Use one of the escape rules in the following table to escape special characters in the XML file:

     

     

    QUESTION: Is anyone in the PPM XOG community using  \'' to double-escape apostrophe chars in XOG import or export files?

     

    Or is one \' enough?

     

    In 2019, we recently changed the docs to show:

     

     

    Since Clarity PPM 7.5 way back in 2004, the documentation listed the escape rule for apostrophes as

                       ''

     

    and it is followed by the text "Apostrophes must be double-escaped." One user indicated that "depending on the situation, I need to use single or double escapes, but it's not clear when we should use single or double" and "I don't think this processing can actually be fixed ... both 1 escape and 2 escapes sometimes work, depending on the situation."

     

    One user reported "XOG will fail when special characters are passed. Convert the special characters... For passing single quotes (apostrophes, for example, 'abc') as part of the XML attribute, You need to pass:

             '' instead of '

     

    Another user suggested the following code to replace a single quote with its equivalent code... "for a single quote, you are sending the equivalent of:  "''" double-quote single-quote single-quote double-quote

     

    Example: <core:set value="${userRead.replaceAll ('\x27', &quot;&apos;&apos;&quot;)}" var="userRead"/> <!-- ' Characters -->



  • 2.  Re: Apostrophes Must Be Double-Escaped in XOG

     
    Posted Mar 11, 2019 05:03 PM

    Thank you for reaching out to the community for input Damon! Jump in here folks.

    Are You Double-Escaping Apostrophes in XOG? 



  • 3.  Re: Are You Double-Escaping Apostrophes in XOG?

    Posted Mar 25, 2019 11:07 AM

    Odd, I don't recall ever having to escape quotes at all (neither single-quote nor double-quote) when using XOG.

     

    So, no (neither &apos; nor &apos;&apos; )



  • 4.  Re: Are You Double-Escaping Apostrophes in XOG?

    Broadcom Employee
    Posted Mar 25, 2019 01:34 PM

    Thank you David, 

    Seems to vary somewhat widely, based on the different responses, so difficult to document the rules here. Another user in a different thread added, ¨You have to use double apostrophes in a query when there is an apostrophe in a string that's part of the WHERE clause, for example, and that might be the genesis of this documentation rule. Not sure. It might have been an issue with some of the import actions not dealing with embedded apostrophes properly.¨



  • 5.  Re: Are You Double-Escaping Apostrophes in XOG?

    Posted Mar 25, 2019 11:31 PM

    My experience, where I have seen this occur.

     

    If the GEL script includes a SQL statement, and the data returned is a string which includes a restricted XML character (ie ', &, > etc).  If this data is passed to a variable in the GEL script, this will then convert the data to be &amp, if the variable is then XOG'ed in, the data is written as &amp.  If the SQL variable is not passed and used directly in the XOG, it works correctly and not written as &amp.

     

    The SQL statement may also need additional parameters eg CDATA, escapeText="false".

     

    I have also experienced when reading from a flat file where the data may also include restricted XML characters.



  • 6.  Re: Are You Double-Escaping Apostrophes in XOG?

    Posted Mar 26, 2019 05:10 AM

    "¨You have to use double apostrophes in a query when there is an apostrophe in a string" - yes that is true, but thats a SQL rule since ' (single-apostrophe) is the default string terminator ; so if you want to (eg) pattern match an apostrophe SQL allows you to do this with '' (two single-apostrophes) 

     

    Nothing to do with XOG (or XML) tho' I think.



  • 7.  Re: Are You Double-Escaping Apostrophes in XOG?

    Broadcom Employee
    Posted Mar 26, 2019 11:27 AM

    Thank you Roland and David,

     

    Makes me wonder since it was written that way since 2004... I can only imagine what the writer was intending here back then... XML 1.0 spec days... here is the XOG doc page:

    https://docops.ca.com/x/C_aYHw 

     

    Seems like the section is not so much about escaping chars, and more about replacing special chars with HTML char entities. See https://www.w3schools.com/html/html_entities.asp

     

    To engineer the results to anticipate the types of converted char data Roland is describing.