Conversion to RDF

(title modified)

This section provides ITS with a RDF vocabulary

ITS 2.0 provides annotations for element nodes (globally and locally) and attributes nodes (globally).

Generic vocabulary for the DOM element nodes and attribute nodes

In the following examples, we use the following HTML Document Snippet adapted from http://richard.cyganiak.de/2007/10/lod/#how-to-join :

doc.html:

<html translate=”no”>

 <head>

 </head>

 <body>

  <h2  id="how-to-join" translate=”yes” >How can I get my <span translate=”no”>dataset</span> into the diagram? </h2>

 </body>

</html>

In RDF, this specification introduces resources and properties that are necessary to preserve the minimum of DOM informations that is needed:

its:Node : the class of nodes,

its:Node a rdfs:Class .

its:ElementNode : the class of element nodes,

Vocabulary:

its:ElementNode rdfs:subClassOf its:Node.

Example:

:h2 a its:ElementNode .

its:AttributeNode : the class of attribute nodes

Vocabulary:

its:AttributeNode a rdfs:Class .

Example:

:h2Title a its:AttributeNode.

its:childElementNode : a property to link an element to one of its child elements nodes

Vocabulary:

its:childElementNode a rdf:Property ;

        rdfs:domain its:ElementNode ;

        rdfs:range its:ElementNode .

Example:

:h2 its:childElementNode :span .

its:attribute : a property to link an element to one of its attribute nodes

Vocabulary:

its:attribute a rdf:Property ;

        rdfs:domain its:ElementNode ;

        rdfs:range its:AttributeNode .

Example:

:h2 its:attribute :h2Title.

Example:

The HTML snippet will be translated as:

@prefix : <doc.html#>

@prefix its: <www.w3.org/2005/11/its>

:html its:childElementNode :head, :body ;

        its:attribute :htmlTranslate .

:body its:childElementNode :h2 .

:h2 its:attribute :h2Title, :h2Translate ;

  its:childElementNode :span .

:span its:attribute :spanTranslate .


DOM fragment: URI fragment to refer to one element or one attribute

We use the XPointer scheme for XPath. With a restricted subset of XPath 1.0 so that we may refer exactly one element node or exactly one attribute node in a DOM.

Examples:

#xpath(//*[@id="how-to-join"]) OR #how-to-join

:h2

#xpath(/html/@translate)

:htmlTranslate

#xpath(/html/body[1]/h2[1])

:h2

#xpath(//*[@id="how-to-join"]/@translate)

:h2Translate

#xpath(/html/body[1]/h2[1]/@translate)

:h2Translate

#xpath(//*[@id="how-to-join"]/span[1])

:span

#xpath(/html/body[1]/h2[1]/span[1])

:span

#xpath(//*[@id="how-to-join"]/span[1]/@translate)

:spanTranslate

#xpath(/html/body[1]/h2[1]/span[1]/@translate)

:spanTranslate

Example:

The HTML snippet may be translated as:

@prefix : <doc.html#>

@prefix its: <www.w3.org/2005/11/its>

:xpath(/html) its:childElementNode :xpath(/html/head[1]) , :xpath(/html/body[1]) ;

        its:attribute :xpath(/html/@translate) .

