Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error with wwXML.ObjecttoXML
Message
From
01/09/2004 09:46:48
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Title:
Error with wwXML.ObjecttoXML
Miscellaneous
Thread ID:
00938384
Message ID:
00938384
Views:
80
I've recently downloaded wwXML from West-Wind. I've put together a very simple class and am attempting to change it to XML, then use the XML to populate the properties of a new class. I would like to included the DTD in the XML so it can adapt to more complex classes.

I've gotten this process to work when I do not include the DTD; however, when I include it I receive the following error:
The attribute 'type' on this element is not defined in the DTD/Schema.
Line: 32
	<test type="object" class="test">
I'm sure this is very simple but I don't have a clue. Here is some code that will generate the error:
************* BEGIN SAMPLE PRG ********************

CLEAR

* Set this to include the location of wwutils.prg,wwhttp.prg,wwxml.vcx
SET PATH TO d:\acprojects\canfitu;d:\classes\wwxml

SET PROCEDURE TO wwutils.prg
SET PROCEDURE TO wwhttp.prg additive
SET CLASSLIB TO wwxml.vcx

LOCAL oTest,oTest2
oTest = CREATEOBJECT("test")
oTest2 = CREATEOBJECT("test")

oTest.nCol1Width = 500
cxml = oTest.Serialize()
?"Before Deserialize:",oTest2.nCol1Width
oTest2.Deserialize(cxml)
?"After Deserialize:",oTest2.nCol1Width
?"*Should be = 500"

?"ERROR MESSAGE:"
?oTest2.cError 

DEFINE CLASS test as Session

	cConfigPath = ""

	cError = ""	
	cFont = "Arial"
	nFontSize = 24
	nFontColor = 0
	nRowHeight = 20
	nNoteFontSize = 10
	cNoteFont = "Arial"
	nCol1Width = 10
	nCol2Width = 10
	nCol3Width = 30

	*********************************************************
	* PROCEDURE: Serialize
	* PURPOSE: Uses wwXML to convert this class to XML for easy storage
	* RETURNS: Nothing
	********************************************
	PROCEDURE Serialize() as String 
		LOCAL oXML as wwXML
		
		oXML = CREATEOBJECT("wwXML")
*		oXML.lRecurseObjects = .T.
		
		* Exclude any properties that are inherited from session
		oXML.cPropertyExclusionList = oXML.cPropertyExclusionList + ",datasession,datasessionid"
		oXML.nCreateDataStructure = 2
		
		RETURN oXML.ObjectToXML(this,'abcdefg')
	ENDPROC 

	*********************************************************
	* PROCEDURE: DeSerialize
	* PURPOSE: Uses wwXML to convert this class from XML back to an object for easy storage
	* RETURNS: Nothing
	********************************************
	PROCEDURE DeSerialize(cXML as String ) as Boolean 
	
		* Check parameter
		IF VARTYPE(cXML) # "C" OR EMPTY(cXML)
			RETURN .F.
		ENDIF 
		LOCAL oXML as wwXML
		
		oXML = CREATEOBJECT("wwXML")
*		oXML.lRecurseObjects = .T.

		* Exclude any properties that are inherited from session
		oXML.cPropertyExclusionList = oXML.cPropertyExclusionList + ",datasession,datasessionid"

		IF ISNULL(oXML.XMLtoObject(cXML))
			this.cError = oXML.cerrormsg
			RETURN .F.
		ELSE
			RETURN .T.
		ENDIF 
	ENDPROC 

ENDDEFINE 
Reply
Map
View

Click here to load this message in the networking platform