3 Replies Latest reply on Oct 10, 2008 5:36 AM by tfennelly

    Error in smooks transformer

    vishal12345

      when i tried transforming a XML message to object of the following type it generated error/exception for "&" symbol which was present in the string as a value of an attribute as follows

      <Message SentenceID="1" Content="it classifies & describes organisms, their functions, how species come into existence, and the interactions they have with each other and with the natural environment."></Message>
      


      what can be the reason ?

      when i replaced "&" then same thing worked
      please help !

        • 1. Re: Error in smooks transformer
          scottdawson

          According to the XML spec http://www.w3.org/TR/xml/:

          The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they MUST be escaped using either numeric character references or the strings [ampersand amp semicolon] and [ampersand lt semicolon] respectively.

          So your XML is not valid. You can fix it by replacing the ampersand with the escape sequence or enclosing the text in a CDATA section.

          I don't know if Smooks provides an easy way to escape the special characters. Maybe a Smooks expert can comment on that.

          Regards,
          Scott

          • 2. Re: Error in smooks transformer
            vishal12345

            thanks

            • 3. Re: Error in smooks transformer
              tfennelly

              This is an XML issue... you need to escape reserved characters (& < > etc) wit their entity reference equivalents. So "&" should be represented as "&amp;".