Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Cannot Reproduce
-
Version 2.4.1
-
None
Description
Xobj.fetch_text() starts with an assert like this:
assert isValid() && isOccupied();
But it seems that sometimes this 'assert' fires incorrectly. Here's a repro case:
Schema:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://cfnxml" targetNamespace="http://cfnxml"
elementFormDefault="qualified">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="invoice" type="InvoiceType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="InvoiceType">
<xs:sequence>
<xs:element name="termsOfPaymentId" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Document ("test.xml"):
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://cfnxml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<invoice>
<termsOfPaymentId>100</termsOfPaymentId>
</invoice>
</root>
Code:
File f = new File("test.xml");
XmlObject doc = XmlObject.Factory.parse(f);
System.out.println("Root type = " + doc.schemaType());
System.out.println("Valid = " + doc.validate());
InvoiceType invoice = ((RootDocument) doc).getRoot().getInvoice();
invoice.setTermsOfPaymentId(null);
invoice.setTermsOfPaymentId(BigInteger.valueOf(10));
invoice.getTermsOfPaymentId();
System.out.println("Final document = " + doc.xmlText());
If you run the repro with assertions enabled, then the assert fires, but if you disable assertions, the repro seems to work, so maybe the assert is incorrect.