×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jul 2008
    Location
    Brasil, São Paulo, Ribeirão Preto
    Posts
    5

    Validation of XML with XSD

    Good morning to all, I wonder if we need something in my application to have that validation, or if need only indicate my XSD in XML, I am using the KXML.

    My files to test:

    XML (teste.xml):
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <order xmlns="urn:nonstandard:test"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="urn:nonstandard:test 
         file:./test.xsd">
        <user>
            <fullname>Bob Jones</fullname>
            <deliveryAddress>
                123 This road,
                That town,
                Bobsville
            </deliveryAddress>
        </user>
        <products>
            <product id="12345" quantity="1" />
            <product id="3232" quantity="3" />
        </products>
    </order>
    XSD(teste.xsd):
    Code:
     <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                elementFormDefault="qualified"
                xmlns="urn:nonstandard:test" 
                targetNamespace="urn:nonstandard:test">
    
    
        <xsd:element name="order" type="Order" />
        <xsd:complexType name="Order">
            <xsd:all>
                <xsd:element name="user" type="User" minOccurs="1" maxOccurs="1" />
                <xsd:element name="products" type="Products" minOccurs="1" maxOccurs="1" />
            </xsd:all>
        </xsd:complexType>
    
    
        <xsd:complexType name="User">
            <xsd:all>
            
                <xsd:element name="deliveryAddress" type="xsd:string" />
            
                <xsd:element name="fullname">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:maxLength value="30" />
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                
            </xsd:all>
        </xsd:complexType>
    
    
        <xsd:complexType name="Products">
    
    
            <xsd:sequence>
                <xsd:element name="product" type="Product" minOccurs="1" maxOccurs="unbounded" />
            </xsd:sequence>
        </xsd:complexType>
    
    
        <xsd:complexType name="Product">
            <xsd:attribute name="id" type="xsd:long" use="required" />
            <xsd:attribute name="quantity" type="xsd:positiveInteger" use="required" />
        </xsd:complexType>
    
    
    </xsd:schema>
    http://programero.blogspot.com/

    O coração tem razões que a própria razão desconhece.

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Validation of XML with XSD

    Hi du_nirvana,

    afaik, kXml has no XML validation features. So, to accomplish such a task, you should write validation logic by your own, or search some alternative libraries (I'm not aware of any in Java ME that could suit your needs)..

    Pit

Similar Threads

  1. Parsing wbxml file to xml file using kxml parser
    By ramyashashe in forum Mobile Java General
    Replies: 18
    Last Post: 2010-05-17, 15:56
  2. Replies: 21
    Last Post: 2009-04-18, 12:00
  3. Need knowledge about XML and XML Parsing
    By 02060515 in forum Mobile Java General
    Replies: 1
    Last Post: 2008-07-07, 08:41
  4. generating an XML file..
    By mayankkedia in forum Symbian
    Replies: 0
    Last Post: 2007-01-10, 14:42
  5. Sending XML file from server to mobile
    By bvsbh in forum Mobile Java General
    Replies: 1
    Last Post: 2005-11-30, 14:21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×