Hi Willy,
There are places in your schema where you set maxOccurs to very large
numbers:
<xsd:element name="container_info" type="container_infoType" minOccurs
="0" maxOccurs="9999"/>
<xsd:element name="item_detail" type="item_detailType" maxOccurs="9999"/>
<xsd:element ref="shipping_marks" minOccurs="0" maxOccurs="999"/>
<xsd:element ref="goods_desc" minOccurs="0" maxOccurs="999"/>
Do you really mean that? Wouldn't maxOccurs="unbounded" be a better choice
in this case?
I have to admit that, in one way, this is a limitation of Xerces-J. Your
element "container_info" is expanded to 9999 optional elements
(min=0/max=1), which causes the stack problem when we recursively traverse
these elements.
We can design certain algorithm to solve this problem, but it would greatly
complicate the program, hence affect the performance. And we don't see
enough demand for it yet.
Regards,
Sandy Gao
Software Developer, IBM Canada
(1-416) 448-3255
[EMAIL PROTECTED]
Willy Ching
<[EMAIL PROTECTED] To: [EMAIL PROTECTED]
h.com> cc:
Subject: Xschema validation:
java.lang.StackOverflowError
06/26/2001
07:00 AM
Please respond
to
xerces-j-user
Hello All,
I'm using xalan 2.1.0 to validate an xml file against schema, and I
got a "StackOverflowError" on some xml document, some works fine.
Error:
java.lang.StackOverflowError
at
org.apache.xerces.validators.common.Grammar.buildSyntaxTree(Grammar.j
ava:854)^M
at
org.apache.xerces.validators.common.Grammar.buildSyntaxTree(Grammar.j
ava:854)
My program:
public static Document xSchemaValidate(InputSource in)
throws SAXException, IOException{
DOMParser parser = new DOMParser();
ErrorHandlerImp eh = new ErrorHandlerImp();
parser.setErrorHandler(eh);
parser.setFeature("http://apache.org/xml/features/validation/schema",
true);
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setFeature("http://xml.org/sax/features/namespaces", true);
parser.parse(in);
return eh.getErrorDoc();
}
Please help. any info will be appreaciated.
thank you very much.
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v3.5 (http://www.xmlspy.com) by willy (itis) -->
<bl_sample xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\in_bls_edi_rule.xsd">
<authority_info_qualifier>00</authority_info_qualifier>
<authority_info/>
<security_info_qualifier>00</security_info_qualifier>
<security_info/>
<interchange_id_qualifier>ZZ</interchange_id_qualifier>
<interchange_sender_id>SENDERID </interchange_sender_id>
<interchange_receiver_id>SENDERID
</interchange_receiver_id>
<interchange_date>010622</interchange_date>
<interchange_time>1200</interchange_time>
<interchange_standard_id>U</interchange_standard_id>
<interchange_version_id>00400</interchange_version_id>
<interchange_ctl_num>100000001</interchange_ctl_num>
<acknowledge_request>0</acknowledge_request>
<usage_indicator>P</usage_indicator>
<functional_indentifier>QO</functional_indentifier>
<app_sender_code>APPSENDERCODE</app_sender_code>
<app_receiver_code>APPRECEIVERCODE</app_receiver_code>
<carrier_scac_code>EVER</carrier_scac_code>
<ocean_so>OS003343</ocean_so>
<vessel_name>EVER RACER</vessel_name>
<voyage_code>0803RE-032</voyage_code>
<shipper>
<name>NISSIN FOOD PRODUCTS CO LTD</name>
<address>HONG KONG BRANCH</address>
<address>21-23 DAI SHING STREET,</address>
<address>TAI PO INDUSTRIAL ESTATE,</address>
<address>TAI PO, N.T. HONG KONG</address>
<city_name>HONG KONG</city_name>
<country_code>HK</country_code>
<contact>OCEAN EXPORT DEPARTMENT</contact>
</shipper>
<consignee>
<name>TO THE ORDER OF THE CHINESE</name>
<address>AMERICAN BANK, NEW YORK.</address>
<city_name>NEW YORK</city_name>
<country_code>US</country_code>
</consignee>
<notify_party1>
<name>CHINESE AMERICAN TRADING CO. INC.</name>
<address>91 MULBERRY STREET,</address>
<address>NEW YORK N.Y. 10013.</address>
<city_name>NEW YORK</city_name>
<country_code>US</country_code>
</notify_party1>
<notify_party2>
<name>GOLDEN FORTUNE IMPORT EXPORT CORP</name>
<address>15 PULASKI STREET, BAYONNE, NJ07002</address>
<address>TEL : (201)243-9880</address>
<address>FAX : (201)243-9883</address>
<city_name>NEW YORK</city_name>
<country_code>US</country_code>
</notify_party2>
<container_info>
<container_no>EISU1010087</container_no>
<container_size_code>4B</container_size_code>
<quantity>1310</quantity>
<weight>13362.00</weight>
<weight_unit>K</weight_unit>
<volume>60.260</volume>
<volume_unit>CBM</volume_unit>
</container_info>
<container_info>
<container_no>EMCU2259256</container_no>
<container_size_code>4B</container_size_code>
<quantity>1310</quantity>
<weight>13362.00</weight>
<weight_unit>K</weight_unit>
<volume>60.260</volume>
<volume_unit>CBM</volume_unit>
</container_info>
<item_detail>
<shipping_marks>NO MARKS</shipping_marks>
<shipping_marks>1310 BUNDLES (3930
CTNS)</shipping_marks>
<shipping_marks>NISSIN DEMAE RAMEN
NOODLE</shipping_marks>
<quantity>1310</quantity>
<goods_desc>NO MARKS</goods_desc>
<goods_desc>1310 BUNDLES (3930 CTNS)</goods_desc>
<goods_desc>NISSIN DEMAE RAMEN NOODLE</goods_desc>
<goods_desc>3 X 30 X 100G</goods_desc>
<goods_desc>L/C NO. " HR-1398
"</goods_desc>
<goods_desc>THIS SHIPMENT CONTAIN NO</goods_desc>
<goods_desc>ANY SOLID WOON PACKING</goods_desc>
<goods_desc>MATERIAL</goods_desc>
</item_detail>
<item_detail>
<shipping_marks>NO MARKS</shipping_marks>
<shipping_marks>1310 BUNDLES (3930
CTNS)</shipping_marks>
<shipping_marks>NISSIN DEMAE RAMEN
NOODLE</shipping_marks>
<quantity>1310</quantity>
<goods_desc>NO MARKS</goods_desc>
<goods_desc>1310 BUNDLES (3930 CTNS)</goods_desc>
<goods_desc>NISSIN DEMAE RAMEN NOODLE</goods_desc>
<goods_desc>3 X 30 X 100G</goods_desc>
<goods_desc>L/C NO. " HR-1398
"</goods_desc>
<goods_desc>THIS SHIPMENT CONTAIN NO</goods_desc>
<goods_desc>ANY SOLID WOON PACKING</goods_desc>
<goods_desc>MATERIAL</goods_desc>
</item_detail>
</bl_sample>
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v3.5 (http://www.xmlspy.com) by Wai (Wai) -->
<!--W3C Schema generated by XML Spy v3.5 (http://www.xmlspy.com)-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault
="qualified">
<xsd:element name="acknowledge_request" type="xsd:string"/>
<xsd:element name="address">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="35"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="app_receiver_code">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="15"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="app_sender_code">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="15"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="authority_info" type="xsd:string"/>
<xsd:element name="authority_info_qualifier" type="xsd:string"/>
<xsd:element name="bl_sample">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref
="authority_info_qualifier"/>
<xsd:element ref
="authority_info"/>
<xsd:element ref
="security_info_qualifier"/>
<xsd:element ref
="security_info"/>
<xsd:element ref
="interchange_id_qualifier"/>
<xsd:element ref
="interchange_sender_id"/>
<xsd:element ref
="interchange_receiver_id"/>
<xsd:element ref
="interchange_date"/>
<xsd:element ref
="interchange_time"/>
<xsd:element ref
="interchange_standard_id"/>
<xsd:element ref
="interchange_version_id"/>
<xsd:element ref
="interchange_ctl_num"/>
<xsd:element ref
="acknowledge_request"/>
<xsd:element ref
="usage_indicator"/>
<xsd:element ref
="functional_indentifier"/>
<xsd:element ref
="app_sender_code"/>
<xsd:element ref
="app_receiver_code"/>
<xsd:element ref
="carrier_scac_code"/>
<xsd:element ref="ocean_so"/>
<xsd:element ref="vessel_name"/>
<xsd:element ref="voyage_code"/>
<xsd:element name="shipper" type
="shipperType"/>
<xsd:element name="consignee"
type="consigneeType"/>
<xsd:element name="notify_party1"
type="notify_party1Type" minOccurs="0"/>
<xsd:element name="notify_party2"
type="notify_party2Type" minOccurs="0"/>
<xsd:element name
="container_info" type="container_infoType" minOccurs="0" maxOccurs
="9999"/>
<xsd:element name="item_detail"
type="item_detailType" maxOccurs="9999"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="carrier_scac_code">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="4"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="city_name">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="2"/>
<xsd:maxLength value="30"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:complexType name="consigneeType">
<xsd:sequence>
<xsd:element ref="name"/>
<xsd:element ref="address" minOccurs="0"
maxOccurs="4"/>
<xsd:element ref="city_name"/>
<xsd:element ref="country_code"/>
<xsd:element ref="contact" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="contact">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="60"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:complexType name="container_infoType">
<xsd:sequence>
<xsd:element ref="container_no"/>
<xsd:element ref="container_size_code"/>
<xsd:element ref="quantity"/>
<xsd:element ref="weight"/>
<xsd:element ref="weight_unit"/>
<xsd:element ref="volume"/>
<xsd:element ref="volume_unit"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="container_no">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="12"/>
<xsd:minLength value="11"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="container_size_code" type="xsd:string"/>
<xsd:element name="country_code">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="2"/>
<xsd:maxLength value="3"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="functional_indentifier">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
<xsd:element name="goods_desc" type="xsd:string"/>
<xsd:element name="interchange_ctl_num" type="xsd:string"/>
<xsd:element name="interchange_date" type="xsd:short"/>
<xsd:element name="interchange_id_qualifier" type="xsd:string"/>
<xsd:element name="interchange_receiver_id" type="xsd:string"/>
<xsd:element name="interchange_sender_id" type="xsd:string"/>
<xsd:element name="interchange_standard_id" type="xsd:string"/>
<xsd:element name="interchange_time" type="xsd:short"/>
<xsd:element name="interchange_version_id" type="xsd:string"/>
<xsd:complexType name="item_detailType">
<xsd:sequence>
<xsd:element ref="shipping_marks" minOccurs
="0" maxOccurs="999"/>
<xsd:element ref="quantity"/>
<xsd:element ref="goods_desc" minOccurs="0"
maxOccurs="999"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="name">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="35"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:complexType name="notify_party1Type">
<xsd:sequence>
<xsd:element ref="name"/>
<xsd:element ref="address" minOccurs="0"
maxOccurs="4"/>
<xsd:element ref="city_name"/>
<xsd:element ref="country_code"/>
<xsd:element ref="contact" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="notify_party2Type">
<xsd:sequence>
<xsd:element ref="name"/>
<xsd:element ref="address" minOccurs="0"
maxOccurs="4"/>
<xsd:element ref="city_name"/>
<xsd:element ref="country_code"/>
<xsd:element ref="contact" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ocean_so">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="25"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="quantity" type="xsd:short"/>
<xsd:element name="security_info" type="xsd:string"/>
<xsd:element name="security_info_qualifier" type="xsd:string"/>
<xsd:complexType name="shipperType">
<xsd:sequence>
<xsd:element ref="name"/>
<xsd:element ref="address" minOccurs="0"
maxOccurs="4"/>
<xsd:element ref="city_name"/>
<xsd:element ref="country_code"/>
<xsd:element ref="contact" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="shipping_marks" type="xsd:string"/>
<xsd:element name="usage_indicator" type="xsd:string"/>
<xsd:element name="vessel_name">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="25"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="volume" type="xsd:decimal"/>
<xsd:element name="volume_unit">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:length value="3"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="voyage_code">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="10"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="weight" type="xsd:decimal"/>
<xsd:element name="weight_unit">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:length value="1"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]