[Petal] Using Petal for RDF templates

Chris Croome chris@webarchitects.co.uk
Fri, 16 Aug 2002 13:06:59 +0100


Hi

If you want to use Petal for RDF generation and you also want your template to
validate (and generate graphs from it) using a validator such as the W3C RDF
Validator [1] then you need to do some Petal things in a specific way.

1. Not using dummy content 

   This syntax will generate an error:

    <dc:publisher 
      petal:content="encode:document/Publisher"
    >
      Example Publisher
    </dc:publisher>

   Where as the following syntax, without the dummy content, will not:

    <dc:publisher 
      petal:content="encode:document/Publisher"
    />

2. Using processing instructions for conditions and some loops

   This loop will generate an error because of the condition and if attributes:

   <dcterms:hasPart
      petal:condition="true:document/Children"
      >
      <rdf:Seq>
        <rdf:li
          petal:repeat="child document/Children">
          <rdf:Description 
            petal:attributes="rdf:about child/URI"
            >
            <dc:title 
              petal:content="encode:child/Title"
            />
          </rdf:Description>
        </rdf:li>
      </rdf:Seq>
    </dcterms:hasPart>

    However if they are replaced with Processing Instructions then all that is
    generated is a warning for each PI:

    <?petal:condition var="true:links"?>
      <dcterms:hasPart>
        <rdf:Seq>
          <?petal:repeat var="link links"?>
            <rdf:li>
              <rdf:Description 
                petal:attributes="rdf:about child/URI"
              >
                <dc:title 
                  petal:content="encode:child/Title"
                />
              </rdf:Description>
            </rdf:li>
          <?petal:end?>
        </rdf:Seq>
      </dcterms:hasPart>
    <?petal:end?>     


The examples above need to be wrapped in the following before putting through
the RDF validator:

<?xml version="1.0" encoding="UTF-8"?>

<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:dcterms="http://purl.org/dc/terms/"
  xmlns:dctype="http://purl.org/dc/dcmitype/"
  xmlns:petal="http://purl.org/petal/1.0/"
>
  <dctype:Text 
    rdf:about="http://example.com/"
    petal:attributes="rdf:about document/URI"
  >

<?insert examples?>

  </dctype:Text>
</rdf:RDF>


[1] http://www.w3.org/RDF/Validator/

-- 
Chris Croome                               <chris@webarchitects.co.uk>
web design                             http://www.webarchitects.co.uk/ 
web content management                               http://mkdoc.com/   
everything else                               http://chris.croome.net/