XAML, SOAP 1.2 Part II Section 3, and RDF

Don Box's Spoutlet

Syndication

Recently, the three of these technologies came into my head all at once, and for a moment they looked strikingly similar.
 
Here's why.
 
Each is an application of XML.
 
Each constrains the use of XML constructs by imposing an underlying (or overarching) data model on how elements and attributes relate.
 
Though the syntax for the three differs wildly, the underlying data model each of them is more alike than it is different.
 
All three support the notion of named properties. 
 
In XAML, it's every attribute and every element whose name begins with the parent element's name + "." (e.g., <Button.Font/>).
In SOAP/1.2, it's every child element of an element marked s:nodeType="struct."
In RDF, it's whatever representation is used for a predicate (see the examples below).
 
 
All three support the notion of sequences of values.
 
In XAML, it’s every child element whose name doesn't begin with the parent's element name + '.'.
In SOAP/1.2, its every child element of an element marked s:nodeType="array."
In RDF, it’s the collection of child elements of an element marked rdf:parseType="Collection" or an rdf:Seq element.
 
All three support the notion of atomic values.
 
In XAML, it’s the textOnly content of an element or an attribute value.
In SOAP/1.2, it’s the child text of an element marked s:nodeType="simple."
In RDF, it’s the textOnly content of an element or an attribute value. Alternatively, it’s the child element of an element marked rdf:parseType="Literal"
 
 
To grok how these are similar and how they are different, consider the following data structure:
 
public class Person {
    public string Name;
    public double Age;
    public Address[] Addresses;
}
 
public class Address {
    public string Street;
    public string CityStateZip;
}
 
In SOAP/1.2, an instance of Person would be written out like this:
 
<!-- example 1: SOAP/1.2 -->
<Person s:nodeType="struct">
  <Name>Don Box</Name>
  <Age xsi:type="xs:double">29</Age>
  <Addresses s:nodeType="array" s:itemType="Address">
    <what s:nodeType="struct">
      <Street>One Microsoft Way</Street>
      <CityStateZip>Redmond WA 98052</CityStateZip>
    </what>
    <ever s:nodeType="struct">
      <Street>123 Main Street</Street>
      <CityStateZip>Seattle WA 98091</CityStateZip>
    </ever>   
  </Addresses>
</Person>
 
Note that for sequences (arrays in SOAP-speak), the name of the child elements is not significant. Also note that for simple values, I omitted the s:nodeType="simple" attribute, as it's unambiguous in all of these cases. I also omitted the xsi:type attribute where its value would be xs:string.
 
In XAML, the same data would look like this:
 
<!-- example 2a: XAML enf -->
<Person>
  <Person.Name>Don Box</Person.Name>
  <Person.Age>29</Person.Age>
  <Person.Addresses>
    <Address>
      <Address.Street>One Microsoft Way</Address.Street>
      <Address.CityStateZip>Redmond WA 98052</Address.CityStateZip>
    </Address>
    <Address>
      <Address.Street>123 Main Street</Address.Street>
      <Address.CityStateZip>Seattle WA 98091</Address.CityStateZip>
    </Address>   
  </Person.Addresses>
</Person>
 
or equivalently, like this:
 
<!-- example 2b: XAML anf -->
<Person Name="Don Box" Age="29">
  <Addresses>
    <Address Street="One Microsoft Way"  CityStateZip="Redmond WA 98052"/>
    <Address Street="123 Main Street" CityStateZip="Seattle WA 98091" />   
  </Addresses>
</Person>
 
Note that the distinction between "record/struct" and "sequence/array" as well as the specific primitive type is implicit and can only be inferred with out-of-band metadata (probably a CLR assembly but one could get much more elaborate).
 
Here's the same data worked up in RDF several times:
 
<!-- example 3a: RDF anf-->
<Person Name="Don Box" Age="29" rdf:about="id1">
  <Addresses rdf:parseType="Collection">
    <Address rdf:parseType="Resource" Street="One Microsoft Way"  CityStateZip="Redmond WA 98052"/>
    <Address rdf:parseType="Resource" Street="123 Main Street" CityStateZip="Seattle WA 98091" />
  </Addresses>
</Person>
 
