C: XML, Atom 1.0: Return Hierarchical Parent Resources: Listing 1

The Atom 1.0 specification allows you to nest a <feed> group within <entry> groups to create a hierarchical structure that accommodates one-to-many associations. This Atom document's parent <feed> group for the Orders EntitySet contains an <entry> for each Order entity, which in turn contains an Order_Details <feed> group with <entry> groups for each Order_Detail entity. Atom <link> elements with an "edit" rel value specify an editable entity instance, and "related" indicates an associated entity or collection. A type attribute value of "entry" indicates a many-to-one or one-to-one EntityReference, and "feed" indicates a one-to-many EntitySet association.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base=
"http://localhost:52660/Northwind.svc/" 
xmlns:ads="http://schemas.microsoft.com/ado/2007/08/
   dataweb" 
xmlns:adsm="http://schemas.microsoft.com/ado/2007/08/dataweb/
metadata" xmlns="http://www.w3.org/2005/Atom">
   <id>http://localhost:52660/Northwind.svc/Orders</id>
   <updated />
   <title>Orders</title>
   <link rel="self" href="Orders" title="Orders" />
   <entry adsm:type="NorthwindModel.Order">
      <id>http://localhost:52660/Northwind.svc/Orders(
      10248)</id>
      <updated />
      <title />
      <author>
         <name />
      </author>
      <link rel="edit" href="Orders(10248)" title=
      "Order" />
      <content type="application/xml">
         <ads:OrderID adsm:type="Int32">10248
         </ads:OrderID>
         <ads:OrderDate adsm:type="DateTime">
             1996-07-04T00:00:00
               </ads:OrderDate>
         <ads:RequiredDate adsm:type="DateTime">
               1996-08-01T00:00:00
               </ads:RequiredDate>
         <ads:ShippedDate adsm:type=
         "Nullable'1[System.DateTime]">
             1996-07-16T00:00:00
               </ads:ShippedDate>
         <ads:Freight adsm:type=
         "Nullable'1[System.Decimal]">
               32.3800
               </ads:Freight>
         <ads:ShipName>Vins et alcools Chevalier
         </ads:ShipName>
         <ads:ShipAddress>59 rue de l'Abbaye
         </ads:ShipAddress>
         <ads:ShipCity>Reims</ads:ShipCity>
         <ads:ShipRegion ads:null="true" />
         <ads:ShipPostalCode>51100</ads:ShipPostalCode>
         <ads:ShipCountry>France</ads:ShipCountry>
      </content>
      <link rel="related" title="Customer" 
         href="Orders(10248)/Customer" 
         type="application/atom+xml;type=entry" />
      <link rel="related" title="Employee" 
         href="Orders(10248)/Employee"    
         type="application/atom+xml;type=entry" />
      <link rel="related" title="Order_Details" 
          href="Orders(10248)/Order_Details"             adsm:inline="true" 
         type="application/atom+xml;type=feed">
         <feed>
            <id>http://localhost:52660/Northwind.svc/
             Orders(10248)/Order_Details</id>
            <updated />
            <title>Order_Details</title>
            <link rel="self" href="Orders(10248)/
            Order_Details" 
               title="Order_Details" />
            <entry adsm:type="NorthwindModel.Order_Detail">
               <id>http://localhost:52660/Northwind.svc/
                  Order_Details(10248,11)</id>
               <updated />
               <title />
               <author>
                  <name />
               </author>
               <link rel="edit" href="Order_Details(10248,11)" 
                  title="Order_Detail" />
               <content type="application/xml">
                  <ads:OrderID adsm:type="Int32">
                  10248</ads:OrderID>
                  <ads:ProductID adsm:type="Int32">
                  11   </ads:ProductID>
                  <ads:UnitPrice adsm:type="Decimal">
                         14.0000</ads:UnitPrice>
                  <ads:Quantity adsm:type="Int16">
                  12   </ads:Quantity>
                  <ads:Discount adsm:type="Single">
                  0</ads:Discount>
               </content>
               
            <link rel="related" title="Order" 
                  href="Order_Details(10248,11)/Order" 
                  type="application/atom+xml;type=entry" />
               <link rel="related" title="Product" 
                  href="Order_Details(10248,11)/Product" 
                  type="application/atom+xml;type=entry" />
            </entry>
            
            <!-- Additional Order_Details in nested <feed>
               groups ... -->
         </feed>
      </link>
      <link rel="related" title="Shipper"             href="Orders(10248)/Shipper" 
          type="application/atom+xml;type=entry" />   
   </entry>
   <!-- Additional Order entities in outer <entry> 
            groups ... -->

</feed>
comments powered by Disqus

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot AI has been a boon for developers, but it might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube