Announcement Announcement Module
Collapse
No announcement yet.
Using escape characters when setting properties Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using escape characters when setting properties

    I have a bean defined that takes a "delimiter" property:

    Code:
    		
    <property name="delimiter">
      <value>\r\n</value>
    </property>
    However, when setting the property, the value is taking literally, as "\\r\\n".

    I want to specify a carriage return and linefeed for this property.

    How do I specify escaped string for a property value? Do I need to write a custom StringEditor class just to do this?

    I thought it might be a common problem.

    Thanks,
    Derek

  • #2
    Did you try XML escapes? etc?

    Comment


    • #3
      I meant &amp;#10;

      Comment


      • #4
        I.e. '&', then '#', then chacater's decimal code.

        Comment


        • #5
          Ah, yeah - that worked. Thanks!

          Snippet below...


          Code:
          		<property name="delimiter">
          			<value>&amp#13;&amp#10;</value>
          		</property>

          Comment


          • #6
            Hi,
            We are also facing similar problem and the solution above doesnt seem to be working.

            We want to read "\n" from the configuration and write "\n" to the file.

            When we read the string from config, it is read as "&#10" and the same characters are being written to the file (&#10) and not a new line character.

            Could some one help?

            Comment


            • #7
              You seem to have missed the trailing ';'.
              Escape sequences begin with '&' and end with ';'.

              Regards,
              Andreas

              Comment


              • #8
                Hi,
                This is what we're writing in spring xml:

                <property name="recordSeparator">
                <value>&amp;#10;</value>
                </property>

                and when we read this and write to a file, it writes to the file!!

                Regards,
                Javvaji Ramesh

                Comment


                • #9
                  Just leave out the semicolon in the middle. The correct sequence is
                  Code:
                  &amp#10;
                  Regards,
                  Andreas

                  Comment


                  • #10
                    It gives BeanDefinitionStoreException if I take out the semi colon in the middle! any solutions?

                    Comment


                    • #11
                      Just tried it out. In fact it is not necessary to XML-escape the sequence.
                      Code:
                      & #10;
                      works fine (just omit the blank between & and #; Seems that I cannot use these characters in posts).

                      Regards,
                      Andreas

                      Comment


                      • #12
                        That works

                        Thanks,
                        J

                        Comment

                        Working...
                        X