homepage Welcome to WebmasterWorld Guest from 107.20.25.215
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
How to write complex microdata and still have valid HTML
Is it possible to use additionalType from Schema.org and have valid HTML?
PatomaS




msg:4653200
 6:32 am on Mar 12, 2014 (gmt 0)

Hi

As I say in the title, is it possible to have a complex microdata that involves using additionalType and still have valid HTML?

For instance, let say I have this code


<div itemscope itemtype="http://schema.org/WebPageElement http://schema.org/ItemList">
<meta itempro="name" content="navigation_menu" />
<ul>
<li itemprop="additionalType" itemscope itemtype="http://www.schema.org/SiteNavigationElement http://schema.org/itemListElement">
<a href="http://www.example.com/link_1" itemprop="url"><span itemprop="name">Link 1</span></a>
</li>
<li itemprop="additionalType" itemscope itemtype="http://www.schema.org/SiteNavigationElement http://schema.org/itemListElement">
<a href="http://www.example.com/link_2" itemprop="url"><span itemprop="name">Link 2</span></a>
</li>
</ul>
</div>



The code above shows the relation that I'm asking for, in this case a web page element that is also a lit of items, so their descendants are navigationelements and list items.

If you check the code on microdata validators, it shows the right structure, but as you can quickly see, it's not valid HTML due to the spaces on the attributes.

%20 doesn't work, then it is valid HTML, but the tree on the microdata is lost and you only have the list of items.

Any input on this would be very appreciated.

Thanks

P.D.
I'm sorry if this is not the right subforum, I really didn't see a clear cut for my question.

 

graeme_p




msg:4653226
 8:56 am on Mar 12, 2014 (gmt 0)

I think SiteNavigationElement should go on the UL. The spec is a bit vague, but it makes more sense and is more consistent that way.

In most caes marking LIs as itemListElements is unnecessary.

graeme_p




msg:4653265
 11:27 am on Mar 12, 2014 (gmt 0)

Just to add that you can use RDFlite instead of microdata for Schema.org markup and it is a bit less verbose. All the major search engines parse it just the same way.

PatomaS




msg:4653304
 1:59 pm on Mar 12, 2014 (gmt 0)

Hi

Thanks for the reply

In deed, I'm more used to RDF, but my question is not if the example is correct, my question is how do you combine two itemptypes and still have a valid HTML code?

drhowarddrfine




msg:4653318
 2:46 pm on Mar 12, 2014 (gmt 0)

You can't cause the spec doesn't allow it.

PatomaS




msg:4653507
 1:25 am on Mar 13, 2014 (gmt 0)

Hi

Your answer, drhowarddrfine is not very helpful, you don't provide any citation or example, plus if you are talking about the HTML spec, I already mentioned that, on the other hand, if you are talking about the schema.org spec, then you are wrong since it allows more than one type if they are fully qualified.

In the WebSchemas/additionalTypeProposal [w3.org] wiki entry on the W3C, we can see that there was a discussion about how to extend the schema and in the first paragraph of the examples section, you can read that Microdata already allows space-separated values to be a list of types from the same vocabulary. Well, the link is just the recopilation of ideas expressed on the mailing list.

In this entry, WebSchemas/MultipleTypesSDO [w3.org], also on the W3C wiki, we can see that you can use more than one type separated by spaces. In that same entry, it's mentioned what I describe in my original question.

So my question boils down to, has anybody found a way to use more than one fully qualified type on the same itemType that is both, valid HTML and correct microdata?

thanks again for the time to read and think about my question.

Bye

graeme_p




msg:4653567
 7:19 am on Mar 13, 2014 (gmt 0)

You could use a wrapper so you add an extra layer of HTML:

<div itemscope itemtype="http://schema.org/WebPageElement"> <div itemscope "http://schema.org/ItemList">
.....

On the other hand, does it matter it is not valid? I take validation failures as a warning, not something to be avoided at all costs.

In this case browsers will ignore it anayway, so you need to check whether the search engines (or whatever else) you want to parse the schema.org will do so correctly.

