views:

253

answers:

0

Source

 XSD:-------------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"  elementFormDefault="qualified">
    <xsd:element name="labor_invoice" type="labor_invoice_type"/>
    <xsd:element name="parts_invoice" type="parts_invoice_type"/>
    <xsd:complexType name="labor_invoice_type">
        <xsd:sequence>
            <xsd:element name="invoice_number" type="xsd:string"></xsd:element>
            <xsd:element name="labor_quantity" type="xsd:float"></xsd:element>
            <xsd:element name="travel_time" type="xsd:float"></xsd:element>
            <xsd:element name="tax" type="xsd:float"></xsd:element>
            <xsd:element name="closing_number">
               <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                       <xsd:minLength value="1"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="line_item" maxOccurs="unbounded" minOccurs="0">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="name" type="xsd:string"></xsd:element>
                        <xsd:element name="quantity" type="xsd:float"></xsd:element>
                        <xsd:element name="rate" type="xsd:float"></xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
        <xsd:attribute name="event_id" type="xsd:positiveInteger"/>
        <xsd:attribute name="user_id" type="xsd:positiveInteger"/>
    </xsd:complexType>
    <xsd:complexType name="parts_invoice_type">
        <xsd:sequence>
            <xsd:element name="invoice_number" type="xsd:string"></xsd:element>
            <xsd:element name="tax" type="xsd:float"></xsd:element>
            <xsd:element name="freight" type="xsd:float"></xsd:element>
            <xsd:element name="tracking_number" type="xsd:string"></xsd:element>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

XML ----------

<?xml version="1.0" encoding="UTF-8"?>
<labor_invoice event_id='4334' user_id='14'>
    <invoice_number>Z1234</invoice_number>
    <labor_quantity>5</labor_quantity>
    <travel_quantity>10</travel_quantity>
    <tax>100.00</tax>
    <closing_number>jkhjkh</closing_number>
   <line_item>
       <name></name>
       <quantity></quantity>
       <rate></rate>
   </line_item>
    <line_item>
       <name></name>
       <quantity></quantity>
       <rate></rate>
   </line_item>
   <line_item>
       <name></name>
       <quantity></quantity>
       <rate></rate>
   </line_item>
</labor_invoice>

My issue when I run this I get the following error: Warning: DOMDocument::schemaValidate() [domdocument.schemavalidate]: Element 'closing_number': [facet 'minLength'] The value has a length of '0'; this underruns the allowed minimum length of '1'. in /var/www/IEA/index.php on line 9

I want php to only throw an error when it finds (empty).

Thank you in advance.