1

I have a table containing some properties of a city. The city is part of a larger area, so I want to add the property containedIn. However, I also want to indicate the type of that area, like "region", "province", or "state", so I am trying to add additionalProperty to these areas. I am very confused about how to do this correctly and efficiently.

This is what I have tried, but Google Structured Data Testing Tool gives two/duplicate items (and two name properties). I want to add both containedIn and additionalProperty to San Juan and San Pablo, but it seems the property name is recognized by both containedIn and additionalProperty, so I do not know how to fix it:

<div itemscope itemtype='http://schema.org/City'>

<h1 itemprop='name'>San Pedro</h1>

<table>
  <tr itemprop='additionalProperty' itemscope itemtype='http://schema.org/PropertyValue'>
    <td itemprop='name'>Type</td>
    <td itemprop='value'>city</td>
  </tr>
  <tr itemprop='additionalProperty containedIn' itemscope itemtype='http://schema.org/PropertyValue http://schema.org/AdministrativeArea'>
    <td itemprop='name'>State</td>
    <td itemprop='value'><a itemprop='url' href='#.html'><span itemprop='name'>San Juan</span></a></td>
  </tr>
  <tr itemprop='additionalProperty containedIn' itemscope itemtype='http://schema.org/PropertyValue http://schema.org/AdministrativeArea'>
    <td itemprop='name'>Region</td>
    <td itemprop='value'><a itemprop='url' href='#.html'><span itemprop='name'>San Pablo</span></a></td>
  </tr>
</table>

</div>
unor
  • 92,415
  • 26
  • 211
  • 360
JAT86
  • 997
  • 12
  • 24

1 Answers1

2

Display in Google’s SDTT

The display in Google’s SDTT appears to be correct for the Microdata you provide:

  • If you use multiple properties to add an item, SDTT displays this item once for every property.

    It’s just the way they decided to display it. They could as well have decided to display something like this instead, but they didn’t:

    additionalProperty, containedIn
    
      @type     PropertyValue
      @type     AdministrativeArea
    
  • If you use multiple properties to add an item, and/or if this item has multiple types, you don’t add multiple/different items, it’s one and the same item.

    It wouldn’t make sense that the name is only for one of the multiple types, or only for the item added by one of the multiple properties. There is only one item, with one set of properties, with multiple types, added by multiple properties.

Meaning

As far as I understand your data, you have a city (San Pedro) which is part of two administrative areas (San Juan, San Pablo).

I’m not sure it makes sense to model it so that the AdministrativeArea is also a PropertyValue. It seems to make more sense to apply the additionalProperty PropertyValue to the AdministrativeArea.

It’s not that easy within a table, so for the sake of this example, I’m using div:

<div itemprop='containedIn' itemscope itemtype='http://schema.org/AdministrativeArea'>
  <a itemprop='url' href='#.html'><span itemprop='name'>San Juan</span></a>
  <div itemprop='additionalProperty' itemscope itemtype='http://schema.org/PropertyValue'>
    <meta itemprop='name' content='State'>
    <meta itemprop='value' content='San Juan'>
  </div>
</div>

Remark: using additionalType instead of additionalProperty for the "type of area"

Using additionalProperty PropertyValue to specify the type of the area is possible, but unusual. Typically actual types are used for such a purpose.

Find a type that represents the concept (e.g. "Region"), or create your own, and add it in addition to the most specific Schema.org type you can find.

In Microdata, the itemtype attribute can only take types from the same vocabulary, so you have to use the additionalType property:

<div itemprop='containedIn' itemscope itemtype='http://schema.org/AdministrativeArea'>
  <a itemprop='url' href='#.html'><span itemprop='name'>San Juan</span></a>
  <link itemprop="additionalType" href="http://example.com/some-vocabulary/Region">
</div>

And for the city: by using Schema.org’s City type, you already convey that it’s a city, so your additionalProperty (with type=city) seems to be superfluous. But if you want to convey some other type, you can use the same method with additionalType here, too.

unor
  • 92,415
  • 26
  • 211
  • 360
  • Thank you for the detailed response. The learning curve is very steep. Since you have mentioned about creating a type, what would the `href` value of the `additionalType` be? I mean, should I just append the custom property (`Region`) to the schema.org url like: `href="http://schema.org/Region`? – JAT86 Apr 01 '18 at 01:01
  • Unfortunately, I have to use a table, so it looks like I would just have to choose between `containedIn` or `additionalProperty` to make things less complicated. – JAT86 Apr 01 '18 at 02:13
  • 1
    @JAT86: No, don’t just invent new Schema.org URIs. Either you look for a suitable [existing vocabulary](https://stackoverflow.com/a/12098901/1591669), or you create your own vocabulary (under a domain you control). If an English Wikipedia article exists for the concept, you could use the Product Types Ontology ([example](https://stackoverflow.com/a/49255326/1591669)). -- Regarding `table`: It should be possible to specify this Microdata in a `table`, but it won’t be beautiful (and with `itemref`, you can even refer to elements outside of the table). Alternatively, you could use JSON-LD. – unor Apr 01 '18 at 21:27