mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
Microdata: schema.org format support
This commit is contained in:
@@ -115,13 +115,20 @@ public class MicrodataUtil {
|
||||
|
||||
private static List<String> collectNames(PsiFile file, String type) {
|
||||
if (file instanceof XmlFile) {
|
||||
final CollectNamesVisitor collectNamesVisitor = new CollectNamesVisitor(type);
|
||||
final CollectNamesVisitor collectNamesVisitor = getVisitorByType(type);
|
||||
file.accept(collectNamesVisitor);
|
||||
return collectNamesVisitor.getValues();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private static CollectNamesVisitor getVisitorByType(String type) {
|
||||
if (type.contains("schema.org")) {
|
||||
return new CollectNamesFromSchemaOrgVisitor();
|
||||
}
|
||||
return new CollectNamesByMicrodataVisitor(type);
|
||||
}
|
||||
|
||||
public static PsiReference[] getUrlReferencesForAttributeValue(final XmlAttributeValue element) {
|
||||
return getReferencesForAttributeValue(element, new PairFunction<String, Integer, PsiReference>() {
|
||||
@Nullable
|
||||
@@ -172,12 +179,18 @@ public class MicrodataUtil {
|
||||
}
|
||||
|
||||
private static class CollectNamesVisitor extends XmlRecursiveElementVisitor {
|
||||
protected final Set<String> myValues = new THashSet<String>();
|
||||
|
||||
private final String myType;
|
||||
public List<String> getValues() {
|
||||
return new ArrayList<String>(myValues);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CollectNamesByMicrodataVisitor extends CollectNamesVisitor {
|
||||
protected final String myType;
|
||||
private boolean myCollecting = false;
|
||||
private final Set<String> myValues = new THashSet<String>();
|
||||
|
||||
public CollectNamesVisitor(String type) {
|
||||
public CollectNamesByMicrodataVisitor(String type) {
|
||||
myType = type;
|
||||
}
|
||||
|
||||
@@ -199,9 +212,18 @@ public class MicrodataUtil {
|
||||
myCollecting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getValues() {
|
||||
return new ArrayList<String>(myValues);
|
||||
public static class CollectNamesFromSchemaOrgVisitor extends CollectNamesVisitor {
|
||||
@Override
|
||||
public void visitXmlTag(XmlTag tag) {
|
||||
super.visitXmlTag(tag);
|
||||
if ("prop-nam".equalsIgnoreCase(getStripedAttributeValue(tag, "class"))) {
|
||||
final String code = tag.getSubTagText("code");
|
||||
if (code != null) {
|
||||
myValues.add(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,48 @@ public class MicrodataCompletionTest extends CodeInsightFixtureTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
public void testPropValueSchemaOrgFormat() throws Throwable {
|
||||
final VirtualFile virtualFile = myFixture.copyFileToProject("Product.html");
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ExternalResourceManager.getInstance().addResource("http://schema.org/Product", virtualFile.getPath());
|
||||
}
|
||||
});
|
||||
doTestInHtml("<section itemscope itemtype=\"http://schema.org/Product\"><div itemprop=\"<caret>\"></div></section>",
|
||||
"additionalType",
|
||||
"aggregateRating",
|
||||
"brand",
|
||||
"color",
|
||||
"depth",
|
||||
"description",
|
||||
"gtin13",
|
||||
"gtin14",
|
||||
"gtin8",
|
||||
"height",
|
||||
"image",
|
||||
"isAccessoryOrSparePartFor",
|
||||
"isConsumableFor",
|
||||
"isRelatedTo",
|
||||
"isSimilarTo",
|
||||
"itemCondition",
|
||||
"logo",
|
||||
"manufacturer",
|
||||
"model",
|
||||
"mpn",
|
||||
"name",
|
||||
"offers",
|
||||
"productID",
|
||||
"releaseDate",
|
||||
"review",
|
||||
"reviews",
|
||||
"sku",
|
||||
"url",
|
||||
"weight",
|
||||
"width"
|
||||
);
|
||||
}
|
||||
|
||||
public void testPropValueFromTwoTypes() throws Throwable {
|
||||
final VirtualFile personFile = myFixture.copyFileToProject("Person.html");
|
||||
final VirtualFile addressFile = myFixture.copyFileToProject("Address.html");
|
||||
|
||||
706
xml/tests/testData/microdata/Product.html
Normal file
706
xml/tests/testData/microdata/Product.html
Normal file
@@ -0,0 +1,706 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Product - schema.org</title>
|
||||
|
||||
<meta name="description" content="Schema.org is a set of extensible
|
||||
schemas that enables webmasters to embed
|
||||
structured data on their web pages for use by search engines and
|
||||
other applications.">
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="search_files/schemaorg.css">
|
||||
|
||||
<link href="search_files/prettify.css" type="text/css"
|
||||
rel="stylesheet" />
|
||||
<script type="text/javascript" src="js/prettify.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
prettyPrint();
|
||||
setTimeout(function(){
|
||||
|
||||
$(".atn:contains(itemscope), .atn:contains(itemtype), .atn:contains(itemprop), .atn:contains(itemid), .atn:contains(time), .atn:contains(datetime), .atn:contains(datetime), .tag:contains(time) ").addClass('new');
|
||||
$('.new + .pun + .atv').addClass('curl');
|
||||
|
||||
}, 500);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
.pln { color: #444; } /* plain text */
|
||||
.tag { color: #515484; } /* div, span, a, etc */
|
||||
.atn,
|
||||
.atv { color: #314B17; } /* href, datetime */
|
||||
.new { color: #660003; } /* itemscope, itemtype, etc,. */
|
||||
.curl { color: #080; } /* new url */
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="intro">
|
||||
<div id="pageHeader">
|
||||
<div class="wrapper">
|
||||
<h1>schema.org</h1>
|
||||
|
||||
<div id="cse-search-form" style="width: 400px;"></div>
|
||||
|
||||
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
|
||||
<script type="text/javascript">
|
||||
google.load('search', '1', {language : 'en', style : google.loader.themes.ESPRESSO});
|
||||
google.setOnLoadCallback(function() {
|
||||
var customSearchControl = new google.search.CustomSearchControl('013516846811604855281:nj5laplixaa');
|
||||
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
|
||||
var options = new google.search.DrawOptions();
|
||||
options.enableSearchboxOnly("docs/search_results.html", null, false, '#');
|
||||
customSearchControl.draw('cse-search-form', options);
|
||||
}, true);
|
||||
</script>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="selectionbar">
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li >
|
||||
<a href="docs/documents.html">Documentation</a></li>
|
||||
<li class="activelink">
|
||||
<a href="docs/schemas.html">Schemas</a></li>
|
||||
<li >
|
||||
<a href=".">Home</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div style="padding: 14px; float: right;" id="languagebox"></div>
|
||||
|
||||
<div id="mainContent">
|
||||
|
||||
|
||||
<h1 class="page-title">
|
||||
|
||||
|
||||
<a href=Thing>Thing</a>
|
||||
|
||||
>
|
||||
<a href=Product>Product</a>
|
||||
|
||||
</h1>
|
||||
A product is anything that is made available for sale—for example, a pair of shoes, a concert ticket, or a car. Commodity services, like haircuts, can also be represented using this type.
|
||||
|
||||
|
||||
|
||||
<table cellspacing="3" class="definition-table">
|
||||
<thead><tr><th>Property</th><th>Expected Type</th><th>Description</th>
|
||||
</tr></thead>
|
||||
|
||||
|
||||
<thead class="supertype"><tr>
|
||||
<th class="supertype-name" colspan="3">Properties from <a href="Thing">Thing</a></th></tr></thead>
|
||||
<tbody class="supertype">
|
||||
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>additionalType</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
URL
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. This is a relationship between something and a class that the thing is in. In RDFa syntax, it is better to use the native RDFa syntax - the 'typeof' attribute - for multiple types. Schema.org tools may have only weaker understanding of extra types, in particular those defined externally.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>description</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">A short description of the item.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>image</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
URL
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">URL of an image of the item.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>name</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The name of the item.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>url</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
URL
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">URL of the item.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<thead class="supertype"><tr>
|
||||
<th class="supertype-name" colspan="3">Properties from <a href="Product">Product</a></th></tr></thead>
|
||||
<tbody class="supertype">
|
||||
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>aggregateRating</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=AggregateRating>AggregateRating</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The overall rating, based on a collection of reviews or ratings, of the item.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>brand</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Brand>Brand</a>
|
||||
|
||||
|
||||
or
|
||||
|
||||
<a href=Organization>Organization</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The brand(s) associated with a product or service, or the brand(s) maintained by an organization or business person.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>color</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The color of the product.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>depth</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Distance>Distance</a>
|
||||
|
||||
|
||||
or
|
||||
|
||||
<a href=QuantitativeValue>QuantitativeValue</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The depth of the product.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>gtin13</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The GTIN-13 code of the product, or the product to which the offer refers. This is equivalent to 13-digit ISBN codes and EAN UCC-13. Former 12-digit UPC codes can be converted into a GTIN-13 code by simply adding a preceeding zero.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>gtin14</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The GTIN-14 code of the product, or the product to which the offer refers.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>gtin8</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The GTIN-8 code of the product, or the product to which the offer refers. This code is also known as EAN/UCC-8 or 8-digit EAN.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>height</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Distance>Distance</a>
|
||||
|
||||
|
||||
or
|
||||
|
||||
<a href=QuantitativeValue>QuantitativeValue</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The height of the item.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>isAccessoryOrSparePartFor</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Product>Product</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">A pointer to another product (or multiple products) for which this product is an accessory or spare part.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>isConsumableFor</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Product>Product</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">A pointer to another product (or multiple products) for which this product is a consumable.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>isRelatedTo</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Product>Product</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">A pointer to another, somehow related product (or multiple products).</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>isSimilarTo</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Product>Product</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">A pointer to another, functionally similar product (or multiple products).</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>itemCondition</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=OfferItemCondition>OfferItemCondition</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">A predefined value from OfferItemCondition or a textual description of the condition of the product or service, or the products or services included in the offer.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>logo</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=ImageObject>ImageObject</a>
|
||||
|
||||
|
||||
or
|
||||
|
||||
URL
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">URL of an image for the logo of the item.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>manufacturer</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Organization>Organization</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The manufacturer of the product.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>model</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=ProductModel>ProductModel</a>
|
||||
|
||||
|
||||
or
|
||||
|
||||
Text
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The model of the product. Use with the URL of a ProductModel or a textual representation of the model identifier. The URL of the ProductModel can be from an external source. It is recommended to additionally provide strong product identifiers via the gtin8/gtin13/gtin14 and mpn properties.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>mpn</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The Manufacturer Part Number (MPN) of the product, or the product to which the offer refers.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>offers</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Offer>Offer</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">An offer to sell this item—for example, an offer to sell a product, the DVD of a movie, or tickets to an event.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>productID</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The product identifier, such as ISBN. For example: <code><meta itemprop='productID' content='isbn:123-456-789'/></code>.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>releaseDate</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
Date
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The release date of a product or product model. This can be used to distinguish the exact variant of a product.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>review</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Review>Review</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">A review of the item.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>reviews</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Review>Review</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">Review of the item (legacy spelling; see singular form, review).</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>sku</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
Text
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The Stock Keeping Unit (SKU), i.e. a merchant-specific identifier for a product or service, or the product to which the offer refers.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>weight</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=QuantitativeValue>QuantitativeValue</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The weight of the product.</td>
|
||||
</tr>
|
||||
|
||||
<tr><th class="prop-nam" scope="row">
|
||||
<code>width</code></th>
|
||||
<td class="prop-ect">
|
||||
|
||||
|
||||
|
||||
<a href=Distance>Distance</a>
|
||||
|
||||
|
||||
or
|
||||
|
||||
<a href=QuantitativeValue>QuantitativeValue</a>
|
||||
|
||||
|
||||
</td>
|
||||
<td class="prop-desc">The width of the item.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>More specific types</h3>
|
||||
<ul>
|
||||
|
||||
<li><a href=IndividualProduct>IndividualProduct</a>
|
||||
|
||||
<li><a href=ProductModel>ProductModel</a>
|
||||
|
||||
<li><a href=SomeProducts>SomeProducts</a>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="attrib">This class contains derivatives of properties from the GoodRelations Vocabulary for E-Commerce, created by Martin Hepp. GoodRelations is a data model for sharing e-commerce data on the Web that can be expressed in a variety of syntaxes, including RDFa and HTML5 Microdata. More information about GoodRelations can be found at <a href="http://purl.org/goodrelations/">http://purl.org/goodrelations/</a>.</div>
|
||||
|
||||
|
||||
<div class="version">Schema Draft Version 0.99</div>
|
||||
|
||||
<hr>
|
||||
<b>Example 1</b>
|
||||
<p><b>Original HTML:</b>
|
||||
<pre class="prettyprint lang-html linenums">
|
||||
Kenmore White 17" Microwave
|
||||
<img src="kenmore-microwave-17in.jpg" alt='Kenmore 17" Microwave' />
|
||||
Rated 3.5/5 based on 11 customer reviews
|
||||
|
||||
$55.00
|
||||
In stock
|
||||
|
||||
Product description:
|
||||
0.7 cubic feet countertop microwave. Has six preset cooking categories and
|
||||
convenience features like Add-A-Minute and Child Lock.
|
||||
|
||||
Customer reviews:
|
||||
|
||||
Not a happy camper - by Ellie, April 1, 2011
|
||||
1/5 stars
|
||||
The lamp burned out and now I have to replace it.
|
||||
|
||||
Value purchase - by Lucas, March 25, 2011
|
||||
4/5 stars
|
||||
Great microwave for the price. It is small and fits in my apartment.
|
||||
...
|
||||
</pre>
|
||||
<br><br><b>With Microdata:</b>
|
||||
<pre class="prettyprint lang-html linenums">
|
||||
<div itemscope itemtype="http://schema.org/Product">
|
||||
<span itemprop="name">Kenmore White 17" Microwave</span>
|
||||
<img src="kenmore-microwave-17in.jpg" alt='Kenmore 17" Microwave' />
|
||||
<div itemprop="aggregateRating"
|
||||
itemscope itemtype="http://schema.org/AggregateRating">
|
||||
Rated <span itemprop="ratingValue">3.5</span>/5
|
||||
based on <span itemprop="reviewCount">11</span> customer reviews
|
||||
</div>
|
||||
|
||||
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
|
||||
<span itemprop="price">$55.00</span>
|
||||
<link itemprop="availability" href="http://schema.org/InStock" />In stock
|
||||
</div>
|
||||
|
||||
Product description:
|
||||
<span itemprop="description">0.7 cubic feet countertop microwave.
|
||||
Has six preset cooking categories and convenience features like
|
||||
Add-A-Minute and Child Lock.</span>
|
||||
|
||||
Customer reviews:
|
||||
|
||||
<div itemprop="review" itemscope itemtype="http://schema.org/Review">
|
||||
<span itemprop="name">Not a happy camper</span> -
|
||||
by <span itemprop="author">Ellie</span>,
|
||||
<meta itemprop="datePublished" content="2011-04-01">April 1, 2011
|
||||
<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
|
||||
<meta itemprop="worstRating" content = "1">
|
||||
<span itemprop="ratingValue">1</span>/
|
||||
<span itemprop="bestRating">5</span>stars
|
||||
</div>
|
||||
<span itemprop="description">The lamp burned out and now I have to replace
|
||||
it. </span>
|
||||
</div>
|
||||
|
||||
<div itemprop="review" itemscope itemtype="http://schema.org/Review">
|
||||
<span itemprop="name">Value purchase</span> -
|
||||
by <span itemprop="author">Lucas</span>,
|
||||
<meta itemprop="datePublished" content="2011-03-25">March 25, 2011
|
||||
<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
|
||||
<meta itemprop="worstRating" content = "1"/>
|
||||
<span itemprop="ratingValue">4</span>/
|
||||
<span itemprop="bestRating">5</span>stars
|
||||
</div>
|
||||
<span itemprop="description">Great microwave for the price. It is small and
|
||||
fits in my apartment.</span>
|
||||
</div>
|
||||
...
|
||||
</div>
|
||||
</pre>
|
||||
|
||||
<hr>
|
||||
<b>Example 2</b>
|
||||
<p><b>Original HTML:</b>
|
||||
<pre class="prettyprint lang-html linenums">
|
||||
<img src="dell-30in-lcd.jpg" />
|
||||
Dell UltraSharp 30" LCD Monitor
|
||||
|
||||
87 out of 100 based on 24 user ratings
|
||||
|
||||
$1250 to $1495 from 8 sellers
|
||||
|
||||
Sellers:
|
||||
<a href="save-a-lot-monitors.com/dell-30.html">
|
||||
Save A Lot Monitors - $1250</a>
|
||||
<a href="jondoe-gadgets.com/dell-30.html">
|
||||
Jon Doe's Gadgets - $1350</a>
|
||||
...
|
||||
</pre>
|
||||
<br><br><b>With Microdata:</b>
|
||||
<pre class="prettyprint lang-html linenums">
|
||||
<div itemscope itemtype="http://schema.org/Product">
|
||||
<img itemprop="image" src="dell-30in-lcd.jpg" />
|
||||
<span itemprop="name">Dell UltraSharp 30" LCD Monitor</span>
|
||||
|
||||
<div itemprop="aggregateRating"
|
||||
itemscope itemtype="http://schema.org/AggregateRating">
|
||||
<span itemprop="ratingValue">87</span>
|
||||
out of <span itemprop="bestRating">100</span>
|
||||
based on <span itemprop="ratingCount">24</span> user ratings
|
||||
</div>
|
||||
|
||||
<div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer">
|
||||
<span itemprop="lowPrice">$1250</span>
|
||||
to <span itemprop="highPrice">$1495</span>
|
||||
from <span itemprop="offerCount">8</span> sellers
|
||||
|
||||
Sellers:
|
||||
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
|
||||
<a itemprop="url" href="save-a-lot-monitors.com/dell-30.html">
|
||||
Save A Lot Monitors - $1250</a>
|
||||
</div>
|
||||
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
|
||||
<a itemprop="url" href="jondoe-gadgets.com/dell-30.html">
|
||||
Jon Doe's Gadgets - $1350</a>
|
||||
</div>
|
||||
...
|
||||
</div>
|
||||
</pre>
|
||||
|
||||
<br><br>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="footer"><p>
|
||||
<a href="docs/terms.html">Terms and conditions</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user