<!-- example 3b: RDF enf-->
<Person rdf:about="#id1">
  <Name>Don Box</Name>
  <Age rdf:datatype="http://www.w3.org/2001/XMLSchema#double">29</Age>
  <Addresses rdf:parseType="Collection">
    <Address rdf:parseType="Resource">
      <Street>One Microsoft Way</Street>
      <CityStateZip>Redmond WA 98052</CityStateZip>
    </Address>
    <Address rdf:parseType="Resource">
      <Street>123 Main Street</Street>
      <CityStateZip>Seattle WA 98091</CityStateZip>
    </Address>
  </Addresses>
</Person>
 
<!-- example 3c: RDF sans typed node -->
<rdf:Description rdf:about="#id1">
  <rdf:type rdf:resource="uri-prefix/Person</rdf:type>
  <Name>Don Box</Name>
  <Age rdf:datatype="http://www.w3.org/2001/XMLSchema#double">29</Age>
  <Addresses rdf:parseType="Collection">
    <rdf:Description rdf:parseType="Resource">
      <rdf:type rdf:resource="uri-prefix/Address</rdf:type>
      <Street>One Microsoft Way</Street>
      <CityStateZip>Redmond WA 98052</CityStateZip>
    </rdf:Description>
    <rdf:Description rdf:parseType="Resource">
      <rdf:type rdf:resource="uri-prefix/Address</rdf:type>
      <Street>123 Main Street</Street>
      <CityStateZip>Seattle WA 98091</CityStateZip>
    </rdf:Description>
  </Addresses>
</Person>
 
<!-- example 3d: RDF reified -->
<rdf:RDF>
  <rdf:Description rdf:about="#s1">
    <rdf:type rdf:resource="rdf-uri#Statement" />
    <rdf:subject rdf:resource="#id1" />
    <rdf:predicate rdf:resource="rdf-uri#type" />
    <rdf:object rdf:resource="uri-prefix/Person" />
  </rdf:Description>
 
  <rdf:Description rdf:about="#s2">
    <rdf:type rdf:resource="rdf-uri#Statement" />
    <rdf:subject rdf:resource="#id1" />
    <rdf:predicate rdf:resource="uri-prefix/Name" />
    <rdf:object>Don Box</rdf:object>
  </rdf:Description>
 
  <rdf:Description rdf:about="#s3">
    <rdf:type rdf:resource="rdf-uri#Statement" />
    <rdf:subject rdf:resource="#id1" />
    <rdf:predicate rdf:resource="uri-prefix/Age" />
    <rdf:object rdf:datatype="http://www.w3.org/2001/XMLSchema#double">29</rdf:object>
  </rdf:Description>
 
   // remaining XML elided to reduce bandwidth costs
 
 
 
So, what are the tradeoffs?
 
SOAP/1.2 and RDF both support inline annotations to give hints about record vs. sequence and primitive type assignment. This makes life easier for processors that have to deal with data without having access to metadata (like SOAP intermediaries or generic data manipulation/query/transformation plumbing).
 
Between SOAP/1.2 and RDF, SOAP is considerably simpler as (a) there's only one way to represent a concept, not N ways and (b) that representation is just element-normal-form + a small number of annotations (s:nodeType, s:itemType).  The use of ENF does make SOAP/1.2 encoding slightly less authorable than RDF's attribute-normal-form, but for someone writing importers, having to cope with N formats obviously make parsers bigger and more complicated.
 
Also, RDF expects you to buy into a URI-based resource model and only added the notion of "blank nodes" recently.  For data transfer applications (which are exceedingly common), there often isn't a persistent URI or ID for the data being represented. Query results that use projection are a great example where having to cons up URI is overkill.
 
On the upside, RDF is unique amongst the three in its ability to have properties on properties on properties on…. Being able to treat an RDF statement as a resource that itself can have properties (in addition to the object or "value" of the property) is certainly powerful and appeals to the inner modeling geek.
 
As for XAML, it's reliance on out-of-band metadata to do the type assignment makes it somewhat different. If the XAML folks decide that that scenario is important (to date ChrisAn has been pretty explicit that it's a non-goal), my guess is it would look similar to SOAP/1.2 encoding with support for ANF where desired (and unambiguous).
 
At this point, I should point to Tim Bray's rants on the subject.
 
 
Here's his RDF.net challenge which contains one explanation of why RDF didn't take off.
 
Finally, here's Tim Appnell's summary of various responses to Tim.

Posted Feb 02 2005, 03:29 PM by don-box

Comments

