Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2007, 08:12 AM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alz6z
Default XML validation error

XML CODEs
<- - - - - - - - -- - - - - - - - -- - - - - - - - -- - - - - - - - -- - - >
<?xml version="1.0"?>
<?xml:stylesheet type="text/xsl" href="test.xsl"?>
<insurance xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd">
<quote>
        <DriverDetails>
            <fullname>
                <LastName>Law</LastName>
                <FirstName>Alan</FirstName>
            </fullname>
        <DOB>04/04/2007</DOB>
        <gender>male</gender>
        <contact>0420308669</contact>
        <address>george st</address>
        <postcode>2144</postcode>
        <previous_insured>Yes</previous_insured>
        </DriverDetails>
        <cardetails>
            <insurancetype>comprehensive</insurancetype>
            <carmaker>benz</carmaker>
            <year>2001</year>
            <transmissiontype>manual</transmissiontype>
            <carmodel>b2500</carmodel>
            <Bodytype>D25</Bodytype>
            <cylinders>6</cylinders>
            <additionalaccessories>car alarm</additionalaccessories>
        </cardetails>
    <Driverhistory>
            <license>2</license>
            <licenseaccured>2004</licenseaccured>
            <accidents>0</accidents>
            <suspension>0</suspension>
            <theft>1</theft>
            <claims>1</claims>
        </Driverhistory>

<quoteno>00001</quoteno>
<Date>12/04/2007</Date>
<time>21:22</time>
    <price>
        <insuredprice>500</insuredprice>
        <extras>50</extras>
        <discounts>2000</discounts>
        <total>2050</total>
    </price>
</quote>
</insurance>

===============================================
XML schema

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
elementFormDefault="qualified">

<xs:element name= "insurance">
    <xs:complexType>
        <xs:sequence>

            <xs:element name="quote" maxOccurs ="unbounded">
                <xs:complexType>
                    <xs:sequence>

                        <xs:element name="DriverDetails">
                            <xs:complexType>
                                <xs:sequence>

                                    <xs:element name="fullname">
                                        <xs:complexType>
                                            <xs:sequence>
                                                <xs:element name="LastName" type="xs:string"/>
                                                <xs:element name="FirstName" type="xs:string"/>
                                            </xs:sequence>
                                        </xs:complexType>
                                    </xs:element>

                                    <xs:element name="DOB" type="xs:string"/>
                                    <xs:element name="gender" type="xs:string"/>
                                    <xs:element name="contact" type="xs:integer"/>
                                    <xs:element name="address" type="xs:string"/>
                                    <xs:element name="postcode" type="xs:integer"/>
                                    <xs:element name="previous_insured" type="xs:string"/>

                                </xs:sequence>
                            </xs:complexType>
                        </xs:element>

                    <xs:element name="cardetails">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="insurancetype" type="xs:string"/>
                                <xs:element name="carmaker" type="xs:string"/>
                                <xs:element name="year" type="xs:string"/>
                                <xs:element name="transmissiontype" type="xs:string"/>
                                <xs:element name="carmodel" type="xs:string"/>
                                <xs:element name="Bodytype" type="xs:string"/>
                                <xs:element name="cylinders" type="xs:string"/>
                                <xs:element name="additionalaccessories" type="xs:string"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>

                    <xs:element name="Driverhistory">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="license" type="xs:integer"/>
                                <xs:element name="licenseaccured" type="xs:integer"/>
                                <xs:element name="accidents" type="xs:integer"/>
                                <xs:element name="suspension" type="xs:yesnostring"/>
                                <xs:element name="theft" type="xs:yesnostring"/>
                                <xs:element name="claims" type="xs:yesnostring"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>



            <xs:element name = "quoteno" type="xs:integer"/>
            <xs:element name = "Date" type="xs:string"/>
            <xs:element name = "time" type="time"/>

                    <xs:element name="price">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="insuredprice" type="xs:float"/>
                                <xs:element name="extras" type="xs:float"/>
                                <xs:element name="discounts" type="xs:float"/>
                                <xs:element name="total" type="xs:float"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>

                </xs:sequence>
            </xs:complexType>
        </xs:element>

        </xs:sequence>
    </xs:complexType>
</xs:element>

===============================================
hi guys, i am new in this forum
i need help with my xml...i keep getting the error msgs "the element 'insurance' is used but not declared in th dtd/schema"
my xml is well formed but i still dont know what the problem is...please help me.

 
Old May 3rd, 2007, 11:06 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well the XML you've shown is referring to a no-namespace schema although the schema shown is targeting the http://www.w3schools.com namespace.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
XML validation error message breithauptj XML 3 March 19th, 2008 01:40 PM
XML validation with XSD ksskumar XML 0 October 12th, 2007 04:46 AM
XML Validation AdamPengelly C# 4 September 8th, 2006 06:36 AM
XML Validation June XML 5 February 17th, 2004 11:41 AM
xml validation error kreddy XML 0 August 20th, 2003 12:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.