Cannot deal with CDATA sections properly
----------------------------------------

         Key: JIBX-73
         URL: http://jira.codehaus.org/browse/JIBX-73
     Project: JiBX
        Type: Bug
  Components: core  
    Versions: 1.0-RC0    
 Environment: Linux c10-dev73-com2.cnet.com 2.4.20-28.7bigmem #1 SMP Thu Dec 18 
11:04:21 EST 2003 i686 unknown
    Reporter: Trenton Lipscomb
    Priority: Blocker


The version of xpp3.jar in RC0 is pretty old and contains a bug related to 
parsing CDATA sections.

1) Create classes, binding, and sample xml file as shown here:

   http://jibx.sourceforge.net/start.html
   
2) Create test harness as shown here

   http://jibx.sourceforge.net/runtime.html

   import java.io.FileInputStream;
   import org.jibx.runtime.BindingDirectory;
   import org.jibx.runtime.IBindingFactory;
   import org.jibx.runtime.IUnmarshallingContext;

   class TestHarness {
       public static void main (String[] args) throws Exception {
       IBindingFactory bfact = BindingDirectory.getFactory(Customer.class);
       IUnmarshallingContext uctx = bfact.createUnmarshallingContext();

       Customer theCustomer = (Customer)uctx.unmarshalDocument(new 
FileInputStream("customer.xml"), null);
       System.out.println("Customer first name was: " + theCustomer.firstName);
       }
   }
   
2) Compile classes and bind, as per here:

   http://jibx.sourceforge.net/bindcomp.html
   
   % javac -classpath lib/jibx-run.jar:lib/xpp3.jar Customer.java 
TestHarness.java   
   % java -jar lib/jibx-bind.jar binding.xml

3) Run it.

   % java -cp lib/jibx-run.jar:lib/xpp3.jar:. TestHarness
   Customer first name was: John
   
4) Edit customer.xml and add a CDATA section and rerun test

   <first-name><![CDATA[>>John<<]]></first-name>

   java -cp lib/jibx-run.jar:lib/xpp3.jar:. TestHarness
   Customer first name was: >>John<<

5) Now add the killer text to the CDATA section. Note this is valid. It'd
   be illegal to have "]]>" in there, but we only have ]]. Also note that 
   having just ]] is okay. It's some combination of the <script> and comment
   and ]] that fowls it up.
   
   <first-name><![CDATA[<script><!-- ]] --> </script>]]></first-name>

   % java -cp lib/jibx-run.jar:lib/xpp3.jar:. TestHarness
   Exception in thread "main" Error parsing document (line 3, col 53)
   org.xmlpull.v1.XmlPullParserException: end tag name 'script' must match 
start tag name 'first-name' (position: TEXT seen ...<!-- ]] --> </script>... 
@3:53)
        at org.xmlpull.mxp1.MXParser.parseEndTag(MXParser.java:1695)
        at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1216)
        at org.xmlpull.mxp1.MXParser.nextToken(MXParser.java:1144)
        at 
org.jibx.runtime.impl.UnmarshallingContext.accumulateText(UnmarshallingContext.java:881)
        at 
org.jibx.runtime.impl.UnmarshallingContext.parseContentText(UnmarshallingContext.java:922)
        at 
org.jibx.runtime.impl.UnmarshallingContext.parseElementText(UnmarshallingContext.java:990)
        at Customer.JiBX_binding_unmarshal_1_0(Customer.java)
        at JiBX_bindingCustomer_access.unmarshal()
        at 
org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2515)
        at 
org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2675)
        at TestHarness.main(TestHarness.java:11)

6) Finally, grap the latest xpp3 implementation (1.1.3.4.M as of 2005-07-06) 
from 
   http://www.extreme.indiana.edu/dist/java-repository/xpp3/distributions/
   and rerun the test using the new xpp3 jar.
   
   % java -cp lib/jibx-run.jar:lib/xpp3-1.1.3.4.M.jar:. TestHarness
   Customer first name was: <script><!-- ]] --> </script>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
jibx-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to