:xpath(/html/body[1]) its:childElementNode :xpath(//*[@id="how-to-join"]) .

:xpath(//*[@id="how-to-join"]) its:attribute :xpath(//*[@id="how-to-join"]/@title), :xpath(//*[@id="how-to-join"]/@translate) ;

  its:childElementNode :xpath(//*[@id="how-to-join"]/span[1]) .

:xpath(//*[@id="how-to-join"]/span[1]) its:attribute :xpath(//*[@id="how-to-join"]/span[1]@translate)

 .        

Warning: These URIs must be percent encoded here in turtle, so this is how it will really look like:

@prefix : <doc.html#>

@prefix its: <www.w3.org/2005/11/its>

:xpath%28%2Fhtml%5B1%5D%29 its:childElementNode :xpath%28%2Fhtml%5B1%5D%2Fhead%5B1%5D%29 , :xpath%28%2Fhtml%5B1%5D%2Fbody%5B1%5D%29 ;

        its:attribute :xpath%28%2Fhtml%5B1%5D%2F%40translate%29 .

:xpath%28%2Fhtml%5B1%5D%2Fbody%5B1%5D%29 its:childElementNode :xpath%28%2F%2F*%5B%40id%3D%22how-to-join%22%5D%29 .

:xpath%28%2F%2F*%5B%40id%3D%22how-to-join%22%5D%29 its:attribute :xpath%28%2F%2F*%5B%40id%3D%22how-to-join%22%5D%2F%40title%29, :xpath%28%2F%2F*%5B%40id%3D%22how-to-join%22%5D%2F%40translate%29 ;

  its:childElementNode :xpath%28%2F%2F*%5B%40id%3D%22how-to-join%22%5D%2Fspan%5B1%5D%29 .

:xpath%28%2F%2F*%5B%40id%3D%22how-to-join%22%5D%2Fspan%5B1%5D%29 its:attribute :xpath%28%2F%2F*%5B%40id%3D%22how-to-join%22%5D%2Fspan%5B1%5D%40translate%29

Generic Vocabulary for global rules

Each data category has a global rule that enables to apply annotations to a set of attribute nodes or element nodes in a generic manner.

The kind of selector that is used (XPath 1.0, CSS Selectors 3, etc.) is defined for each rule

A document is linked to a set of global rules through the its:rules property

This specification introduces:

its:rules : links a document to a list of rules.

Vocabulary:

its:rules a rdf:Property ;

rdfs:range rdf:List .

@not formalized: The list of rules should be described using the RDF Collections convention, every item is either an instance of a its:Rule, or a resource that is subject of a triple with property its:rules

its:Rule : the class of rules.

Vocabulary:

its:Rule a rdfs:Class ;

rdfs:comment "represents a single global rule" .

@caution: the queryLanguage is applied to each Rule !

its:queryLanguage : the query language of the list of rules.

Vocabulary:

its:queryLanguage a rdf:Property ;

        rdfs:domain its:Rule ;

        rdfs:comment "links an instance of its:Rule to the a resource that describes the selection mechanism [note: same values as for the queryLanguage XML attribute] " .

its:selector : a literal description of the selector used by the rule

Vocabulary:

its:selector a rdf:Property ;
        rdfs:domain its:Rule ;
        rdfs:comment "links an instance of its:Rule to a literal that represents the selector of this rule (XPath, CSS selector or other according to what is defined by the its:queryLanguage property." .

its:selects : a link from a Rule to a Node that is selected by the selector.

Vocabulary:

its:selects a rdf:Property ;

        rdfs:domain its:Rule ;

        rdfs:range its:Node .

rules that have links to external list of rules:

The list of rules may contain: instances of its:Rule, or other resources. These resources SHOULD have a its:rules property that links it to a list of rules or resources, etc.


Specific vocabulary for data categories

Translate

Vocabulary:

its:TranslateRule rdfs:subClassOf its:Rule .

its:translate a rdf:Property ;

rdfs:range its:yesOrNo . [note: itsxsd:yesOrNo ? c.f. ISSUE-30]

Global mapping

Mapping of example 24:

@prefix its: <http://www.w3.org/2005/11/its#>

<.../examples/xml/EX-translate-selector-1.rdf> its:rules (

 [ a its:TranslateRule ;

  its:translate "no"^^its:yesOrNo ;

  its:selector "//code" ;

  its:queryLanguage "XPath 1.0" ] ) .

#[note: queryLanguage values and datatype may change, and are applied on each rule. XPath 1.0 should be the default.]

@in application/rdf+xml: just to help the writing of the XSLT stylesheet

<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [

<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >

<!ENTITY its "http://www.w3.org/2005/11/its#" >

]>

<rdf:RDF xmlns:rdf="&rdf;#" xmlns:its="&its;#">
 <rdf:Description rdf:about=".../examples/xml/EX-translate-selector-1.rdf">

   <its:rules>

    <rdf:List>

      <!-- [note: queryLanguage values and datatype may change. ]-->

      <rdf:first>

        <its:TranslateRule its:selector="//code" its:queryLanguage="XPath 1.0">

         <its:translate rdf:datatype="&its;#yesOrNo">no</its:translate>

        </its:TranslateRule>

      </rdf:first>

      <rdf:rest rdf:resource="&rdf;#nil"/>

    </rdf:List>

   </its:rules>

  </rdf:Description>
</rdf:RDF>

Local mapping

Mapping of example 25:

@prefix its: <http://www.w3.org/2005/11/its#>

@prefix : <[note: URI of example to be completed ]/examples/xml/EX-translate-selector-2.xml#>

:xpath(/messages[1]/msg[1]/panelmsg[1]) its:translate "no" .

Local mapping

Mapping of example 26:

<!DOCTYPE html>

<html lang="en">

 <head>

  <meta charset="utf-8"/>

  <title>Translate flag test: Default</title>

  <script type="text/turtle">

@prefix its: <http://www.w3.org/2005/11/its#>

@prefix : <[note: URI of example to be completed ]/examples/html5/EX-translate-html5-local-1.html#>

:xpath(/html/body[1]/p[1]/span[1]) its:translate "no" .

  </script>

 </head>

 <body>

  <p>The <span>World Wide Web Consortium</span> is

    making the World Web Web worldwide!</p>

 </body>

</html>

Default rules

# root node is translate = yes

defaultRules:t-root a its:Rule ;

  its:selects "/*[1]" ;             # to be checked by XML experts

  its:translate "yes"^^its:yesOrNo .

# attributes are not to be translated

defaultRules:t-att a its:Rule ;

  its:selects "//@*" ;              # to be checked by XML experts

  its:translate "no"^^its:yesOrNo .  

Propagation rule

@prefix its: <http://www.w3.org/2005/11/its#> .

INSERT {

 ?child its:translate ?fatherValue .

}

WHERE {

 ?father a its:ElementNode ;

   its:translate ?fatherValue ;

   its:childElementNode ?child .

 MINUS ( ?child its:translate ?childValue )

}

Localization Note

Vocabulary:

@ note: There is: its:LocNote : the class of localisation notes, and its:locNote: a property that links a its:LocNote to a XMLLiteral

In RDF, one must alternate resources and properties. So there must be a property between a its:LocNoteRule and a its:LocNote.

The following chain unifies the model:

[a its:LocNoteRule] -its:locNoteRef-> [a its:LocNote] -> its:locNote -> "the locNote XMLLiteral"

its:LocNoteRule rdfs:subClassOf its:Rule .

its:LocNote a rdfs:Class . # the its:locNote element

its:locNoteType a rdf:Property ;

rdfs:range its:descriptionOrAlert . [note: similar to ISSUE-30]

its:locNote a rdf:Property ; # the its:locNote attribute

rdfs:range rdf:XMLLiteral .

its:locNotePointer a rdf:Property ; # points to an instance of its:LocNote

rdfs:range its:LocNote .

its:locNoteRef a rdf:Property ;

rdfs:range rdf:Resource .

its:locNoteRefPointer a rdf:Property ;

rdfs:range rdf:Literal .

@not formalized: exactly one locNoteType

@warning: difference with XML: one must alternate resources and properties. So there must be a property between a LocNoteRule and a LocNote. What is chosen is:

[a its:LocNoteRule] -its:locNoteRef-> [a its:LocNote] -> its:locNote -> "the locNote XMLLiteral"

@not formalized: only one of the locNotePointer, locNoteRef, locNoteRefPointer

Global mapping

Mapping of example 27:

@prefix its: <http://www.w3.org/2005/11/its#>

<.../examples/xml/EX-locNote-element-1.rdf> its:rules (

 [ a its:LocNoteRule ;

  its:locNoteType "alert"^^its:alertOrDescription ;

  its:selector "//msg[@id='DisableInfo'" ;

  its:queryLanguage "XPath 1.0" ;

  its:locNotePointer

    [ a its:LocNote ;

      its:locNote "The variable {0} has three possible values: 'printer', 'stacker' and 'stapler options'." ] ] ) .

Mapping of example 28:

@prefix its: <http://www.w3.org/2005/11/its#>

<.../examples/xml/EX-locNotePointer-attribute-1.rdf> its:rules (

 [ a its:LocNoteRule ;

  its:locNoteType "alert"^^its:alertOrDescription ;

  its:selector "//msg/notes" ;

  its:queryLanguage "XPath 1.0" ;

  its:locNotePointer "../notes" ] ) .

Mapping of example 29:

@prefix its: <http://www.w3.org/2005/11/its#>

<.../examples/xml/EX-locNoteRef-attribute-1.rdf> its:rules (

 [ a its:LocNoteRule ;

  its:locNoteType "description"^^its:alertOrDescription ;

  its:selector "//msg[@id='NotFound']" ;

  its:queryLanguage "XPath 1.0" ;

  its:locNoteRef <ResolvedURI … ErrorsInfo.html#NotFound> ] ) .

Mapping of example 30:

@prefix its: <http://www.w3.org/2005/11/its#>

<.../examples/xml/EX-locNoteRefPointer-attribute-1.rdf> its:rules (

 [ a its:LocNoteRule ;

  its:locNoteType "description"^^its:alertOrDescription ;

  its:selector "//data" ;

  its:queryLanguage "XPath 1.0" ;

  its:locNoteRefPointer "../@noteFile" ] ) .

Local mapping

Mapping of example 31:

@prefix its: <http://www.w3.org/2005/11/its#>

@prefix : <.../examples/xml/EX-locNote-selector-2.xml#>

:xpath(/msgList[1]/data[1]) its:locNoteType "alert"^^its:alertOrDescription ;

  its:locNoteRef [ a its:LocNote ; its:locNote "Keep the leading space!" ].

:xpath(/msgList[1]/data[2]) its:locNoteType "alert"^^its:alertOrDescription ;

  its:locNoteRef [ a its:LocNote ; its:locNote "%1\$s is the original text's date in the format YYYY-MM-DD HH:MM always in GMT" ] .

Mapping of example 32:

<!DOCTYPE html>

<html lang="en">

 <head>

  <meta charset="utf-8"/>

  <title>LocNote test: Default</title>

  <script type="text/turtle">

@prefix its: <http://www.w3.org/2005/11/its#>

@prefix : <.../examples/html5/EX-locNote-html5-local-1.html#>

:xpath(/html/body[1]/p[1]/span[1]) its:locNoteRef [ a its:LocNote ; its:locNote "Check with terminology engineer" ];

  its : locNoteType "alert"^^its:alertOrDescription .

  </script>

 </head>

 <body>

  <p>This is a <span its-loc-note="Check with terminology engineer" its-loc-note-type="alert">motherboard</span>.</p>

 </body>

</html>

Default rules

# no defaut rule

Propagation rule

# no propagation rule

@todo: other data categories and mapping of examples.


Algorithm for transformation from HTML + ITS 2.0 to RDF

1. add in the head of the HTML document: @todo: the default value rules<script type="text/turtle>

  @prefix : < ---here: the URI of the document--- >

  @prefix its: <http://www.w3.org/2005/11/its>

  : its:rules ( <http://www.w3.org/TR/its-2.0/default-rules.rdf> ) .

</script>

2. FOR EACH rules document linked in head

 a. append the URI of the new rules document converted using [XSLT stylesheet in appendix] at the end of the list that is object of  : its:rules  in the <script>

 b. delete the link in the head element

3. FOR EACH rules element in the head,

 a. convert it to RDF using [XSLT stylesheet in appendix]

 b. append the instance of its:Rule at the end of the list that is object of  : its:rules  in the <script>

   i. the URI of the resource that describes the RDF document containing the rules

   ii. the list of rules directly

 c. delete it in the head element

4. convert DOM to RDF using [Generic vocabulary for the DOM element nodes and attribute nodes], with generated URIs for element nodes and attribute nodes using , [ DOM fragment: URI fragment to refer to one element or one attribute ] but do not convert ITS attributes.

add all generated triples in the <script>

5. for each ITS attribute of an element e, apply the corresponding RDF property to the corresponding generated resource rdf-e in the RDF and delete the ITS attribute from the DOM.


Algorithm for propagating metadata

1. recursively apply rules   - default rules @todo: write default rules

2. Saturation with application of propagation rules

For 2. : One or more SPARQL 1.1 update rule per data category, to be applied until it has no effect. The rule depends on the data category attribute, the Inheritance type, the overriding possibility, if it is applied to an element or attribute.  For instance, see the rule for the translate data category.


Resolution algorithm for its:locNotePointer

For its:locNotePointer:

 1- same as with XML: evaluate the relative XPath on the DOM with respect to the context node ; create the resource <ln> that has for URI the XPath-scheme-based-URI of the selected node ; link the subject of its:locNotePointer to <ln> through the its:locNoteRef property

 2- this resource <ln> must be involved in at least two triples:  <ln> a its:LocNote ; its:locNote "the XMLLiteral"

     2a- If these triples exist, then they are not to be recomputed

     2b- if not, then triple <ln> a its:LocNote is added, and triple <ln> its:locNote "the XMLLiteral" must be added with "the XMLLiteral" being evaluated as :

         2ba- If ihe resource is an its:elementNode, the set of child nodes of the DOM element node converted to XMLLiteral (some XSLT stylesheet exist for that, see e.g.,  http://symphony-cms.com/download/xslt-utilities/view/79266/ ).

         2bb- if the resource is an its:attributeNode, the DOM value attribute of the Attr node

Resolution algorithm for its:locNoteRefPointer

For its:locNoteRefPointer:

 1- same as with XML: evaluate the relative XPath on the DOM with respect to the context node ; Assert that the selected node should be an attribute node ; Evaluate the absolute URI <ln> of the value of the selected attribute ; link the subject of its:locNoteRefPointer to <ln> through the its:locNoteRef property

 2- this resource <ln> must be involved in at least one triple:  <ln> a its:LocNote

     2a- If this triple exist, then it is not to be recomputed

     2b- if not, then triple <ln> a its:LocNote is added


Complete example for Translate: transformation, propagation.

file its-rules-example.xml

<its:rules version="1.0" xmlns:its="http://www.w3.org/2005/04/its"/>

  <its:translateRule selector="//img" translate="no"/>

  <its:translateRule selector="//img/@alt" translate="yes"/>

</its:rules>

file doc.html

<!DOCTYPE html>

 <html>

  <head translate="no">

   <link href="its-rules-example.xml" type="its-rules"/>

  </head>

  <body>

   <h2>How can I get my <span translate="no">dataset</span> into the diagram? </h2>

   <img src="some-file.png" alt="Image description"/>

  </body>

 </html>

transformation

Step 1:

file its-rules-example.xml

no change

file doc.html

<!DOCTYPE html>

 <html>

  <head translate="no">

   <link href="its-rules-example.xml" type="its-rules"/>

   <script type="text/turtle>

  @prefix : <http://example.org/doc.html#>

  @prefix its: <http://www.w3.org/2005/11/its#>

  : its:rules ( <http://www.w3.org/TR/its-2.0/default-rules.rdf> ) .

   </script>

...

Step 2:

file its-rules-example.xml converted to its-rules-example.rdf

(output should be in RDF/XML, here in turtle for readability purpose)

@prefix its: <http://www.w3.org/2005/11/its#> .

@prefix : <http://example.org/its-rules-example.rdf> .

: its:rules ( :tr1 :tr2 ) .

:tr1 a its:translateRule ;

  its:selector "//img" ;

  its:translate "no"^^its:yesOrNo .

:tr2 a its:translateRule ;

  its:selector "//img/@alt" ;

  its:translate "yes"^^its:yesOrNo . ) .

file doc.html

...

   <script type="text/turtle>

  @prefix : <http://example.org/doc.html#>

  @prefix its: <http://www.w3.org/2005/11/its#>

  : its:rules (

  <http://www.w3.org/TR/its-2.0/default-rules.rdf>

  <http://example.org/its-rules-example.rdf> ) .

   </script>

...

Step 3:

no change

Step 4 & 5:

file its-rules-example.xml converted to its-rules-example.rdf

no change

file doc.html

(generated URI based on XPath should have most characters percent escaped, we did not do it here for readability purpose)

...

   <script type="text/turtle>

  @prefix : <http://example.org/doc.html#>

  @prefix its: <http://www.w3.org/2005/11/its#>

  : its:rules (

  <http://www.w3.org/TR/its-2.0/default-rules.rdf>

  <http://example.org/its-rules-example.rdf> ) .

 

:xpath(/html)

  its:childElementNode :xpath(/html/head[1]) ;

  its:childElementNode :xpath(/html/body[1]) .

:xpath(/html/head[1])

  its:childElementNode :xpath(/html/head[1]/script[1]) ;

  its:translate "no"^^its:yesOrNo .

:xpath(/html/body[1])

  its:childElementNode :xpath(/html/body[1]/h2[1]) ;

  its:childElementNode :xpath(/html/body[1]/img[1]) .

:xpath(/html/body[1]/h2[1])

  its:childElementNode :xpath(/html/body[1]/h2[1]/span[1]) .

:xpath(/html/body[1]/h2[1]/span[1]) its:translate "no"^^its:yesOrNo .

:xpath(/html/body[1]/img[1])

  its:attribute :xpath(/html/body[1]/h2[1]/img[1]/@src) ;

  its:attribute :xpath(/html/body[1]/h2[1]/img[1]/@alt) .

   </script>

...

Propagation

Step 1: Application of rules

1.1. Application of rules in  <http://www.w3.org/TR/its-2.0/default-rules.rdf>

# root element is translate="yes" : 1 triple added:

:xpath(/html) its:translate "yes"^^its:yesOrNo .

# attribute is translate="no" : 2 triples added:

:xpath(/html/body[1]/h2[1]/img[1]/@src) its:translate "no"^^its:yesOrNo .

:xpath(/html/body[1]/h2[1]/img[1]/@alt) its:translate "no"^^its:yesOrNo .

1.2. Application of rules in <http://example.org/its-rules-example.rdf>

@Prefix rules: <http://example.org/its-rules-example.rdf#>

 1.2.1 rule rules:tr1 its:selector "//img" ; its:translate "no"^^its:yesOrNo .

# evaluation of selected nodes using XPath: 1 triple added:

rules:tr1 its:selects :xpath(/html/body[1]/img[1]) .

# transfer of properties to selected nodes (and override as the case may be):

# 1 triple added:

:xpath(/html/body[1]/img[1]) its:translate "no"^^its:yesOrNo .

 1.2.2 rule rules:tr2 its:selector "//img/@alt" ; its:translate "yes"^^its:ye...

# evaluation of selected nodes using XPath: 1 triple added:

rules:tr2 its:selects :xpath(/html/body[1]/img[1]/@alt) .

# transfer of properties to selected nodes (and override as the case may be):

# 1 triple deleted:

:xpath(/html/body[1]/img[1]/@alt) its:translate "no"^^its:yesOrNo .

# 1 triple added:

:xpath(/html/body[1]/img[1]/@alt) its:translate "yes"^^its:yesOrNo .

2. Saturation with application of propagation rules

# 3 triple deleted:

:xpath(/html/head[1]/script[1]) its:translate "no"^^its:yesOrNo .

:xpath(/html/body[1]) its:translate "yes"^^its:yesOrNo .

:xpath(/html/body[1]/h2[1]) its:translate "yes"^^its:yesOrNo .

# INFO: propagation rules for translate data category is:

# for elements:

@prefix its: <http://www.w3.org/2005/11/its#> .

INSERT {

 ?child its:translate ?fatherValue .

}

WHERE {

 ?father a its:ElementNode ;

   its:translate ?fatherValue ;

   its:childElementNode ?child .

 MINUS ( ?child its:translate ?childValue )

}

# for attributes: no propagation rule, only global rules

Conclusion: generated triples:

<script type="text/turtle>

  @prefix : <http://example.org/doc.html#>

  @prefix its: <http://www.w3.org/2005/11/its#>

  : its:rules (

  <http://www.w3.org/TR/its-2.0/default-rules.rdf>

  <http://example.org/its-rules-example.rdf> ) .

rules:tr1 its:selects :xpath(/html/body[1]/img[1]) .

rules:tr2 its:selects :xpath(/html/body[1]/img[1]/@alt) .

 

:xpath(/html)

  its:childElementNode :xpath(/html/head[1]) ;

  its:childElementNode :xpath(/html/body[1]) ;

  its:translate "yes"^^its:yesOrNo .

:xpath(/html/head[1])

  its:childElementNode :xpath(/html/head[1]/script[1]) ;

  its:translate "no"^^its:yesOrNo .

:xpath(/html/body[1])

  its:childElementNode :xpath(/html/body[1]/h2[1]) ;

  its:childElementNode :xpath(/html/body[1]/img[1]) ;

  its:translate "yes"^^its:yesOrNo .

:xpath(/html/body[1]/h2[1])

  its:childElementNode :xpath(/html/body[1]/h2[1]/span[1]) ;

  its:translate "yes"^^its:yesOrNo .

:xpath(/html/body[1]/h2[1]/span[1]) its:translate "no"^^its:yesOrNo .

:xpath(/html/body[1]/img[1])

  its:attribute :xpath(/html/body[1]/h2[1]/img[1]/@src) ;

  its:attribute :xpath(/html/body[1]/h2[1]/img[1]/@alt) .

:xpath(/html/body[1]/img[1]/@src) its:translate "no"^^its:yesOrNo .

:xpath(/html/body[1]/img[1]/@alt) its:translate "yes"^^its:yesOrNo .

</script>

query in RDF to say "give me all attributes that must be translated":

# SPARQL query

@prefix its: <http://www.w3.org/2005/11/its#> .

SELECT {

 ?att a its:AttributeNode ;

   its:translate "yes"^^its:yesOrNo .

}


Complete example : Localization Note, ex30, resolution of locNoteRefPointer

input should look like that in turtle ( I write without percent-encoding):

http://www.w3.org/International/its/tests/inputdata/EX-locNoteRefPointer-attribute-1.xml

output with the XML approach:

http://www.w3.org/International/its/tests/test2/EX-locNoteRefPointer-attribute-1-result.xml

@prefix : <http://www.w3.org/International/its/tests/inputdata/EX-locNoteRefPointer-attribute-1.xml#>

@prefix its: <http://www.w3.org/2005/11/its#>

  : its:rules ( <http://www.w3.org/TR/its-2.0/default-rules.rdf> :lnr ) .

  :lnr a its:LocNoteRule ;

    its:locNoteType "description"^^its:alertOrDescription ;

    its:selector "//body/string/data" ;

    its:locNoteRefPointer "../@noteFile" ;

    its:selectionType "XPath 1.0" .

  :XPath(/dataFile)

    its:childElementNode :XPath(/dataFile/prolog[1]) ;

    its:childElementNode :XPath(/dataFile/body[1]) .

  :XPath(/dataFile/body[1])

    its:childElementNode :XPath(/*[@id="FileNotFound"]) ;

    its:childElementNode :XPath(/*[@id="DivByZero"]) .

  :XPath(/*[@id="FileNotFound"])

    its:childElementNode :XPath( /*[@id="FileNotFound"] /data[1]) ;

    its:attribute :XPath(/*[@id="FileNotFound"]/@noteFile) .

  :XPath(/*[@id="DivByZero"])

    its:childElementNode :XPath(/*[@id="DivByZero"]/data[1]) ;

    its:attribute :XPath(/*[@id="DivByZero"]/@noteFile) .

-- end of transformation Step

-- begin propagation Step

application of rule :lnr

 :lnr its:selects :XPath(/*[@id="FileNotFound"]/data[1]) .

 :lnr its:selects :XPath(/*[@id="FileNotFound"]/data[2]) .

transfer of properties to selected nodes

 :XPath(/*[@id="FileNotFound"]/data[1]) its:locNoteType "description"^^its:alertOrDescription ;

    its:locNoteRefPointer "../@noteFile" .

 :XPath(/*[@id="FileNotFound"]/data[2]) its:locNoteType "description"^^its:alertOrDescription ;

    its:locNoteRefPointer "../@noteFile" .

-- end of propagation Step

-- begin LocNote resolution Step

resolution of locNoteRefPointer

step 1

 :XPath(/*[@id="FileNotFound"]/data[1]) its:locNoteType "description"^^its:alertOrDescription ;

    its:locNoteRefPointer "../@noteFile" ;

    its:locNoteRef <http://www.w3.org/International/its/tests/inputdata/Comments.html#FileNotFound> .

 :XPath(/*[@id="FileNotFound"]/data[2]) its:locNoteType "description"^^its:alertOrDescription ;

    its:locNoteRefPointer "../@noteFile" ;

    its:locNoteRef <http://www.w3.org/International/its/tests/inputdata/Comments.html#DivByZero> .

step 2b

 <http://www.w3.org/International/its/tests/inputdata/Comments.html#FileNotFound> a its:LocNote ;

 <http://www.w3.org/International/its/tests/inputdata/Comments.html#DivByZero> a its:LocNote ;

-- end of LocNote resolution Step


Appendix: RDFS vocabulary for ITS

@todo: compile vocabulary sections above in one text/turtle or application/rdf+xml document.

its:Node a rdfs:Class .

its:ElementNode rdfs:subClassOf its:Node.

its:AttributeNode a rdfs:Class .

its:childElementNode a rdf:Property ;

  rdfs:domain its:ElementNode ;

  rdfs:range its:ElementNode .

        

its:attribute a rdf:Property ;

  rdfs:domain its:ElementNode ;

  rdfs:range its:AttributeNode .

        

its:rules a rdf:Property ;

  rdfs:range rdf:List .

its:Rule a rdfs:Class ;

  rdfs:comment “represents a single global rule” .

its:queryLanguage a rdf:Property ;

  rdfs:domain its:Rule ;

  rdfs:comment “links an instance of a its:Rules to the a resource that describes the selection mechanism [note: same values as for the queryLanguage XML attribute] ” .

 

its:selector a rdf:Property ;

  rdfs:domain its:Rule ;

  rdfs:comment “links an instance of its:Rule to a literal that represents the selector of this rule (XPath, CSS selector or other according to what is defined by the its:queryLanguage property.” .

        

its:selects a rdf:Property ;

  rdfs:domain its:Rule ;

  rdfs:range its:Node .

 

its:translateRule rdfs:subClassOf its:Rule .

its:translate a rdf:Property ;

  rdfs:range its:yesOrNo .

Appendix: XSLT stylesheet: Direct mapping of its rules  document to RDF

An XSLT stylesheet enables the direct mapping of a its:rules XML element to RDF

@todo: a XSLT stylesheet -> to be added as an Annexe of the recommendation.

@todo: define and register a GRDDL profile for the ITS 2.0 XML documents