David Ryan wrote re: XAML, SOAP 1.2 Part II Section 3, and RDF
on 02-03-2005 4:32 AM
It's late, I'm tired.. yet I'm still curious. I can see that these things are similar. They all seem to scare me for different reasons. I'm curious about two things. a) Is there any reason for comparing these methods? b) Is there any reason why you didn't include the XML Schema version?

I'm guessing the answer to my second question is related to your point regarding processing without access to meta data?
Nils Jonsson wrote Don Box impersonates Bill Clinton
on 02-03-2005 7:26 AM
Don, the value of the ‘Age’ element/attribute makes me think you are repeating an assertion often enough that even you will be inclined to believe it!
Don Box wrote re: XAML, SOAP 1.2 Part II Section 3, and RDF
on 02-03-2005 9:05 PM
David,

The reason XSD isn't on this list is that I'm looking at ways to represent INSTANCES, not descriptions/metadata/schema for instances.

There's a meaningful comparison between XSD and RDF VDL. The real comparison for RDF is to XML.
Don Box's Spoutlet wrote XAML, SOAP 1.2 Part II Section 3, and RDF
on 02-04-2005 12:02 AM
Julien Boyreau wrote re: XAML, SOAP 1.2 Part II Section 3, and RDF
on 02-04-2005 4:51 AM
Hi Don, my comment disappeared from this entry BUT I really liked you leverage your Buzz Effect Semantic Agents : if Indigo is just a mean to lock-in users in a very software-as-a-service dependance model such as the one of the TelcoStructure THAT could be a DEAD-END.
If Indigo is just a WS-Wrapper that will feed the confusion meme of "Service=component" that would be desastrous.
Microsoft has fueled the PC Revolution where USERS could be HACKERS (in the sense of Stallman) and had the power to break the innovation bareer of the Mainframe era : the SKYPE of the Internet Revolution has leveraged this effect one more time by giving USERS the CONTROL of their Proto-PBX.
On the other side, SUN SEEMS NOT TO UNDERSTAND THAT and promote this "F***ing" Sun Ray Thin Client logic that reGive the control to Sysadmin.
All the debate about Web Browser, Thin client...is wrong because if you give just HTML to the user you lock-off the hacking chain cause HTML is TV-Content for passive customer AND JavaScript or ActiveX are SO trojan friendly...

I think MS is at crossroads between the old C/C++ Win32 Guys, the Web-oriented-as-a-dumb-TV MSN guys and the .NET++/Service=contract/powerful-PERSONAL COMPUTER people. Where are thou ?
Please climb the imam Minaret and spread Agents, Semantic Web, Service=Contract, DAM...

The Battle Royale is near...choose your SIDE !!
shooby wrote XML and Microsoft (In general)
on 02-04-2005 8:31 AM
Don,

I know your almost as 'into' XML as I am, so I'm sure you are aware of the following.

I read recently that some Microsoft gumba stated at a recent Microsoft Office shindig (Mary Foley reported) that, to paraphrase...

"XML is the future, and Microsoft Office facilitates XML"

So, being a good little MrSofty fan, I made a little doc-y with word-y, something like...
---

This is a test document.
---

...and saved it as XML, which when saved was 6.3 K bytes -- not bad overhead (by MrSofty 'standards' (note, I have to use those ''s because nothing MrSofty does is really a standard, its just used as a word'))

Then I openned it with a little app I collected, XMLPad, a MrSofty tool, which has disappeared from the corp web by the way, useful, free, small -- totally un-MrSofty in most ways as you can see.

And after sorting through all the overhead managed to find the text above, and changed the element to "I just changed a few chars" and tried to save it, which failed with a COM error.

Ok, so I figure, this is just MrSofty telling me I should spend money for things that work, and tried editing with a text editor, TextPad - great tool BTW, on the web, send him a few bucks -- and did the same thing and saved the file.

Then, just to see how truthful the statement above (near "XML is the future") I tried to open it in Word -- error, blah blah, blah must begin in line 2 -- or some such.

Ok, so how about Internet Exploder (thats our pet name here for IE) -- error "Internet Explored has stopped responding"

...Gee, the future IS XML.

...but it sure aint Microsoft.

So, Don, as we both love the XML, when are you leaving?

...have you no integrity?

Your best buddy
Jeff wrote re: XAML, SOAP 1.2 Part II Section 3, and RDF
on 02-04-2005 9:45 AM
I don't want to start an argument on Don's blog but I tested your experiment, Shooby, and had no problems. The .xml file as created by MS Word 2003 is 3231 bytes on disk for the short sentence "This is a test document."

I looked at it in an XML editor and easily found and changed the text. I loaded it back in Word and all was well.

First, if XMLPad generated a COM error, maybe that is why it's not available on MS' site anymore. I don't have personal knowledge of this tool but I suspect it was never a supported product by MS.

Second, you can't complain about overhead in the XML file. For a short document overhead will be massive: for that document the overhead is 99.25% of the file (3207 bytes for XML + formatting information + etc. vs 24 bytes for the actual text)

I then took a 124 pg document and copied it into Word with same formatting as the initial test sentence. Saved as .txt this file is 265956 bytes. The XML version, as saved by Word, is 326900 bytes. This is 18.64% overhead.

I'm not sure at what point you think overhead is too much - but just casually looking at the information stored in the XML file it all seems necessary. Word uses that information to render the document.

It seems like you're making up reasons to knock the technology without looking deeper into it.
shooby wrote re: XAML, SOAP 1.2 Part II Section 3, and RDF
on 02-04-2005 11:26 AM
Points

1) XMLPad edits everything else just fine

2) I was just being cute, as I said for a Mr Softy App, thats peanuts, but, ok at least they used a schema.

