=========================
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]