You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Evaristo Camarero (JIRA)" <xm...@xml.apache.org> on 2005/03/01 13:06:55 UTC

[jira] Created: (XMLBEANS-113) ORDER IN XML INSTANCES

ORDER IN XML INSTANCES
----------------------

         Key: XMLBEANS-113
         URL: http://issues.apache.org/jira/browse/XMLBEANS-113
     Project: XMLBeans
        Type: Bug
    Versions: Version 2 Beta 1    
 Environment: JAVA 1.4.2_07 ; LINUX (Fedora Core 2) ; Intel Platform
    Reporter: Evaristo Camarero



Hi:

I have been playing with the examples (easypo.xsd) included in the binary distribution, and I have seen that if you change the elements of the XML documents the parser methods does not report an exception claiming that the XML instance does not comply the schema. According to cheme specs, the order of defined elements should be maintained in the XML instances.

The schema file I have employed is:

<xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:po="http://openuri.org/easypo"
    targetNamespace="http://openuri.org/easypo"
    elementFormDefault="qualified">
    <xs:element name="purchase-order">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="customer" type="po:customer"/>
                <xs:element name="date" type="xs:dateTime"/>
                <xs:element name="line-item" type="po:line-item" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element name="shipper" type="po:shipper" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:complexType name="customer">
        <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="address" type="xs:string"/>
        </xs:sequence>
        <xs:attribute name="age" type="xs:int"/>
        <xs:attribute name="moo" type="xs:int" default="100"/>
        <xs:attribute name="poo" type="xs:int" fixed="200"/>
    </xs:complexType>
    <xs:complexType name="line-item">
        <xs:sequence>
            <xs:element name="description" type="xs:string"/>
            <xs:element name="per-unit-ounces" type="xs:decimal"/>
            <xs:element name="price" type="xs:decimal"/>
            <xs:element name="quantity" type="xs:integer"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="shipper">
        <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="per-ounce-rate" type="xs:decimal"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>


And for instance this a XML instance that does not comply the schema (date element is before customer element):

<purchase-order xmlns="http://openuri.org/easypo">
    <date>2003-01-07T14:16:00-05:00</date>
    <customer>
        <address>Anytown, PA</address>
        <name>Gladys Kravitz</name>
    </customer>
    <line-item>
        <description>Burnham's Celestial Handbook, Vol 1</description>
        <per-unit-ounces>5</per-unit-ounces>
        <price>21.79</price>
        <quantity>2</quantity>
    </line-item>
    <line-item>
        <description>Burnham's Celestial Handbook, Vol 2</description>
        <per-unit-ounces>5</per-unit-ounces>
        <price>19.89</price>
        <quantity>2</quantity>
    </line-item>
    <shipper>
        <name>ZipShip</name>
        <per-ounce-rate>0.74</per-ounce-rate>
    </shipper>
</purchase-order>


Thank you very much for your help

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[jira] Resolved: (XMLBEANS-113) ORDER IN XML INSTANCES

Posted by "Kevin Krouse (JIRA)" <xm...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XMLBEANS-113?page=history ]
     
Kevin Krouse resolved XMLBEANS-113:
-----------------------------------

    Resolution: Invalid

Parsing and validating are two different things in XMLBeans.  Validation does not happen when XmlBeans parses a document.  It is possible to have an invalid document and still be able to use it with XMLBeans.

To validate an instance, first parse it into an XmlObject, then call the .validate() method:

XmlObject xo = XmlObject.Factory.parse(java.io.File("mydoc.xml"));

ArrayList errors = new ArrayList();
XmlOptions options = new XmlOptions().setErrorListener(errors);
if (!xo.validate(options))
{
    for (Iterator iter = errors.iterator(); iter.hasNext(); )
        System.out.println(">> " + iter.next());
}

> ORDER IN XML INSTANCES
> ----------------------
>
>          Key: XMLBEANS-113
>          URL: http://issues.apache.org/jira/browse/XMLBEANS-113
>      Project: XMLBeans
>         Type: Bug
>     Versions: Version 2 Beta 1
>  Environment: JAVA 1.4.2_07 ; LINUX (Fedora Core 2) ; Intel Platform
>     Reporter: Evaristo Camarero

