Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Using XPath on xsd

Using XPath on xsd

Scheduled Pinned Locked Moved XML / XSL
xmldatabasetutorialquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jholt
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • J jholt

      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

      D Offline
      D Offline
      Diederik de Haas
      wrote on last edited by
      #2

      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.

      J 1 Reply Last reply
      0
      • D Diederik de Haas

        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.

        J Offline
        J Offline
        jholt
        wrote on last edited by
        #3

        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 - - - - - - - - -

        D 1 Reply Last reply
        0
        • J jholt

          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 - - - - - - - - -

          D Offline
          D Offline
          Diederik de Haas
          wrote on last edited by
          #4

          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.

          J 1 Reply Last reply
          0
          • D Diederik de Haas

            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.

            J Offline
            J Offline
            jholt
            wrote on last edited by
            #5

            OK - thanks very much for your help Jeremy

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups