If you have a look at your XML : > [java] <shippingRequest xmlns="http://partners.mcdata.com" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://partners.mcdata.com > http://partners.mcdata.com/downloads/it/schema/riverbed_ship_request.xsd > "> > [java] <order_date>2006-03-09</order_date>
As you have specified 'xmlns="http://partners.mcdata.com"', the order_date element's namespace is 'http://partners.mcdata.com'. However if you look at your schema: > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > targetNamespace="http://partners.mcdata.com" > xmlns="http://partners.mcdata.com"> > <!-- Schema definition for shipping requests sent to Riverbed from > McDATA --> > > <xsd:element name="shippingRequest" type="ShippingRequestType"/> > > <xsd:complexType name="ShippingRequestType"> > <xsd:sequence> > <!-- create date of the order --> > <xsd:element name="order_date" type="xsd:date"/> You have not specified 'elementFormDefault="qualified"', so the 'order_date' element's namespace is not "http://partners.mcdata.com". This fails the validation, and is the correct behavior. As I see it, you have two options: 1. Change the XML, and have the definition something like: <ns1:shippingRequest xmlns:ns1="http://partners.mcdata.com" ... </ns1:shippingRequest> OR 2. Add the elementFormDefault="qualified" attribute to the schema element in the schema definition. Either should let you parse the XML validating against the schema. The schema you are trying to validate is simply not valid against the schema you are trying to validate it against currently. Hope this helps, Bindul On 4/20/06, Scott Shaver <[EMAIL PROTECTED]> wrote: > > ========================= > ERROR > ========================== > [java] Thu Apr 20 13:55:00 MDT 2006 > RiverbedShipmentSubscriberMDB.validateSchema(): XML failed > validation:cvc-complex-type.2.4.a: Invalid content was found starting > with element 'order_date'. One of '{order_date}' is expected. Column: 14 > Line: 3 > PublicID: null > ========================== > XML > ========================== > [java] <?xml version="1.0"?> > [java] <shippingRequest xmlns="http://partners.mcdata.com" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://partners.mcdata.com > http://partners.mcdata.com/downloads/it/schema/riverbed_ship_request.xsd > "> > [java] <order_date>2006-03-09</order_date> > [java] <brand_name>McDATA</brand_name> > [java] <shipRequestType>Evaluation</shipRequestType> > [java] <shipHow shippingCarrier="McDATA ROUTED" > shippingServiceLevel="NEXT DAY AM" modeOfTransport="AIR" > freightTerms="MCDATA PAYS"/> > [java] > <exportDocsURL>https://partners.mcdata.com</exportDocsURL> > [java] <so>99165</so> > [java] <po>65512</po> > [java] <customer_po>77836 NRR</customer_po> > [java] <shipTo> > [java] <company>GENERAL ELECTRIC AIRCRAFT ENGINES - > OH</company> > [java] <attn>DAVID SMITHY</attn> > [java] <address>ONE MAN WAY</address> > [java] <city>CINCINNATI</city> > [java] <state>OH</state> > [java] <postalCode>423495</postalCode> > [java] <country>US</country> > [java] </shipTo> > [java] <items> > [java] <item> > [java] <item_reason>NEW</item_reason> > [java] <type>STANDARD</type> > [java] > <creation_date>2006-03-09</creation_date> > [java] <update_date>2006-03-09</update_date> > [java] > <schedule_ship_date>2006-03-16</schedule_ship_date> > [java] <order_line_id>799082</order_line_id> > [java] <quantity>2</quantity> > [java] <part_num>MSHA-03010</part_num> > [java] </item> > [java] <item> > [java] <item_reason>NEW</item_reason> > [java] <type>STANDARD</type> > [java] > <creation_date>2006-03-09</creation_date> > [java] <update_date>2006-03-09</update_date> > [java] > <schedule_ship_date>2006-03-16</schedule_ship_date> > [java] <order_line_id>799091</order_line_id> > [java] <quantity>1</quantity> > [java] <part_num>MCMC-08003</part_num> > [java] </item> > [java] </items> > [java] <comment>ATTN: DAVID SMITHY</comment> > [java] </shippingRequest> > [java] Thu Apr 20 13:55:01 MDT 2006 > RiverbedShipmentSubscriberMDB.createAndSendXML(): Received: > [java] <result><status>ERROR</status><message>Invalid shipping > service level: "NEXT DAY AM".</message></result> > [java] > > =================== > SCHEMA > ==================== > > <?xml version="1.0"?> > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > targetNamespace="http://partners.mcdata.com" > xmlns="http://partners.mcdata.com"> > <!-- Schema definition for shipping requests sent to Riverbed from > McDATA --> > > <xsd:element name="shippingRequest" type="ShippingRequestType"/> > > <xsd:complexType name="ShippingRequestType"> > <xsd:sequence> > <!-- create date of the order --> > <xsd:element name="order_date" type="xsd:date"/> > > <!-- Riverbed or OEM (McDATA) name --> > <xsd:element name="brand_name" type="xsd:string"/> > > <xsd:element name="shipRequestType" type="ShipRequestType"/> > > <xsd:element name="shipHow" type="ShippingMethod"/> > > <!-- URL pointing to a PDF file containing the export documents > --> > <xsd:element name="exportDocsURL" type="xsd:string"/> > > <!-- McDATA so (order) number (this is used in the documentation > file names) --> > <xsd:element name="so" type="xsd:string"/> > > <!-- Riverbed or OEM (McDATA) po number --> > <xsd:element name="po" type="xsd:string"/> > > <!-- Riverbed or OEM customer's PO number --> > <xsd:element name="customer_po" type="xsd:string" minOccurs="0" > maxOccurs="1"/> > > <xsd:element name="shipInstructions" type="xsd:string" > minOccurs="0" maxOccurs="1"/> > > <xsd:element name="shipTo" type="Address"/> > > <xsd:element name="items" type="Items"/> > > <xsd:element name="comment" type="xsd:string" minOccurs="0"/> > > </xsd:sequence> > </xsd:complexType> > > <xsd:simpleType name="ShipRequestType"> > <xsd:restriction base="xsd:string"> > <xsd:enumeration value="Sale"/> > <xsd:enumeration value="Evaluation"/> > <xsd:enumeration value="RMA Replacement"/> > </xsd:restriction> > </xsd:simpleType> > > <xsd:complexType name="ShippingMethod"> > <xsd:attribute name="shippingCarrier" type="xsd:string"/> > <xsd:attribute name="shippingServiceLevel" type="xsd:string"/> > <xsd:attribute name="modeOfTransport" type="xsd:string"/> > <xsd:attribute name="freightTerms" type="xsd:string"/> > </xsd:complexType> > > <xsd:complexType name="Address"> > <xsd:sequence> > <xsd:element name="company" type="xsd:string"/> > <xsd:element name="attn" type="xsd:string" minOccurs="0" > maxOccurs="1"/> > <xsd:element name="address" type="xsd:string"/> > <xsd:element name="address2" type="xsd:string" minOccurs="0" > maxOccurs="1"/> > <xsd:element name="address3" type="xsd:string" minOccurs="0" > maxOccurs="1"/> > <xsd:element name="city" type="xsd:string"/> > <xsd:element name="state" type="xsd:string"/> > <xsd:element name="postalCode" type="xsd:string"/> > <xsd:element name="country" type="xsd:string"/> > <xsd:element name="phone" type="xsd:string" minOccurs="0" > maxOccurs="1"/> > <xsd:element name="email" type="xsd:string" minOccurs="0" > maxOccurs="1"/> > </xsd:sequence> > </xsd:complexType> > > <xsd:simpleType name="LineItemType"> > <xsd:restriction base="xsd:string"> > <xsd:enumeration value="MODEL"/> > <xsd:enumeration value="CLASS"/> > <xsd:enumeration value="OPTION"/> > <xsd:enumeration value="CONFIG"/> > <xsd:enumeration value="STANDARD"/> > </xsd:restriction> > </xsd:simpleType> > > <!-- > An item is a single line item from the McDATA order system. It > doesn't necessarily > represent an actuall orderable part number. Sometime it is just > there to show > configuration information. > --> > <xsd:complexType name="Items"> > <xsd:sequence> > <xsd:element name="item" minOccurs="1" maxOccurs="unbounded"> > <xsd:complexType> > <xsd:sequence> > <!-- the reson this line is in the data --> > <xsd:element name="item_reson" type="xsd:string"/> > > <!-- the type of this line on the order --> > <xsd:element name="type" type="LineItemType"/> > > <!-- create date of the line item --> > <xsd:element name="creation_date" type="xsd:date"/> > > <!-- date of last update to the line item --> > <xsd:element name="update_date" type="xsd:date"/> > > <!-- date the line item is supposed to be shipped --> > <xsd:element name="schedule_ship_date" type="xsd:date"/> > > <!-- this is the order_line_id of the item on the order that > is this items parent line, > if this line is it's own parent then it is the top of a > configured item. This happens > when the part_num element is a star "*" part. A > generated part number for a config. > --> > <xsd:element name="parent_line_id" type="xsd:integer" > minOccurs="0" maxOccurs="1"/> > > <!-- uniquely identifies this PO line item in our OEM's > database --> > <xsd:element name="order_line_id" type="xsd:integer" > minOccurs="1" maxOccurs="1"/> > > <xsd:element name="quantity"> > <xsd:simpleType> > <xsd:restriction base="xsd:positiveInteger"> > <xsd:maxExclusive value="100"/> > </xsd:restriction> > </xsd:simpleType> > </xsd:element> > > <!-- used in the packing list --> > <xsd:element name="part_num" type="xsd:string"/> > > <!-- Special packing instructions, shipping instructions, > etc. --> > <xsd:element name="note" type="xsd:string" minOccurs="0" > maxOccurs="1"/> > > </xsd:sequence> > </xsd:complexType> > </xsd:element> > </xsd:sequence> > </xsd:complexType> > > </xsd:schema> > > ================= > CODE > ================= > validateSchema("http://partners.mcdata.com > http://partners.mcdata.com/downloads/it/schema/riverbed_ship_request.xsd > ", data.toString(), ordernumber); > > public boolean validateSchema(String schemaURL, String xml, String > ordernumber) > { > boolean retval = true; > try > { > DOMParser domParser = new DOMParser(); > > domParser.setFeature("http://xml.org/sax/features/validation",true); > > domParser.setFeature("http://apache.org/xml/features/validation/schema", > true); > > domParser.setFeature("http://apache.org/xml/features/validation/schema-f > ull-checking",true); > > //domParser.setFeature("http://apache.org/xml/features/validation/schema > /normalized-value",true); > > domParser.setFeature("http://apache.org/xml/features/honour-all-schemaLo > cations", true); > > domParser.setProperty("http://apache.org/xml/properties/schema/external- > schemaLocation",schemaURL); > > Validator handler=new Validator(); > domParser.setErrorHandler(handler); > domParser.parse(new InputSource(new StringReader(xml))); > > if(handler.validationError==true) > { > doLogging("validateSchema()","XML failed > validation:"+handler.saxParseException.getMessage()+" Column: > "+handler.saxParseException.getColumnNumber()+" Line: > "+handler.saxParseException.getLineNumber()+" PublicID: > "+handler.saxParseException.getPublicId(),true,true,false); > logError(ordernumber,"XML failed validation:","System"); > //handler.saxParseException.printStackTrace(); > retval=false; > } > else > doLogging("validateSchema()","XML has been > validated",true,true,false); > } > catch (Exception e) > { > e.printStackTrace(); > } > > return retval; > } > > private class Validator extends DefaultHandler > { > public boolean validationError = false; > public SAXParseException saxParseException=null; > > public void error(SAXParseException exception) throws > SAXException > { > validationError = true; > saxParseException=exception; > } > > public void fatalError(SAXParseException exception) throws > SAXException > { > validationError = true; > saxParseException=exception; > } > > public void warning(SAXParseException exception) throws > SAXException > { > doLogging("Validator.warning()",exception.getMessage()+" > Column: "+exception.getColumnNumber()+" Line: > "+exception.getLineNumber()+" PublicID: > "+exception.getPublicId(),true,true,false); > } > > public void processingInstruction(java.lang.String target, > java.lang.String data)throws SAXException > { > doLogging("Validator.processingInstruction()",target+" : > "+data,true,true,false); > } > } > > > > > -----Original Message----- > > From: Michael Glavassevich [mailto:[EMAIL PROTECTED] > > Sent: Thursday, April 20, 2006 2:46 PM > > To: [email protected] > > Subject: RE: Xerces 1.4.4, XML, XSD and validation > > > > "Scott Shaver" <[EMAIL PROTECTED]> wrote on 04/20/2006 > > 03:59:00 PM: > > > > > Well at least it tries now. I still get the error > > > > > > cvc-complex-type.2.4.a: Invalid content was found starting with > > > element 'order_date'. One of '{order_date}' is expected. Column: 14 > > > Line: 3 > > > > > > Which is bogus, the document is correct. > > > > If you made no other changes besides fixing > > xsi:schemaLocation, your document is still invalid. See my > > previous post about elementFormDefault [1]. > > > > [1] > > http://mail-archives.apache.org/mod_mbox/xerces-j-users/200604 > > .mbox/%3cOF91D4F891.4BD2A142-ON85257156.0056699A-85257156.0057 > > [EMAIL PROTECTED] > > > > Michael Glavassevich > > XML Parser Development > > IBM Toronto Lab > > E-mail: [EMAIL PROTECTED] > > E-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > SPECIAL NOTICE > > All information transmitted hereby is intended only for the use of the > addressee(s) named above and may contain confidential and privileged > information. Any unauthorized review, use, disclosure or distribution > of confidential and privileged information is prohibited. If the reader > of this message is not the intended recipient(s) or the employee or agent > responsible for delivering the message to the intended recipient, you are > hereby notified that you must not read this transmission and that disclosure, > copying, printing, distribution or use of any of the information contained > in or attached to this transmission is STRICTLY PROHIBITED. > > Anyone who receives confidential and privileged information in error should > notify us immediately by telephone and mail the original message to us at > the above address and destroy all copies. To the extent any portion of this > communication contains public information, no such restrictions apply to that > information. (gate01) > > --------------------------------------------------------------------- > 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]
