Question

Adding RDFa is quite fun, but tends to make my source almost impossible to read, (even when the editor has decent syntax highlighting.) For instance:

<div id="me" prefix="foaf: http://xmlns.com/foaf/0.1/ schema:
http://schema.org/Person" typeof="foaf:Person schema:Person"
resource="http://carlboettiger.info#me"> <p> <img property="foaf:depiction"
src="assets/img/carlboettiger.png" alt="Photo of Carl Boettiger"
style="float: right; margin: 10px 10px"/>
I am  <a property="foaf:homepage schema:url"
href="http://carlboettiger.info"><span property="foaf:name
schema:name"><span property="foaf:givenName schema:givenName">Carl</span>
<span property="foaf:familyName schema:familyName">Boettiger</span></span></a>, <span
property="schema:jobTitle">a graduate student</span> with <span property="foaf:knows"><span
typeof="foaf:Person"><span property="foaf:name"><a property="foaf:homepage"
href="http://two.ucdavis.edu/%7Eme">Alan Hastings</a>
</span></span></span> in the <a property="foaf:workplaceHomepage"
href="http://www-eve.ucdavis.edu/eve/pbg/">Population Biology</a>
Ph.D program at<span property="schema:affiliation">UC Davis</span>,
working on <span property="foaf:interest">regime shifts</span>
in <span property="foaf:interest">ecology</span> and <span
property="foaf:interest">evolution</span>. Such shifts mark the most
dramatic events in <span property="foaf:interest">complex systems</span>

I mislike dense markup in general, for which reason I frequently prefer to write in markdown, but this seems impossible in the context of adding RDFa markup, such as this example.

It seems like one might exploit whitespace to make this a bit more human readable. Are there any existing tools or conventions for this? (the example below just comes from !fmt wordwrapping in vim, which usually looks decent but seems at a loss in this case).

Was it helpful?

Solution

  • you should prefer using wide spread ontologies instead of duplicating classes or predicates that already have equivalents (or just produce owl:equivalentClass or owl:sameAs relations)
  • there are many shortcuts in RDFa 1.1 you have not used, for example vocab or rel properties
  • you can use indents to beatify markup

According to that, your page can look like:

<body prefix="schema: http://schema.org/"
      vocab="http://xmlns.com/foaf/0.1/">
    <p typeof="Person" resource="http://carlboettiger.info#me">
    <img property="depiction" style="float: right; margin: 10px 10px"
         src="assets/img/carlboettiger.png" alt="Photo of Carl Boettiger" />
    I am <a property="homepage schema:url" href="http://carlboettiger.info">
        <span property="name"><span property="givenName">Carl</span> <span property="familyName">Boettiger</span></span>
    </a>, a <span property="schema:jobTitle">graduate student</span> with
    <span rel="knows" typeof="Person">
        <span property="name"><a property="homepage" href="http://two.ucdavis.edu/%7Eme">Alan Hastings</a></span>
    </span> in the <a property="workplaceHomepage" href="http://www-eve.ucdavis.edu/eve/pbg/">Population Biology</a>
    Ph.D program at <span property="schema:affiliation">UC Davis</span>, working on
    <span rel="interest">
        <a href="http://en.wikipedia.org/wiki/Regime_shifts">regime shifts</a> in
        <a href="http://en.wikipedia.org/wiki/Ecology">ecology</a> and
        <a href="http://en.wikipedia.org/wiki/Evolution">evolution</a>.
        Such shifts mark the most dramatic events in <span>complex systems</span>
    </span>
    </p>
</body>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top