[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] <xsd:all> problem
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|