Jump to content

XML/XSD Validation Problem

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
Root23

Root23

    Programmer

  • Members
  • PipPipPipPip
  • 144 posts
I created an XML file that uses an XSD for validation. When I run 'Validate XML' in NetBeans I get the following message:

Quote

XML validation started.
Checking file:/F:/school/Fall2010/XML/XMLWork/hw1/homeWork1.xml...
Referenced entity at "file:/F:/school/Fall2010/XML/XMLWork/hw1/homeWork1.xsd".
s4s-elt-invalid-content.1: The content of '#AnonType_XMLParty' is invalid. Element 'element' is invalid, misplaced, or occurs too often. [5]
XML validation finished.
This is line #5 it's referencing:
<xsd:element name="Party" minOccurs="0" maxOccurs="2">
Does it mean I'm missing a closing tag somewhere in the XSD? I've scanned the file for quite some time, and I'm not seeing anything missing. Any help would be greatly appreciated.

Below is the XML and then the XSD..
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!--
    Document   : homeWork1.xml
    Created on : August 31, 2010, 8:38 PM
    Author     : Cody 
    Description:
        XML homeWork1 XML/DTD/XDS.
-->
<!--<!DOCTYPE XMLParty SYSTEM "homeWork1.dtd">-->
<XMLParty xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="homeWork1.xsd">
    <Party>
        <PartyID></PartyID>
        <Name>
            <Name1></Name1>
            <Name2></Name2>
            <Name3></Name3>
        </Name>
        <Street>
            <Street1></Street1>
            <Street2></Street2>
            <Street3></Street3>
            <Street4></Street4>
        </Street>
        <PostalInfo>
            <City></City>
            <CountrySubEntity></CountrySubEntity>
            <PostalCode></PostalCode>
            <Country></Country>
        </PostalInfo>
        <Contact>
            <!-- <Name1></Name1> -->
            <StructuredName>
                <Title></Title>
                <FirstNames>
                    <Name1></Name1>
                    <Name2></Name2>
                    <Name3></Name3>
                </FirstNames>
                <Surname></Surname>
            </StructuredName>
            <TelNum></TelNum>
            <Email></Email>
            <Fax></Fax>
            <MailStop></MailStop>
            <JobTitle></JobTitle>
            <Description></Description>
        </Contact>
        <Ref></Ref>
    </Party>
</XMLParty>

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="XMLParty">
        <xsd:complexType>
            <xsd:element name="Party" minOccurs="0" maxOccurs="2">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="PartyID" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="Name" minOccurs="0" maxOccurs="1">
                            <xsd:complexType>
                                <xsd:sequence>
                                    <xsd:element name="Name1" type="xsd:string" minOccurs="1" maxOccurs="1"/>
                                    <xsd:element name="Name2" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                    <xsd:element name="Name3" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                </xsd:sequence>
                            </xsd:complexType>
                        </xsd:element>
                        <xsd:element name="Street" minOccurs="0" maxOccurs="1">
                            <xsd:complexType>
                                <xsd:sequence>
                                    <xsd:element name="Street1" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                    <xsd:element name="Street2" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                    <xsd:element name="Street3" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                    <xsd:element name="street4" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                </xsd:sequence>
                            </xsd:complexType>
                        </xsd:element>
                        <xsd:element name="PostalInfo" minOccurs="0" maxOccurs="1">
                            <xsd:complexType>
                                <xsd:sequence>
                                    <xsd:element name="City" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                    <xsd:element name="CountrySubEntity" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                    <xsd:element name="PostalCode" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                    <xsd:element name="Country" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                </xsd:sequence>
                            </xsd:complexType>
                        </xsd:element>
                        <xsd:element name="Contact" minOccurs="0" maxOccurs="unbounded">
                            <xsd:complexType>
                                <xsd:choice>
                                    <xsd:element name="Name1" minOccurs="0" maxOccurs="1"/>
                                    <xsd:element name="StructuredName" minOccurs="0" maxOccurs="1">
                                        <xsd:complexType>
                                            <xsd:sequence>
                                                <xsd:element name="Title" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                                <xsd:element name="FirstName" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                                    <xsd:complexType>
                                                        <xsd:sequence>
                                                            <xsd:element name="Name1" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                                            <xsd:element name="Name2" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                                            <xsd:element name="Name3" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                                        </xsd:sequence>
                                                    </xsd:complexType>
                                                <xsd:element name="SurName" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                            </xsd:sequence>
                                        </xsd:complexType>
                                    </xsd:element>
                                </xsd:choice>
                                <xsd:element name="TelNum" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                <xsd:element name="Email" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                <xsd:element name="Fax" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                <xsd:element name="Mailstop" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                <xsd:element name="JobTitle" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                                <xsd:element name="Description" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                            </xsd:complexType>
                        </xsd:element>
                        <xsd:element name="Ref" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

Posted Image

#2
Root23

Root23

    Programmer

  • Members
  • PipPipPipPip
  • 144 posts
Well, apparently there's an issue with Netbeans and XSDs.. so I'm hoping that the XSD was fine.

Now, I'd like to find a good *free* alternative to XMLSpy. It seems XMLSpy seems to set the standard... Apparently they used to have a Home Edition that was free. I found a download for Home Edition 2006, and although it was free you had to request a serial from it. Well, since they no longer support it, they won't supply me with the serial number to activate it. So this 'free' software can't even be used.
Posted Image

#3
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
I use EditX. Not the best but it does the job and is free... i think. I don't remember me paying for it or anything.

#4
Root23

Root23

    Programmer

  • Members
  • PipPipPipPip
  • 144 posts
I actually installed that last night, shortly after posting. I haven't actually checked it out yet though.

I emailed this company called Liquid-Technologies that has a program called Liquid XML Studio 2010 to see if they offered a student discount. They said if I had to school get in touch with them they would give us free licenses (for the computers in the XML class). So I'm going to talk to my XML teacher tonight. I'd still like to know if they had jus a regular student discount for my own laptop.
Posted Image

#5
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
Well Visual Studio comes as Express editions that are free. XSD and XML handling is very easy with Visual Studio

#6
Root23

Root23

    Programmer

  • Members
  • PipPipPipPip
  • 144 posts
I'll have to check that out.. I actually have VS 2010 Pro on my laptop. It was free since I'm a student (dreamspark.com)
Posted Image