none
How do I format Dataset XML for Javascript (XPath) use? RRS feed

  • Question

  • Background...

     

    I'm writing the WebForm UI for an n-tier app that currently only has a WinForm UI. The WinForm UI implements the MVC design pattern. In other words, the navigation components (controller) instantiate the UI component (view) and the business entity (model), couples them then stands back. The UI component binds to the business entity which contains all the business rules, lists, etc. necessary to model the real world business entity. The business entities all store their instance data in datasets (untyped). The business entities are transferred between the n-tier layers by serializing the datasets and re-hydrating the business entities. For example, the serialized dataset arrives in the presentation layer. It is converted to a datasets. A new (blank) business entity is instantiated and then instance data dataset.

     

    I'd like the WebForm UI to follow the same programming model the WebForm UI uses. In other words, deliver the same objects to the client and let the client take over. I'm using AJAX components to imlement the UI component and the business entity. That all works well.

     

    The Problem

    How do I format the dataset XML so it can be manipulated  with XPath on the client and converted back to a dataset that looks like the original with edits applied on the server?

     

    Issues...

    1. Nulls values are not represented in the XML
    2. The original and current values must be maintained on the client to deserialize the dataset when it arrives back at the server.
    3. The XML structure should (I'm willing to compromize on this) model the actual data closely (not diff gram format).

    What I've Tried...

     

    Formatting the the dataset XML with the XmlDataDocument.Normalize method makes the XML easy to manipulate with XPath. Unfortunately, null values are not represented in the XML. I'm looking for ways to convert the dataset XSD to XSL I can transform to force nulls to show up in the XML. That seems hopeful but I haven't found a solution yet. Is there anything the System.XML.Schema or System.XML.XSL namespace that can do this?

     

    Sending two copies, original and current, of the dataset XML to the client allows me to manually de-serialize with changes intact on the client but seems kludgey.

    Monday, October 1, 2007 4:03 PM

All replies

  • The question is related to System.Data and DataSet specifically rather then to System.Xml.

    You can use XPath to process any can XML.

     

    Thursday, October 4, 2007 8:52 AM
  •  

    Sergey

     

    Thanks for replying.

     

    I'm asking for general advice on moving the XML representation of a dataset from IIS to IE, manipulating it with Javascript (XPath, etc.), then moving it back to IIS and converting back to a dataset for persistence. The three specific problems I'm trying to resolve are listed in my orignal post.

     

    I've posted the forth problem I listed in my original post, paraphrased as...

     

    "How do I convert the XSD for an untyped dataset to XSL that I can use as the basis of a transform (XSLT)?"

     

    As a new post in the XML forum.

     

    Thank you for pointing out that XPath can manipulate any XML. However, I don't see how that addresses my request for general advice or any of the four specific problems I listed.

     

    Am I missing something in your reply?

    Thursday, October 4, 2007 1:05 PM