I'm using IBM's Websphere to develop/deploy a webservices application that
accepts strings (xml docs) as arguments. I need to validate the incoming
documents against a schema. When I run the code below I get a null pointer
exception from the XML parser. I know I should update to a newer version
of xerces but when I download the 2.0.2 bin zip there is no xerces.jar file
in there...just a xercesImpl.jar. I'm not familiar with how to upgrade my
parser with a newer version of a parser ...anyways here is the code....btw
both the source and schema validate fine and the schema does validate
against the source document in a Microsoft environment....WHAT DO I DO NOW?
AND if I run a less complex document against a less complex schema then it
works..
try{
String methodnamespace = new String(
"MesApi/Schemas/version1.0/ReceiveInventory");
String url = new String(
"http://localhost:8080/meswebservice/schemas/ReceiveInventory.xsd");
String sxml = new XMLDataTest().getXMLData("RecInventory.XML"); //this just
loads the request xml from a directory and returns the xml as a
string...test purposes only
//Create the Sax parser;
SAXParser myparser = new SAXParser();
//set the parser to validate
myparser.setFeature("http://xml.org/sax/features/validation",true);
//tell the parser what schema and what namespace to match it to...
String myprop = new String(
"http://apache.org/xml/properties/schema/external-schemaLocation");
String mySchema = methodnamespace + " " + url;
myparser.setProperty(myprop, mySchema);
//create/set the content handler
ReceiveInventoryContentHandler MethodContent = new
ReceiveInventoryContentHandler();
//Set the content handler
myparser.setContentHandler(MethodContent);
//Set the Error handler
myparser.setErrorHandler(new MESErrorHandler());
//Parse the string
myparser.parse(new InputSource(new java.io.StringReader(sxml)));
System.out.println("no errors");
}
catch....
Here is the source document...
<request xmlns="MesApi/Schemas/version1.0/ReceiveInventory" server
='myserver' database='mydatabase' clientmachinename='xxx' requestid
='scooby'>
<actualreceipt printloadticket="1">
<supply_order_nbr>MP28214</supply_order_nbr>
<supply_order_release_nbr></supply_order_release_nbr>
<supply_order_line_nbr>00001</supply_order_line_nbr>
<supply_order_line_receipt_nbr>00001</supply_order_line_receipt_nbr>
<mmm_facility_code>HT</mmm_facility_code>
<mmm_id_nbr>34300000030</mmm_id_nbr>
<receiptcomplete>0</receiptcomplete>
<receipt_datetime>2002-02-26T01:01:01</receipt_datetime>
<receipt_qty mesunittype
="ITEMSUPPLIER">137.222222</receipt_qty>
<receipt_uom>sqyd</receipt_uom>
<carriername>billybobtrucking</carriername>
<shipment_mode_code>R</shipment_mode_code>
<packing_list_nbr>8675309</packing_list_nbr>
<comment>This is your comment blahblahblahb</comment>
<inventorydetails>
<material>
<run_nbr>77777</run_nbr>
<batch_nbr>909809</batch_nbr>
<unit_nbr>302457</unit_nbr>
<material_qty mesunittype
="REPORTING">100</material_qty>
<load>
<load_id>XX00094</load_id>
<storage_loc_nbr>TEST</storage_loc_nbr>
<qc_status_code>R</qc_status_code>
<adjustment_qty mesunittype
="REPORTING">100</adjustment_qty>
</load>
</material>
</inventorydetails>
</actualreceipt>
</request>
Here is the schema...
<xsd:schema targetNamespace="MesApi/Schemas/version1.0/ReceiveInventory"
elementFormDefault="qualified" xmlns:src=
"MesApi/Schemas/version1.0/ReceiveInventory" xmlns:xsd=
"http://www.w3.org/2001/XMLSchema">
<xsd:attributeGroup name="connections">
<xsd:attribute name="server" type="xsd:string" use="optional"/>
<xsd:attribute name="database" type="xsd:string" use="optional"
/>
<xsd:attribute name="requestid" type="xsd:string" use=
"optional"/>
<xsd:attribute name="siteid" type="xsd:string" use="optional"/>
</xsd:attributeGroup>
<!-- Define the inventory quantity rules. All quantity elements must
have an mesunittype attribute -->
<!-- Extend the simple type to include an attribute -->
<xsd:complexType name='mesquantity'>
<xsd:simpleContent>
<xsd:extension base="xsd:double">
<xsd:attribute name="mesunittype" type=
"src:unitofmeasure" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<!-- Restrict the simple type to be greater than zero -->
<xsd:complexType name='qtygreaterthanzero'>
<xsd:simpleContent>
<xsd:restriction base="src:mesquantity">
<xsd:minInclusive value="0.000001"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
<!-- Define a type that restricts mesquantity to be zero or greater
-->
<xsd:complexType name='qtyzeroandgreater'>
<xsd:simpleContent>
<xsd:restriction base="src:mesquantity">
<xsd:minInclusive value="0"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
<!-- Define all of the enumeration values for mesunittype -->
<xsd:simpleType name='unitofmeasure'>
<xsd:restriction base='xsd:string'>
<xsd:enumeration value="REPORTING"/>
<xsd:enumeration value="INVENTORY"/>
<xsd:enumeration value="COMMONPURCHASING"/>
<xsd:enumeration value="ITEMSUPPLIER"/>
</xsd:restriction>
</xsd:simpleType>
<!--Define the root element -->
<xsd:element name="request" type="src:requestdata"/>
<xsd:complexType name="requestdata">
<xsd:sequence>
<xsd:element name='actualreceipt' type='src:actualreceipttype'
minOccurs='1' maxOccurs='unbounded'/>
</xsd:sequence>
<xsd:attributeGroup ref="src:connections"/>
<xsd:attribute name="clientmachinename" type="xsd:string" use=
"optional"/>
<xsd:attribute name="printloadticket" type="xsd:boolean" use=
"optional"/>
</xsd:complexType>
<xsd:complexType name='actualreceipttype'>
<xsd:sequence>
<xsd:element name='supply_order_nbr' minOccurs='1'
maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='supply_order_release_nbr' minOccurs='1'
maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="3" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='supply_order_line_nbr' minOccurs='1'
maxOccurs='1' type='xsd:positiveInteger'/>
<xsd:element name='supply_order_line_receipt_nbr' minOccurs=
'1' maxOccurs='1' type='xsd:positiveInteger'/>
<xsd:element name='mmm_facility_code' minOccurs='1' maxOccurs=
'1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="8" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='mmm_id_nbr' minOccurs='1' maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="11" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='receiptcomplete' minOccurs='1' maxOccurs=
'1' type='xsd:boolean'/>
<xsd:element name='receipt_datetime' minOccurs='1' maxOccurs=
'1' type='xsd:dateTime'/>
<xsd:element name='receipt_qty' minOccurs='1' maxOccurs='1'
type="src:qtygreaterthanzero"/>
<xsd:element name='receipt_uom' minOccurs='1' maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='entered_receipt_qty' minOccurs='0'
maxOccurs='1' type="src:qtygreaterthanzero"/>
<xsd:element name='entered_receipt_uom' minOccurs='0'
maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='carriername' minOccurs='1' maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="40" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='shipment_mode_code' minOccurs='1' maxOccurs
='1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="2" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='packing_list_nbr' minOccurs='1' maxOccurs=
'1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="11" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='comment' minOccurs='0' maxOccurs='1' type=
'xsd:string'/>
<xsd:element name='item_dimension_set_id' minOccurs='0'
maxOccurs='1' type='xsd:long'/>
<xsd:element name='inventorydetails' minOccurs='1' maxOccurs=
'unbounded' type='src:inventorydetailstype'/>
</xsd:sequence>
<xsd:attribute name="printloadticket" type="xsd:boolean"/>
</xsd:complexType>
<xsd:complexType name='inventorydetailstype'>
<xsd:sequence>
<xsd:element name='material' minOccurs='1' maxOccurs=
'unbounded' type='src:materialtype'/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name='materialtype'>
<xsd:sequence>
<xsd:element name='run_nbr' minOccurs='1' maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='batch_nbr' minOccurs='1' maxOccurs='1'
>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='unit_nbr' minOccurs='1' maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='material_qty' minOccurs='1' maxOccurs=
'1' type="src:qtyzeroandgreater"/>
<xsd:element name='load' minOccurs='1' maxOccurs=
'unbounded' type='src:loadtype'/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name='loadtype'>
<xsd:sequence>
<xsd:element name='load_id' minOccurs='1' maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="8" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='storage_loc_nbr' minOccurs='1' maxOccurs='1'
>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='qc_status_code' minOccurs='1' maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="2" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='adjustment_qty' minOccurs='0' maxOccurs='1'
type="src:qtygreaterthanzero"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>