Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Importing XML, no parent record id in child table
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Divers
Thread ID:
01042677
Message ID:
01072908
Vues:
20
Hi David,

I did actually have the
parent::parentalias/parentIdField
correct just my description in the email that was wrong.

Thanks for the explanation of parent::, I had indeed assumed that it refered to the parent table not the root node, I will experiment with that and see if it helps.

XML structure:
MessageHeader
PurchaseOrder
PurchaseOrderHeaderText
PurchaseOrderLine
PurchaseOrderNote

In the code listed below I would have expected only the PurchaseOrderLine to fail because of PurchaseOrderHeaderText being its parent but all POId fields return .null.:
LOCAL oAdapter as XMLAdapter, oPOHT as XMLTable, oPOAC as XMLTable, oPON as XMLTable

cFile = "Test.xml"
oAdapter = CREATEOBJECT("XMLAdapter")
oAdapter.LoadXML(cFile,.T.,.T.)

oPOHT=oAdapter.Tables(STRCONV("PurchaseOrderHeaderText",5))
AddXmlField(oPOHT,"parent::PurchaseOrder/AgentPurchaseOrder",.F.,"POId","C",99,.T.)

oPOL=oAdapter.Tables(STRCONV("PurchaseOrderLine",5))
AddXmlField(oPOL,"parent::PurchaseOrder/AgentPurchaseOrder",.F.,"POId","C",99,.T.)

oPOAC=oAdapter.Tables(STRCONV("PurchaseOrderAdditionalCharge",5))
AddXmlField(oPOAC,"parent::PurchaseOrder/AgentPurchaseOrder",.F.,"POId","I",-1,.T.)

oPON=oAdapter.Tables(STRCONV("PurchaseOrderNote",5))
? AddXmlField(oPON,"parent::PurchaseOrder/AgentPurchaseOrder",.F.,"POId","I",-1,.T.)

LOCAL OpenTables
OpenTables=""
FOR EACH oTable IN oAdapter.Tables
	oTable.ToCursor()
	LOCAL lcAlias
	lcAlias=ALIAS()
	SELECT * FROM (lcAlias) INTO TABLE ("Tables\"+lcAlias)
ENDFOR

FUNCTION AddXmlField(oXT,cXMLName,lAttribute,cAlias,cDataType,nMaxLength,lXPath)
	oXF=CREATEOBJECT("XMLField")
	IF VERSION(5)>=900
		oXF.XMLNameIsXPath=lXPath
	ENDIF 
	oXF.XMLName=STRCONV(cXMLName,5)
	oXF.IsAttribute= lAttribute
	oXF.Alias=cAlias
	oXF.DataType=cDataType
	oXF.MaxLength=nMaxLength
	oXF.IsNULL=.T.
	oXT.Fields.Add(oXF,oXF.XMLName)
	RETURN oXF	
ENDFUNC 
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform