Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-196

Pretty print not always handling xml encoded ampersands

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: Version 2
    • Fix Version/s: Version 2
    • Component/s: None
    • Labels:
      None
    • Environment:

      Description

      The following elements in our xml cause a
      java.lang.ArrayIndexOutOfBoundsException in Document.save(StringWriter,
      XmlOptions) in xmlbeans when we first call setSavePrettyPrint() on the
      XmlOptions object we pass into the Document.save(StringWriter,
      XmlOptions) method:

      <value>uranium miner &</value>
      <value>uranium miner & s</value>
      <value>uranium miner & </value>

      These do not:

      <value>uranium miner & s</value>
      <value>&</value>

      Basically, we're seeing that any "&amp" at the end of an element value
      needs to have a non-whitespace character at least three characters from
      the right of it in order to avoid the problem.

      If setSavePrettyPrint() is not called, everything works.

      Here's the stack against the 2.0.0 xmlbeans release:

      java.lang.ArrayIndexOutOfBoundsException
      at java.lang.System.arraycopy(Native Method)
      at org.apache.xmlbeans.impl.store.Saver
      $TextSaver.replace(Saver.java:1438)
      at org.apache.xmlbeans.impl.store.Saver
      $TextSaver.entitizeContent(Saver.java:1269)
      at org.apache.xmlbeans.impl.store.Saver
      $TextSaver.emitText(Saver.java:966)
      at org.apache.xmlbeans.impl.store.Saver.process(Saver.java:288)
      at org.apache.xmlbeans.impl.store.Saver
      $TextSaver.ensure(Saver.java:1466)
      at org.apache.xmlbeans.impl.store.Saver$TextSaver.read(Saver.java:1553)
      at org.apache.xmlbeans.impl.store.Saver
      $TextReader.read(Saver.java:1680)
      at org.apache.xmlbeans.impl.store.Cursor._save(Cursor.java:609)
      at org.apache.xmlbeans.impl.store.Cursor.save(Cursor.java:2554)
      at
      org.apache.xmlbeans.impl.values.XmlObjectBase.save(XmlObjectBase.java:186)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              clamey Chris Lamey
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: