[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

<xsd:all> problem

  • To: xml-dev@l...
  • Subject: <xsd:all> problem
  • From: PeterHowells@h...
  • Date: Wed, 12 Jun 2002 17:40:26 +0100
  • Thread-index: AcISL9uQb061C3klEdaG/AAA9v8Ucw==
  • Thread-topic: <xsd:all> problem

xsd all
I tried to find the FAQ for this list but there 
doesn't appear to be one.

If you are like the guy in the comic shop in "The Simpsons" 
please don't bother replying, otherwise :-

I have a problem with my schema.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="person">
  <xsd:complexType  >
    <xsd:all minOccurs="0" maxOccurs="1">
      <xsd:element name="firstname" type="xsd:string"/>
      <xsd:element name="lastname" type="xsd:string"/>
    </xsd:all>
  </xsd:complexType>
</xsd:element>
</xsd:schema>

and the xml is :-

<person>	
	<firstname>peter</firstname>
	<lastname>howells</lastname>
</person>

and it validates OK.

But when I comment out the <lastname> element like this :-

<person>	
	<firstname>peter</firstname>
<!--
	<lastname>howells</lastname>
-->
</person>

I get this error message :-

Error loading XML document: Element content is incomplete according to the 
DTD/Schema.

How come ?

I'm using this code to do the validation :-

Private Sub cmdValidate_Click()

    Dim schemaCache     As msxml2.XMLSchemaCache40
    'Dim doc             As msxml2.DOMDocument40
    Dim doc             As msxml2.DOMDocument30
    Dim sError          As String
    
    rtbMain.Text = ""
    
    Set doc = New msxml2.DOMDocument40
    Set schemaCache = New msxml2.XMLSchemaCache40
    
    On Error Resume Next
    schemaCache.Add "", txtXSD.Text
    If Err.Number <> 0 Then
        MsgBox "Error in schema: " & Err.Description, vbCritical, "XSD 
Validator"
        Exit Sub
    End If
    
    Set doc.schemas = schemaCache
    doc.async = False
    If Not doc.Load(txtXML.Text) Then
        sError = "Error loading XML document: " & doc.parseError.reason & 
vbCrLf & _
                 "Line Number: " & doc.parseError.Line & vbCrLf & _
                 "Line Position: " & doc.parseError.linepos & vbCrLf & _
                 "Error Code: " & doc.parseError.errorCode & vbCrLf & _
                 "File Position: " & doc.parseError.filepos & vbCrLf & _
                 "Text In Error: " & doc.parseError.srcText & vbCrLf & _
                 "URL: " & doc.parseError.url
        rtbMain.SelColor = vbRed
        rtbMain.Text = sError
    Else
        rtbMain.SelColor = vbBlack
        rtbMain.Text = "Validation succeeded. No errors."
    End If
End Sub


> Peter Howells
> Peter Howells
> Web Developer
> Halifax Bank Of Scotland (HBOS) plc
> Retail Bank IT - Mortgage Sales Platform (MSP)
> Dean Clough (G1)
> 
> 
> 

------------------------------------------------------------------------------
Halifax plc, Registered in England No. 2367076.  Registered Office: Trinity Road, Halifax, West Yorkshire HX1 2RG. Regulated by the Financial Services Authority.  Represents only the Halifax Financial Services Marketing Group for the purposes of advising on and selling life assurance, pensions and collective investment scheme business.  Switchboard 01422 333333.

==============================================================================


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.