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

  • Mastering AI Development and Building AI Apps with GitHub Copilot

    Two Microsoft experts explain how GitHub Copilot is evolving from a coding assistant into a broader platform for building, customizing and testing AI-powered developer workflows.

  • VS Code 1.123 Adds Agent Session Sync, 1M Context Windows

    Microsoft released Visual Studio Code 1.123 on June 3, adding agent-focused features, larger model context support, integrated browser updates and a new delay for some automatic extension updates.

  • Copilot Billing Shock Hits Developers

    Developer complaints about GitHub Copilot's new usage-based billing model have centered on unexpectedly rapid AI credit consumption, and neither GitHub nor Microsoft has responded directly to the backlash, though they have previously published guidance to lessen model usage costs.

  • Hands On with GitHub Copilot App Technical Preview: Turning a Blazor Issue into a PR

    GitHub's brand-new Copilot desktop app, in technical preview, handled a small Blazor issue from planning through pull request creation, but the hands-on test also showed why developers still need to verify agent work in the running app before merging.

Subscribe on YouTube