4

I've noticed that in the models of my DXA application I always need to fill the Vocab property of the SemanticEntity decorator with the uid of the schema. For example:

enter image description here

enter image description here

The thing is that in other DXA sites I've seen the Vocab value is always "http://schema.org/", but if I use it in my models it doesn't work. Does anyone know why is that and how could I change it to work that way?

Thanks a lot for your help!

Mer

3

If you have to use the namespace URIs of your CM Schemas in your SemanticEntity annotations, you are apparently using the retrofit mode. See https://docs.sdl.com/LiveContent/content/en-US/SDL%20DXA-v10/GUID-C0AD6DCC-ED65-441F-B361-928A18B2896D

In regular mapping mode, mapping tp CM Schema can be done largely implicity (i.e. without annotations), but in retrofit mode you indeed have to explicitly map all you View Model Types to CM Schema namespace URIs.

In regular mode, the assumption is that the root element names of all your CM Schemas are distinct. This may not be the case if you’re retrofitting DXA on an existing content model (worst case, the root element name of all your CM Schemas is Content). The retrofit mode was introduced to facilitate use of DXA on such existing content models.

Note: for such “internal” SemanticEnity annotations, which are only intended for mapping to CM Schemas, you should not set Public=true, because that causes the semantic type to be output in RDFa artributes in the HTML. It only makes sense to do that for public vocabularies (such as schema.org)

1
  • That's it! I changed that value some time ago testing and I forgot to redo it. Thank you so much, @Rick Pannekoek !
    – Mer
    Aug 30 '18 at 5:42
0

you annotate with the prefix "s", so I'm assuming there is a SemanticEntity annotated on the class with a vocabulary defined, most likely that is "http://schema.org"

Remove prefix from SemanticProperty attribute.

[SemanticEntity(Vocab = "http://schema.org/", EntityName = "Promos", Prefix = "s", Public = true)]

public class Promos : EntityModel
{
     [SemanticProperty("promos")]
        public List<Promo> PromoList{ get; set; }
}

It means that SemanticProperty attribute for explicit mapping does not work with prefixes - that can provide structured content markup.

No need to pass the uid of the schema. What version of DXA are you using?

2
  • hey sorry i have misunderstood your question can you check the "ViewModel.cs" file which is present in "Sdl.Web.Common\Models" it contains the Vocabulary ID used for semantic/CM mapping. It will have 2 vocabulary id one is built-in which is used by the Core and other vocabulary id for types defined by schema.org.
    – k951
    Aug 29 '18 at 7:44
  • We are using Tridion 8.5 y DXA 1.7. The ViewModel.cs is in the Sdl dll, we cannot modify that, it has the default values it comes with. We are getting the model using EntityModel content = ContentProvider.GetEntityModel(ConfigurationManager.AppSettings.Get("componentTemplateCities"), Sdl.Web.Mvc.Configuration.WebRequestContext.Localization); and it works, but we always need to put the uuis in the Vocab (we have already tried changing it and removing the prefix, but it doesn't parse to the model).
    – Mer
    Aug 29 '18 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.