Now go ahead and edit the file with something normal and see if everything with a Bill Gates tattoo doesnt throw up on your desktop.

...I have no problem with the technology, I have a problem with breaking the technology to make sure you sell product.
Kannan Goundan wrote XML is broken!
on 02-07-2005 2:07 PM
I think the reason there are varying models is that XML is not a good way to represent data. It is just not simple enough. It has extra crap (attributes) that nobody really needs.

Most programming languages' data structures are basically the same. There are records/structs and sequences/arrays. This model works. The fact that XML doesn't map well to this model (because of the extra frills) explains why XML is such a pain to program with. It's like making suspension cables out of fully constructed bridges.

BTW, why does example 2b use "Addresses" instead of "Person.Addresses"?
Jeremy Gray wrote re: XAML, SOAP 1.2 Part II Section 3, and RDF
on 02-07-2005 5:23 PM
Don: a minor-sounding but important clarification for you:

you are quite correct about how RDF's many ways to express the same thing complicates things. The unfortunate part is that RDF/XML was given those many ways to express things so that mappings to and from existing XML schemas could be more literal. Sadly, this intention backfired by making it harder to grok, not easier. Anyway, back to my point:

RDF has had blank nodes for as long as it has existed as a specification, though they were called "anonymous resources" back in the days of RDF Model & Syntax 1.0 (before the set and graph people started mucking with the spec and renaming everything :( ).
Dan Brickley wrote re: XAML, SOAP 1.2 Part II Section 3, and RDF
on 02-12-2005 2:01 AM
Hi. Re blank nodes, yes the construct was in the spec from day 1. The original, informal terminology "anonymous resources" was confusing in an important way. It gave people the impression that the anonymity or namelessness was a property of the thing the node stood for, rather than of the chunk of RDF/XML the node appeared in. Since we can have bNodes which represent entities that do have URIs (but those URIs happen not to be mentioned in some piece of RDF), the renaming was an improvement. It was only a prose change anyway, didn't affect anything at the code level.

Re SOAP Encoding and RDF data models, there is a strong similarity there, despite the different deployment models associated with each.

http://www.w3.org/2001/sw/Europe/reports/xml_graph_serialization_report/
...is an exploration of the relationship between the two, including experimental XSLT that generates RDF from SOAP Encoding graphs. That report is a bit scrappy, since SOAP Encoding seemed to fall from favour in the SOAP/WS scene as we were working on it, which took away the sense of urgency behind it...
Jeremy Gray wrote re: XAML, SOAP 1.2 Part II Section 3, and RDF
on 02-16-2005 3:20 PM
Dan, we need to be clear on this in order to avoid further confusing those who are not as familiar with RDF as some of us pundits are.

RDF itself does not allow for bNodes to represent entities that do have URIs. Only once into OWL territory does this start to change, and even then those bNodes STILL do not represent entities that do have URIs. "Equivalence" via functional properties does not result in self-sameness, only in "cloning" of relations at an interpretive level.

As pure RDF goes, bNodes / anonymous resources truly are just that: anonymous resources.
Anatoly Lubarsky: Weblog wrote Links: Webservices Articles
on 03-05-2005 10:23 AM

Add a Comment

(required)  
(optional)
(required)  
Remember Me?