>
> Hi:
> I have been playing with the examples (easypo.xsd) included in the binary distribution, and I have seen that if you change the elements of the XML documents the parser methods does not report an exception claiming that the XML instance does not comply the schema. According to cheme specs, the order of defined elements should be maintained in the XML instances.
> The schema file I have employed is:
> <xs:schema
>     xmlns:xs="http://www.w3.org/2001/XMLSchema"
>     xmlns:po="http://openuri.org/easypo"
>     targetNamespace="http://openuri.org/easypo"
>     elementFormDefault="qualified">
>     <xs:element name="purchase-order">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element name="customer" type="po:customer"/>
>                 <xs:element name="date" type="xs:dateTime"/>
>                 <xs:element name="line-item" type="po:line-item" minOccurs="0" maxOccurs="unbounded"/>
>                 <xs:element name="shipper" type="po:shipper" minOccurs="0" maxOccurs="1"/>
>             </xs:sequence>
>         </xs:complexType>
>     </xs:element>
>     <xs:complexType name="customer">
>         <xs:sequence>
>             <xs:element name="name" type="xs:string"/>
>             <xs:element name="address" type="xs:string"/>
>         </xs:sequence>
>         <xs:attribute name="age" type="xs:int"/>
>         <xs:attribute name="moo" type="xs:int" default="100"/>
>         <xs:attribute name="poo" type="xs:int" fixed="200"/>
>     </xs:complexType>
>     <xs:complexType name="line-item">
>         <xs:sequence>
>             <xs:element name="description" type="xs:string"/>
>             <xs:element name="per-unit-ounces" type="xs:decimal"/>
>             <xs:element name="price" type="xs:decimal"/>
>             <xs:element name="quantity" type="xs:integer"/>
>         </xs:sequence>
>     </xs:complexType>
>     <xs:complexType name="shipper">
>         <xs:sequence>
>             <xs:element name="name" type="xs:string"/>
>             <xs:element name="per-ounce-rate" type="xs:decimal"/>
>         </xs:sequence>
>     </xs:complexType>
> </xs:schema>
> And for instance this a XML instance that does not comply the schema (date element is before customer element):
> <purchase-order xmlns="http://openuri.org/easypo">
>     <date>2003-01-07T14:16:00-05:00</date>
>     <customer>
>         <address>Anytown, PA</address>
>         <name>Gladys Kravitz</name>
>     </customer>
>     <line-item>
>         <description>Burnham's Celestial Handbook, Vol 1</description>
>         <per-unit-ounces>5</per-unit-ounces>
>         <price>21.79</price>
>         <quantity>2</quantity>
>     </line-item>
>     <line-item>
>         <description>Burnham's Celestial Handbook, Vol 2</description>
>         <per-unit-ounces>5</per-unit-ounces>
>         <price>19.89</price>
>         <quantity>2</quantity>
>     </line-item>
>     <shipper>
>         <name>ZipShip</name>
>         <per-ounce-rate>0.74</per-ounce-rate>
>     </shipper>
> </purchase-order>
> Thank you very much for your help

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[jira] Closed: (XMLBEANS-113) ORDER IN XML INSTANCES

Posted by "Jacob Danner (JIRA)" <xm...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XMLBEANS-113?page=all ]
     
Jacob Danner closed XMLBEANS-113:
---------------------------------


Closing

> ORDER IN XML INSTANCES
> ----------------------
>
>          Key: XMLBEANS-113
>          URL: http://issues.apache.org/jira/browse/XMLBEANS-113
>      Project: XMLBeans
>         Type: Bug
>     Versions: Version 2 Beta 1
>  Environment: JAVA 1.4.2_07 ; LINUX (Fedora Core 2) ; Intel Platform
>     Reporter: Evaristo Camarero

>
> Hi:
> I have been playing with the examples (easypo.xsd) included in the binary distribution, and I have seen that if you change the elements of the XML documents the parser methods does not report an exception claiming that the XML instance does not comply the schema. According to cheme specs, the order of defined elements should be maintained in the XML instances.
> The schema file I have employed is:
> <xs:schema
>     xmlns:xs="http://www.w3.org/2001/XMLSchema"
>     xmlns:po="http://openuri.org/easypo"
>     targetNamespace="http://openuri.org/easypo"
>     elementFormDefault="qualified">
>     <xs:element name="purchase-order">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element name="customer" type="po:customer"/>
>                 <xs:element name="date" type="xs:dateTime"/>
>                 <xs:element name="line-item" type="po:line-item" minOccurs="0" maxOccurs="unbounded"/>
>                 <xs:element name="shipper" type="po:shipper" minOccurs="0" maxOccurs="1"/>
>             </xs:sequence>
>         </xs:complexType>
>     </xs:element>
>     <xs:complexType name="customer">
>         <xs:sequence>
>             <xs:element name="name" type="xs:string"/>
>             <xs:element name="address" type="xs:string"/>
>         </xs:sequence>
>         <xs:attribute name="age" type="xs:int"/>
>         <xs:attribute name="moo" type="xs:int" default="100"/>
>         <xs:attribute name="poo" type="xs:int" fixed="200"/>
>     </xs:complexType>
>     <xs:complexType name="line-item">
>         <xs:sequence>
>             <xs:element name="description" type="xs:string"/>
>             <xs:element name="per-unit-ounces" type="xs:decimal"/>
>             <xs:element name="price" type="xs:decimal"/>
>             <xs:element name="quantity" type="xs:integer"/>
>         </xs:sequence>
>     </xs:complexType>
>     <xs:complexType name="shipper">
>         <xs:sequence>
>             <xs:element name="name" type="xs:string"/>
>             <xs:element name="per-ounce-rate" type="xs:decimal"/>
>         </xs:sequence>
>     </xs:complexType>
> </xs:schema>
> And for instance this a XML instance that does not comply the schema (date element is before customer element):
> <purchase-order xmlns="http://openuri.org/easypo">
>     <date>2003-01-07T14:16:00-05:00</date>
>     <customer>
>         <address>Anytown, PA</address>
>         <name>Gladys Kravitz</name>
>     </customer>
>     <line-item>
>         <description>Burnham's Celestial Handbook, Vol 1</description>
>         <per-unit-ounces>5</per-unit-ounces>
>         <price>21.79</price>
>         <quantity>2</quantity>
>     </line-item>
>     <line-item>
>         <description>Burnham's Celestial Handbook, Vol 2</description>
>         <per-unit-ounces>5</per-unit-ounces>
>         <price>19.89</price>
>         <quantity>2</quantity>
>     </line-item>
>     <shipper>
>         <name>ZipShip</name>
>         <per-ounce-rate>0.74</per-ounce-rate>
>     </shipper>
> </purchase-order>
> Thank you very much for your help

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org