代码之家  ›  专栏  ›  技术社区  ›  S16

产品的RDFa内容实现

  •  5
  • S16  · 技术社区  · 15 年前

    我沉浸在产品信息的RDFa实现的噩梦中,我很好奇是否有人能提供一些见解。

    谷歌直截了当地说,这并不是为了向机器提供数据而隐藏信息,除非是特定于机器的信息。但是,为了提供这些数据,我找不到任何关于有空元素的信息。

    <div xmlns="http://www.w3.org/1999/xhtml"
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
      xmlns:gr="http://purl.org/goodrelations/v1#"
      xmlns:foaf="http://xmlns.com/foaf/0.1/">
    
      <div typeof="gr:Offering" about="#offering">
        <div rev="gr:offers" resource="#company"></div>
        <div property="rdfs:label" content="Alpinestars S-MX Plus Racing Boots" xml:lang="en"></div>
        <div property="rdfs:comment" content="Alpinestars’ S-MX Plus racing boot raises performance and safety to new and unmatched levels with its innovative design, structural protection and comfort." xml:lang="en"></div>
        <div property="gr:hasEAN_UCC-13" content="0000000000000" datatype="xsd:string"></div>
        <div rel="foaf:depiction" resource="http://www.motorcycle-superstore.com/ProductImages/300/g17268.jpg"></div>
        <div rel="gr:hasBusinessFunction" resource="http://purl.org/goodrelations/v1#Sell"></div>
        <div rel="gr:hasPriceSpecification">
          <div typeof="gr:UnitPriceSpecification">
            <div property="gr:hasCurrency" content="USD" datatype="xsd:string"></div>
            <div property="gr:hasCurrencyValue" content="349.95" datatype="xsd:float"></div>
            <div property="gr:hasUnitOfMeasurement" content="C62" datatype="xsd:string"></div>
          </div>
        </div>
        <div rel="gr:acceptedPaymentMethods" resource="http://purl.org/goodrelations/v1#PayPal"></div>
        <div rel="gr:acceptedPaymentMethods" resource="http://purl.org/goodrelations/v1#AmericanExpress"></div>
        <div rel="gr:acceptedPaymentMethods" resource="http://purl.org/goodrelations/v1#Discover"></div>
        <div rel="gr:acceptedPaymentMethods" resource="http://purl.org/goodrelations/v1#MasterCard"></div>
        <div rel="gr:acceptedPaymentMethods" resource="http://purl.org/goodrelations/v1#VISA"></div>
        <div rel="foaf:page" resource="http://www.motorcycle-superstore.com/1/1/36/77/ITEM/Alpinestars-S-MX-Plus-Racing-Boots.aspx"></div>
      </div>
    </div>
    

    我在百思买非常成功地使用的实现中发现有趣的是,这里的标签中没有实际的内容,而只是一个content属性。

    那么,我的问题是,有没有人对这种类型的实现有什么见解,以及使用空div结构(它利用content属性)而不是将RDFa结构添加到现有标记中是否会受到惩罚?

    2 回复  |  直到 10 年前
        1
  •  6
  •   Stanislav Kralin kenwenzel    8 年前

    这就是“代码段样式”中的RDFa。充分论证;背景在这里

    http://www.ebusiness-unibw.org/tools/rdf2rdfa/

    在这里:

    赫普,马丁;加卡,罗伯托;Radinger,Andreas:RDF2RDFa:Turning RDF into Snippets for Copy and Paste,技术报告TR-2009-012009。 PDF在上面页面的底部。

    基本上,在a)重用数据标记的可见内容和b)分离关注点之间存在一种权衡。只要数据结构和可见内容标记的组织几乎是1:1,就可以轻松地使用传统样式的RDFa。但是,在丰富元数据的建模上强制使用可见标记的结构会创建混乱的标记,难以维护,容易出错。

    马丁水电站

    另外:您可以在XHTML、HTML5和HTML4模板中使用RDFa中的GoodRelations,尽管各个doctype的标准化状态不同。以下是正确的DOCTYPE设置:

    1. XHTML格式: a) 将DOCTYPE设置为XHTML+rdfa1.0: b) 将html version属性设置为XHTML+RDFa1.0

    2. HTML5 b) 将html version属性设置为html+RDFa1.1

    请注意,这只是W3C现阶段的一个工作草案,但仍然应该有效。

    另请参见: http://answers.semanticweb.com/questions/1187/can-i-use-the-html5-doctype-with-rdfa

        2
  •  0
  •   scor    12 年前

    关于HTML5,你应该简单地使用 RDFa 1.1 RDFa Lite ,它们在HTML5中有效。例如,您必须使用prefix属性将xmlns:转换为。