How to handle ampersands in XML with XSLT

Ray's Avatar


14 Apr, 2016 09:23 PM


A user has copied and pasted some XML into a block and using XSLT to read the data. I am trying to build a custom feed like the example you have
When viewing the feed within Cascade, I get the error:

An error occurred: An error occurred during the parsing of the assembled page XML: org.xml.sax.SAXParseException: The reference to entity "ID" must end with the ';' delimiter.

However, the ampersand seems to be causing a problem in the XML


This works when changing it to &amp;, but is is unreasonable to ask the user to swap out all instances of & to &amp; within the XML as it is quite large and will have tonnes of instances of this occurring.


Is there a way around this issue in XSLT to get this to work?

  1. 1 Posted by Ryan Griffith on 15 Apr, 2016 12:35 PM

    Ryan Griffith's Avatar

    Hi Ray,

    I actually helped a client with a similar situation where the resulting content contained unencoded & characters and threw the error message.

    The solution I came up with was to use a Xalan function that encodes all ampersands that are not encoded.

    Please let me know if you have any questions.


  2. 2 Posted by Raymond Choo on 15 Apr, 2016 03:38 PM

    Raymond Choo's Avatar

    Thanks so much, that seems to have worked.


  3. 3 Posted by Ryan Griffith on 15 Apr, 2016 03:44 PM

    Ryan Griffith's Avatar

    Not a problem at all, Ray. I am glad to hear the proposed code did the trick.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  4. Ryan Griffith closed this discussion on 15 Apr, 2016 03:44 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM