Using XPath on xsd
-
Hi I've just started using DataDynamics ActiveReports for NET which I find very good. However, I'm a bit lost on accessing datasets using XPATH. Note that I do not want to make my dataset relations nested, and quite often a dataset will contain more than one non-related data table. Say I have a dataset (dsContracts) with tables/fields as follows Table - Contracts Fields - ContractID, Seller, Buyer, Commodity Table - Details Fields - ContractID, DetailsID, Grade, Price Table - Invoices Fields - ContractID, Invoice, Nett and that all three tables are related by field ContractID. I create an xml file by ds.WriteXml("c:\Contracts.xml",WriteSchema) I would have thought that if I wanted to access dsContracts.Details.Grade the xpath query would be Details/Grade but this is not working. Could someone give me a clue as to how to access the fields in dataset?? Many thanks in advance Jeremy Holt
-
Hi I've just started using DataDynamics ActiveReports for NET which I find very good. However, I'm a bit lost on accessing datasets using XPATH. Note that I do not want to make my dataset relations nested, and quite often a dataset will contain more than one non-related data table. Say I have a dataset (dsContracts) with tables/fields as follows Table - Contracts Fields - ContractID, Seller, Buyer, Commodity Table - Details Fields - ContractID, DetailsID, Grade, Price Table - Invoices Fields - ContractID, Invoice, Nett and that all three tables are related by field ContractID. I create an xml file by ds.WriteXml("c:\Contracts.xml",WriteSchema) I would have thought that if I wanted to access dsContracts.Details.Grade the xpath query would be Details/Grade but this is not working. Could someone give me a clue as to how to access the fields in dataset?? Many thanks in advance Jeremy Holt
First of all: you don't use XPath on an XML-Schema, but on the XML file (which can be validated against the Schema). Now the answer ;) If the nodeName of your documentElement is Details then it should work. If it's not there are (at least) 2 ways to make it work. 1. Provide the full path: "documentElementNodeName/.../Details/Grade". Replace "documentElementNodeName" with the actual name of your documentElement and "..." with all elements (if any) till the Details element. 2. Use "//Details/Grade". This finds any Grade element which has a Details parentNode.
-
First of all: you don't use XPath on an XML-Schema, but on the XML file (which can be validated against the Schema). Now the answer ;) If the nodeName of your documentElement is Details then it should work. If it's not there are (at least) 2 ways to make it work. 1. Provide the full path: "documentElementNodeName/.../Details/Grade". Replace "documentElementNodeName" with the actual name of your documentElement and "..." with all elements (if any) till the Details element. 2. Use "//Details/Grade". This finds any Grade element which has a Details parentNode.
Many thanks your reply - but I still can't get my head around it. I was using the XPath on the XML file. I wrote a small form to test the expressions using an example in the Help files. The xsd looks like this (obviously I'm actually accessing the data in the xml). Using the form below: / returns everything as one long string /* returns only table Images //* returns everything split into lines //Journal returns nothing //Journal/Amount returns nothing Maybe the code for ProcessFile is wrong ? Many thanks for your help Jeremy - - - - - - - - -
-
Many thanks your reply - but I still can't get my head around it. I was using the XPath on the XML file. I wrote a small form to test the expressions using an example in the Help files. The xsd looks like this (obviously I'm actually accessing the data in the xml). Using the form below: / returns everything as one long string /* returns only table Images //* returns everything split into lines //Journal returns nothing //Journal/Amount returns nothing Maybe the code for ProcessFile is wrong ? Many thanks for your help Jeremy - - - - - - - - -
I've tested your XML in XMLSPY (and MSXML4) and tried the XPath and it returns the correct node. So I guess it's the ProcessFile function. Can't help you with that because I don't have VS.NET.
-
I've tested your XML in XMLSPY (and MSXML4) and tried the XPath and it returns the correct node. So I guess it's the ProcessFile function. Can't help you with that because I don't have VS.NET.