Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WwXML and XPath
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
West Wind Web Connection
Titre:
WwXML and XPath
Divers
Thread ID:
00672268
Message ID:
00672268
Vues:
40
Hi,

I think I found an interesting behaviour in the wwXML implementation concerning the use of XPath expressions. Please, consider the following code:
SET CLASSLIB TO wwXML ADDITIVE

LOCAL loXML AS "wwXML"
loXML = CREATEOBJECT("wwXML")

*-- Create the Customer cursor
CREATE CURSOR Customers (ID Integer, Name Char(30))
INSERT INTO Customers VALUES (1, "Customer A")
INSERT INTO Customers VALUES (2, "Customer B")
INSERT INTO Customers VALUES (3, "Customer C")

*-- I wnat to generate an XDR Schema into my resulting XML
loXML.ncreatedatastructure = 1

*-- Here is my XML...
LOCAL lcXML
lcXML = loXML.CursorToXML()    

*-- Load the XML into a DOMDocument object (MSXML 3.0)
LOCAL loDOM as "MSXML2.DOMDocument.3.0"
loDOM = CREATEOBJECT("MSXML2.DOMDocument.3.0")
loDOM.setProperty("SelectionNamespaces", ;
                  "xmlns:ms='x-schema:#Schema'")
loDOM.loadXML(lcXML)

*-- I want the node <name> from my customer which has ID=2 (this is Customer B)
LOCAL loNodo as "MSXML2.IXMLDOMNode"
loNodo = loDOM.selectSingleNode("/xdoc/ms:customers/ms:row/ms:name[../ms:id = '1']")

IF VARTYPE(loNodo) = "O"
  loNodo.nodeTypedValue = "Customer changed"
ENDIF

loXML.XMLToCursor(loDOM, "NewCustomers")

BROWSE
All works fine! When the BROWSE command is executed I see the name of my custumer 2 altered.

Now, if I want to instruct the parser to use XPath as the default query language by issuing the following line right after the instantiation of the DOMDocument object:
loDOM.setProperty("SelectionLanguage","XPath")
My query (selectSingleNode()) still works, as my expression is compatible with both XSL Patterns and XPath. but the XMLToCursor() method fails. It creates three records in "NewCustomers" cursor, but all the values are empty.

I may be completely wrong, but it seems to me that XMLToCursor() uses XSL Patterns expressions to create the cursor from the input XML, so it fails when XPath is selected as the defult language.

Does anyone have some comments on this? If I would like to use XPath expressions over my DOM wouldn't it be possible?

I can imagine a workaround where other DOMDocument object can be created from the first one just to be passed to the XMLToCursor() method, but I would like to confirm my impressions.

Thank you!
-----
Fabio Vazquez
http://www.fabiovazquez.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform