Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dumb xmladapter or Dumb me
Message
De
26/06/2003 19:32:30
 
 
À
26/06/2003 15:36:09
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Divers
Thread ID:
00803232
Message ID:
00804499
Vues:
37
This message has been marked as the solution to the initial question of the thread.
>Sorry, the email which I sent yesterday got "stuck" in my outbox! You should have the email now.
>
>This code we are discussing is a method in a generic class for transporting cursors from one system to another. If it is necessary to "program for the data" then it is less valuable as a class. However, I may need to subclass for only this table although I will try not to.
>
>I will test the code sample which you have provided and see if I can implement this code into my base class.
>
>Please let me know what you find with the data which I sent you.
>


Hi Glenn,

It looks like MSXML4 treats some characters as invalid characters for XML document. For example, you are using CHR(6) and MSXML4 complains. In that field you are using all character codes (1-255) and the proper way to handle this field is to map it to one of binary XML types. When VFP maps native data type to XML data type, it doesn't use hexBinary type.
It is possible to write generic code that will map all Character (binary) fields to hexBinary type and hexBinary type back to Character (binary). Here is an example:
CLOSE DATABASES all
CLEAR
SET MEMOWIDTH TO 150

CREATE CURSOR foo (cc c(1), cb c(1) NOCPTRANS)
INSERT INTO foo VALUES ("A",CHR(6))

LOCAL oXA as XMLAdapter, oXT as XMLTable, oXF as XMLField

oXA=CREATEOBJECT("XMLAdapter")
oXA.AddTableSchema("foo",.T.)

FOR EACH oXT IN oXA.Tables
	FOR EACH oXF IN oXT.Fields
		IF oXF.DataType='C' AND oXF.NoCpTrans= .T.
			oXF.XSDtype=""
			oXF.IsBinary=.T.
			oXF.IsBase64= .F.
			oXF.DisableEncode=.F.
		ENDIF
	ENDFOR
ENDFOR

oXA.ToXML("cXml",,.F.)

?cXml

oXA=null
oXF=null

oXA=CREATEOBJECT("XMLAdapter")
oXA.LoadXML(cXml,.F.)

FOR EACH oXT IN oXA.Tables
	FOR EACH oXF IN oXT.Fields
		?oXF.XSDtype
		IF 		oXF.XSDtype=="hexBinary" AND ;
				VAL(oXF.XSDmaxLength)>0 AND ;
				VAL(oXF.XSDmaxLength)<255
		 	oXF.DisableEncode=.F. 	
			oXF.IsBinary=.T.
			oXF.IsBase64= .F.
			oXF.DataType="C"
			oXF.NoCpTrans= .T.
		ENDIF
	ENDFOR
ENDFOR

oXA.Tables(1).ToCursor(.F.,"foo1")

SELECT foo1
DISPLAY STRUCTURE 
GO top
?cc,ASC(cb)

return
Thanks,
Aleksey.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform