What is an Escape Sequence ?
"An Escape sequence is a series of characters which cause an escape from normal interpretation".
Escape sequences use a Special (Escape) character to change the meaning of characters that follow it.
For example, you cannot use the & (ampersand sign) in XML as you would normally use it elsewhere. The & (ampersand sign) is a special character and is to be used differently in XML.
This tag contains incorrect value.
<NAME>ABC & Company Ltd</NAME>
Here's the corrected tag.
<NAME>ABC & Company Ltd</NAME>
XML Escape Sequences
In XML, there are 5 Escape sequences. Refer this link for more information on XML Escape sequences.
XSL Escape Sequences
XML Escape sequences are well documented and you can get lot's of information about it. But, what about using special characters in XSL ?
Well, the Escape sequences used in XML do NOT work in XSL. Now, let's try understand this.
Task 1
Search for all LEDGER nodes that have an attribute named NAME which contains "some-value".
This works fine.
//LEDGER[@NAME='some-value']
Task 2
Search for all LEDGER nodes that have an attribute named NAME which contains "Here's a special one".
This does not work :-
//LEDGER[@NAME="Here's a special one"]
This does not work :-
//LEDGER[@NAME='Here's a special one']
This WORKS!!!
//LEDGER[@NAME='Here\'s a special one']
Remarks:-
In Task 2, we search for a text-value that contains a special character ( ' ) .i.e. an apostrophe.
No comments:
Post a Comment