This discussion is archived
1 Reply Latest reply: May 7, 2012 2:49 AM by EJP RSS

XML Validation failing

908463 Newbie
Currently Being Moderated
Hi,
I have XSD file, My application generates xml file dynamically.
When validating my xml with the XSD i am getting below exception messages.please find the code of XSD amd XML files.

org.xml.sax.SAXParseException: cvc-pattern-valid: Value '300' is not facet-valid with respect to pattern '[0-2][0-9][0-5][0-9]' for type 'TimeValidation'.

org.xml.sax.SAXParseException: cvc-type.3.1.3: The value '300' of element 'StartTime' is not valid.

org.xml.sax.SAXParseException: cvc-complex-type.2.4.d: Invalid content was found starting with element 'AutoReplyText'. No child element is expected at this point.





XSD_Code_


This XML file does not appear to have any style information associated with it. The document tree is shown below.
<xsd:schema><xsd:element name="AutoReplyReq"><xsd:complexType><xsd:sequence><xsd:element name="TransactionID" type="TransIDValidation"/><xsd:element name="MSISDN" type="MSISDNTYPE"/><xsd:element name="Action" type="Action"/><xsd:element name="AutoReplyElements" type="AutoReplyElements" minOccurs="0" maxOccurs="10"/></xsd:sequence></xsd:complexType></xsd:element><xsd:complexType name="AutoReplyElements"><xsd:sequence><xsd:element name="AutoReplyId" type="IdValidation" minOccurs="1"/><xsd:element name="KeyWordList" type="xsd:string" minOccurs="0"/><xsd:element name="AutoReplyText" type="TextValidation" minOccurs="0"/><xsd:element name="OARuleName" type="NameValidation" minOccurs="0"/><xsd:element name="OARuleType" type="OARuleType" minOccurs="0"/><xsd:element name="OAList" type="OAListValidation" minOccurs="0"/><xsd:element name="TBSRuleName" type="NameValidation" minOccurs="0"/><xsd:element name="TBSRuleType" type="OARuleType" minOccurs="0"/><xsd:element name="StartDay" type="DayValidation" minOccurs="0"/><xsd:element name="EndDay" type="DayValidation" minOccurs="0"/><xsd:element name="StartTime" type="TimeValidation" minOccurs="0"/><xsd:element name="EndTime" type="TimeValidation" minOccurs="0"/></xsd:sequence></xsd:complexType><xsd:simpleType name="TransIDValidation"><xsd:restriction base="xsd:int"><xsd:minInclusive value="1"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="NameValidation"><xsd:restriction base="xsd:string"><xsd:minLength value="1"/><xsd:maxLength value="20"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="TextValidation"><xsd:restriction base="xsd:string"><xsd:minLength value="1"/><xsd:maxLength value="160"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="MSISDNTYPE"><xsd:restriction base="xsd:long"><xsd:pattern value="\d{10,21}"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="OAListValidation"><xsd:restriction base="xsd:string"><xsd:pattern value="([0-9,]+)"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="TimeValidation"><xsd:restriction base="xsd:int"><xsd:pattern value="[0-2][0-9][0-5][0-9]"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="Action"><xsd:restriction base="xsd:string"><xsd:enumeration value="Subscribe"/><xsd:enumeration value="Activate"/><xsd:enumeration value="Update"/><xsd:enumeration value="Delete"/><xsd:enumeration value="Deactivate"/><xsd:enumeration value="Unsubscribe"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="OARuleType"><xsd:restriction base="xsd:string"><xsd:enumeration value="All"/><xsd:enumeration value="Specific"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="IdValidation"><xsd:restriction base="xsd:int"><xsd:minInclusive value="0"/><xsd:maxInclusive value="20"/></xsd:restriction></xsd:simpleType><xsd:simpleType name="DayValidation"><xsd:restriction base="xsd:int"><xsd:minInclusive value="1"/><xsd:maxInclusive value="7"/></xsd:restriction></xsd:simpleType></xsd:schema>



XML code

<?xml version="1.0"?>
<AutoReplyReq>
<TransactionID>5</TransactionID>
<MSISDN>919988776655</MSISDN>
<Action>Activate</Action>
<AutoReplyElements>
<AutoReplyId>4</AutoReplyId>
<KeyWordList>hhhhhhhhhhhhhhhhhhhhhhhkkkkkk</KeyWordList>
<OARuleName>ppppppppp</OARuleName><OARuleType>Specific</OARuleType><OAList>7458963251</OAList><TBSRuleName>ddfdfdf</TBSRuleName><TBSRuleType>Specific</TBSRuleType><StartDay>1</StartDay><EndDay>5</EndDay><StartTime>0</StartTime><EndTime>1300</EndTime><AutoReplyText>rrrrrrrrrrrrrrrrrrrrrr</AutoReplyText></AutoReplyElements></AutoReplyReq>


Please do needful in fixing this issue.
  • 1. Re: XML Validation failing
    EJP Guru
    Currently Being Moderated
    The value '300' of element 'StartTime' is not valid
    According to that you have <StartTime>300</StartTime>
    <StartTime>0</StartTime>
    According to that you have zero. However the exception doesn't agree with you.
    Please do needful in fixing this issue.
    It is you that wil fix this issue. All you will get here is advice and guidance.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points