OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   <xsd:all> problem

[ Lists Home | Date Index | Thread Index ]

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.

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





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS