Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Attribute-centric XML
Message
General information
Forum:
Visual FoxPro
Category:
Web Services
Miscellaneous
Thread ID:
00620011
Message ID:
00621221
Views:
18
Hmmm... good point - i hadn't tried with an external schema because in most Web applications that's very difficult to manage because data tends to be dynamically generated.

The following does not work with nodeTypedValue:
CREATE CURSOR Test (Field1 I, Field2 C(30), Field3 DATE, Field4 L)
INSERT INTO Test VALUES (1, "Fabio Vazquez", {^2002-02-16}, .F.)

* ? CURSORTOXML("test", "c:\test.xml", 1, 512, 0, "c:\test.xsd")
lcXML = ""
CURSORTOXML("test", "lcXML",1, 32,0,"1")

Showxml(lcXML)

* Create the DOMDocument to keep the XML in test.xml that will be validated
LOCAL loXML as "MSXML2.DOMDocument.4.0"
loXML = CREATEOBJECT("MSXML2.DOMDocument.4.0")
loXML.loadxml(lcXML)

IF loXML.parseError.errorCode = 0
  loNodes = loXML.selectNodes("VFPData/test/field1")
  ?loNodes.item(0).nodeTypedValue     && returns integer 1
  ?VARTYPE(loNodes.item(0).nodeTypedValue)     && returns integer 1

  loNodes = loXML.selectNodes("VFPData/test/field2")
  ?loNodes.item(0).nodeTypedValue     && returns string "Fabio Vazquez"

  loNodes = loXML.selectNodes("VFPData/test/field3")
  ?loNodes.item(0).nodeTypedValue     && returns date 2002-02-16

  loNodes = loXML.selectNodes("VFPData/test/field4")
  ?loNodes.item(0).nodeTypedValue     && returns boolean false
ELSE
  ?loXML.parseError.reason
ENDIF

loXMLSchema = null
loXML = null
+++ Rick ---

>Rick,
>
>Thank you again for your reply. Please see bellow:
>
>
>I don't think so. AS you say MSXML 3.0 is not schema aware and the schema generated by VFP 7 does not work as a truly schema'd document because you can't access the nodes with nodeTypedValue() which would indicate that typing is applied.
>

>The following code uses MSMXL 4.0 parser in order to validate an XML document generated by VFP 7 CURSORTOXML(). According to the results, nodeTypedValue() can be used. Do your comments apply to this or to something else?
>
>
>CREATE CURSOR Test (Field1 I, Field2 C(30), Field3 DATE, Field4 L)
>INSERT INTO Test VALUES (1, "Fabio Vazquez", {^2002-02-16}, .F.)
>
>?CURSORTOXML("test", "c:\test.xml", 1, 512, 0, "c:\test.xsd")
>
>* Create a schema cache object to keep the schema in test.xsd
>LOCAL loXMLSchema as "MSXML2.XMLSchemaCache.4.0"
>loXMLSchema = CREATEOBJECT("MSXML2.XMLSchemaCache.4.0")
>loXMLSchema.add("","c:\test.xsd")
>
>* Create the DOMDocument to keep the XML in test.xml that will be validated
>LOCAL loXML as "MSXML2.DOMDocument.4.0"
>loXML = CREATEOBJECT("MSXML2.DOMDocument.4.0")
>loXML.schemas = loXMLSchema
>loXML.load("c:\test.xml")
>
>IF loXML.parseError.errorCode = 0
>  loNodes = loXML.selectNodes("VFPData/test/field1")
>  ?loNodes.item(0).nodeTypedValue     && returns integer 1
>
>  loNodes = loXML.selectNodes("VFPData/test/field2")
>  ?loNodes.item(0).nodeTypedValue     && returns string "Fabio Vazquez"
>
>  loNodes = loXML.selectNodes("VFPData/test/field3")
>  ?loNodes.item(0).nodeTypedValue     && returns date 2002-02-16
>
>  loNodes = loXML.selectNodes("VFPData/test/field4")
>  ?loNodes.item(0).nodeTypedValue     && returns boolean false
>ELSE
>  ?loXML.parseError.reason
>ENDIF
>
>loXMLSchema = null
>loXML = null
>
>
>
>So, the schema is parsed internally in the VFP guts and cursors are created accordingly. As long as your schema sticks to the same format and data types VFP should have no problem dealing with the data. But vary the schema to one it's not expecting and it'll likely fail on schema validation. But because of the two pass functionality in VFP you still get the 'best-guess' functionality which is often useful.
>

>
>Agreed! Since MS didn't have MSXML 4.0 parser at the time these functions were written, I think there was some, let's call it "VFP specific" way to validate the XML.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform