XML
Schema error - can't see it.
Gravatar is a globally recognized avatar based on your email address. Schema error - can't see it.
  Carl Chambers
  All
  Feb 4, 2017 @ 09:11am

I have a problem with the schema in a simple test and I'm not seeing it.

The following code...

loSubscription = CREATEOBJECT("empty")
ADDPROPERTY(loSubscription,"customer","Acme Stuff")
ADDPROPERTY(loSubscription,"subscriber",.T.)
ADDPROPERTY(loSubscription,"premium",.F.)

SET CLASSLIB TO wwXML.vcx ADDITIVE
loXML = CREATEOBJECT("wwXML")
lcSchema = "c:\webconnectionprojects\psparts\web\schemas\subscription.xsd"
lcXML = m.loXML.CreateObjectXML(loSubscription,"subscription",0,lcSchema)

loObject = loXML.XMLToObject(lcXML)
IF loXML.lError
  MESSAGEBOX(loXML.cErrorMsg)
ELSE
  WAIT window
ENDIF

produces this XML...

<subscription xmlns="x-schema:c:\webconnectionprojects\psparts\web\schemas\subscription.xsd" type="object" class="empty">
	<customer>Acme Stuff</customer>
	<premium>0</premium>
	<subscriber>1</subscriber>
</subscription>

and this schema...

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="subscription">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="customer" type="xs:string" minOccurs='1' maxOccurs='1'/>
        <xs:element name="subscriber" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
        <xs:element name="premium" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
</xs:schema>

produces this error...

Error opening input file: 'c:\webconnectionprojects\psparts\web\schemas\subscription.xsd'.
Incorrect definition for the root element in schema.

Line: 2
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

This line matches samples that I have found. Any idea what I've done wrong?

Thanks,
Carl

Gravatar is a globally recognized avatar based on your email address. re: Schema error - can't see it.
  Rick Strahl
  Carl Chambers
  Feb 4, 2017 @ 11:14am

Schemas have to be specified as URLs so you probably have to prefix the file name with file:///c:\.....

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Schema error - can't see it.
  Carl Chambers
  Rick Strahl
  Feb 4, 2017 @ 01:30pm

Thanks Rick, but that didn't do it.

Next, I uploaded the XSD file to the web server, hit the URL with the browser to make sure I had the URL right, and put that schema URL in my test program - same error.

The error message references the 2nd line of the schema. But this line is the same as samples have found online. There must be something else but I'm just not seeing it.

Carl

© 1996-2024