Put up a sample page of your actual HTML (I assume the above is just an example of the principle) and use the Google, Bind and Yandex test tools on it.

drhowarddrfine




msg:4653694
 2:47 pm on Mar 13, 2014 (gmt 0)

@PatomaS If you already know the spec says it's invalid, then how can I be wrong? The HTML spec overrides anything else but I don't have time to look further into this.

@graeme_p Ignoring validation is a peril others faced in the past and something I thought current developers learned from. Validation failure is an error and errors should never be tolerated. You are then putting your page in the hands of the browser to determine what to do with your markup.

PatomaS




msg:4653864
 12:30 am on Mar 14, 2014 (gmt 0)

I explained that the information on the W3C is not up to date, or people not related to them at all, have found a way to do something that the spec mentions as invalid or a problem they are trying to solve.

@graeme_p, that's all the code, there is no page associated, is an example I created for a situation that arose from a theoretical question. And yes it validates on the Google Structured Data Testing Tool [google.com].

About validation, I'm not a zealot of it, but if I can get my codes to validate, I try.

In this case, if I can't find a way to get that syntax to work on both situations (validations), I'll go for another option, which is nesting. But I'm sure there are situations where you can't nest more things and adding more and more code just generates a lot of extra load.

Thanks for your answers people

If I find a way, I'll post it here, and I'll keep an eye on this thread in case somebody finds a way.

[edited by: incrediBILL at 5:23 am (utc) on Mar 14, 2014]
[edit reason] thread cleanup [/edit]

drhowarddrfine




msg:4653890
 2:23 am on Mar 14, 2014 (gmt 0)

About validation, I'm not a zealot of it, but if I can get my codes to validate, I try.


I find it interesting that you find the W3C, the people who write the spec, not up to date and try to find your answers elsewhere, from people who do not write the spec. And that includes Schema.org. Schema.org is, essentially, Google, who also help write the W3C spec which you complain is not kept up to date, following circular logic.

[edited by: incrediBILL at 5:21 am (utc) on Mar 14, 2014]
[edit reason] thread cleanup [/edit]

graeme_p




msg:4655029
 11:55 am on Mar 18, 2014 (gmt 0)

Can you please tell me where in the HTML5 spec it states what the allowed values of the itemtype attribute are? I tried without success to find it.

mattur




msg:4657127
 3:56 pm on Mar 25, 2014 (gmt 0)

The itemtype attribute is defined here:

[whatwg.org...]

Note that Validators (and Microdata consumers) may well lag behind what's defined in the spec. What matters is what the software you're aiming to gain a benefit from, by adding this markup, actually supports imho

graeme_p




msg:4657332
 7:32 am on Mar 26, 2014 (gmt 0)

So, if we accept WhatWG as authoritative then the standard says we can have multiple space separated itemtypes, so the validator is wrong!

Of course, you are quite right, the important thing is what Google and Bing make of it - but if they do, then its safe to do because they are unlikely to move away from what the standard says.

drhowarddrfine




msg:4657417
 12:59 pm on Mar 26, 2014 (gmt 0)

Well, especially cause they wrote it.

mattur




msg:4657420
 1:40 pm on Mar 26, 2014 (gmt 0)

So, if we accept WhatWG as authoritative then the standard says we can have multiple space separated itemtypes, so the validator is wrong!


The WhatWG spec is authoritative, Microdata is developed and maintained in the WhatWG, the W3C HTMLWG just published a split out copy of the Microdata section of the WhatWG spec as a Note a few months ago because no one was interested in editing it at W3C. The politics around this issue are certainly confusing though :)

The validator does recognise space separated itemtypes, the OP's problem seems to be the Microdata consumer he/she is using does not, as I understand it:

%20 doesn't work, then it is valid HTML, but the tree on the microdata is lost and you only have the list of items.

graeme_p




msg:4657430
 1:55 pm on Mar 26, 2014 (gmt 0)

I thought the OP was trying to get the HTML to pass am HTML validator....

Thanks for the details of who does what with regard to the Microdata spec.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved