0

I am sending XML messages to update records in a new software system. The xPath uses apostrophes around an ID value. the problem is the value itself could potentially contain an apostrophe.

Example:

This works fine when the ID value doesnt have an apostrophe:

<Sync>
     <ActionCriteria>
          <ActionExpression actionCode="Add">/SyncItemMaster/DataArea/ItemMaster[ItemMasterHeader/ItemID[ID=&apos;Test Part&apos;]]</ActionExpression>
     </ActionCriteria>
</Sync>
<ItemMaster>
    <ItemMasterHeader>
        <ItemID>
            <ID>Test Part</ID>
            <RevisionID>000</RevisionID>
        </ItemID>

So when i have an ID value with an apostrophe, this fails.

i.e. ID = Part's Test gives this that fails when being read by software system.

<ActionExpression actionCode="Add">/SyncItemMaster/DataArea/ItemMaster[ItemMasterHeader/ItemID[ID=&apos;Part&apos;s Test&apos;]]</ActionExpression>

Is there a way to delimit an actual apostrophe in the value here?

av155
  • 31
  • 2
  • You should detail your transformation operation. What you want to achieve is rather unclear. – Alice Oualouest Nov 10 '16 at 16:18
  • Possible duplicate of [Single quote escaping a dynamic value-of string in XSLT 1.0](http://stackoverflow.com/questions/14287598/single-quote-escaping-a-dynamic-value-of-string-in-xslt-1-0) – Rao Nov 10 '16 at 16:31
  • ItemID[ID='Part's Test'] the above erorrs out because the importing program see's that apostrophe in the middle and thinks the string is ending. need something so that apostrophe in the middle is treated as part of the actual value instead. – av155 Nov 10 '16 at 18:53
  • What if you didn't escape the inner quote, like : `ItemID[ID='Part's Test']` – har07 Nov 11 '16 at 02:20

0 Answers0