0

After a lot of searching for how to properly refer to one item from another, I found this minimal example that showcases how to refer to an Organization item as a branchOf from a Hotel item. It defines the attribute itemprop="branchOf" on the Organization, which becomes a property of the Hotel item after it references it.

<div itemprop="branchOf" itemscope itemtype="http://schema.org/Organization" id="schema-organization">
 <h1 itemprop="name">The Hotel Chain</h1>
</div>

<div itemscope itemtype="http://schema.org/Hotel" itemref="schema-organization">
 <h2 itemprop="name">Hotel Location 1</h2>
</div>

That example validates.

But now I need to add a Person that works for that Organization. I could use the same concept by defining itemprop="worksFor" on the Organization, and then referencing that from my Person, like so:

<div itemprop="worksFor" itemscope itemtype="http://schema.org/Organization" id="schema-organization">
 <h1 itemprop="name">The Hotel Chain</h1>
</div>
<div itemscope itemtype="http://schema.org/Hotel" itemref="schema-organization">
 <h2 itemprop="name">Hotel Location 1</h2>
</div>
<div itemscope itemtype="http://schema.org/Person" itemref="schema-organization">
    <div itemprop="name">John Doe</div>
</div>

And the Person correctly gets its worksFor attribute to show the Organization here.

But now I have to remove the itemref from the Hotel, otherwise it complains that it doesn't recognize a worksFor attribute. And if I do so, the Hotel is no longer referencing the Organization in any way, therefore it is not a branch of it.

So it seems that it's a either-or situation.

How I can I declare both? The Person needs to work for the Organization, and Hotel needs to be a branch of the Organization.

Digital Ninja
  • 3,415
  • 5
  • 26
  • 51
  • Advice: it's easier to 'describe' information using [turtle](https://en.wikipedia.org/wiki/Turtle_(syntax)) [example](https://www.loc.gov/aba/pcc/bibco/documents/TurtleExamples.pdf) (note: don't use CURIEs; just model ?s ?p ?o statements). Once you have an information model, you can match it to the HTML. If you start with HTML, and the related microdata for each HTML element, you will have extreme difficulty in composing valid statements (valid as determined by the Google SDTT). HTML is a layout language; turtle is a thinking language. – Jay Gray May 26 '20 at 10:23

1 Answers1

1

You could use itemid and reference the same itemid from each entity. e.g.

<div itemscope itemtype="http://schema.org/Organization" itemid="#organization">
 <h1 itemprop="name">The Hotel Chain</h1>
</div>
<div itemscope itemtype="http://schema.org/Hotel" >
 <h2 itemprop="name">Hotel Location 1</h2>
 <meta itemprop="branchOf" itemscope itemid="#organization"/>
</div>
<div itemscope itemtype="http://schema.org/Person">
    <div itemprop="name">John Doe</div>
    <meta itemprop="worksFor" itemscope itemid="#organization"/>
</div>
Tony McCreath
  • 2,882
  • 1
  • 14
  • 21