I have xml/rdf file which I get from service. So, I need to transform it to html block via XSL.
Here is part of xml/rdf file:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:c="http://s.opencalais.com/1/pred/">
<rdf:Description rdf:about="http://d.opencalais.com/dochash-1/f1a1cace-8df1-3247-b8e2-331a8fa8363d/Instance/2">
<rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/>
<c:docId rdf:resource="http://d.opencalais.com/dochash-1/f1a1cace-8df1-3247-b8e2-331a8fa8363d"/>
<c:subject rdf:resource="http://d.opencalais.com/comphash-1/f69211ed-b366-31a8-9e04-b85c50b8e0a5"/><!--Company: Zila Inc.; -->
<c:detection>[ PHOENIX, March 28 /PRNewswire/ -- ]Zila, Inc.[ (Nasdaq: ZILA) Chairman and President Joseph]</c:detection>
<c:prefix> PHOENIX, March 28 /PRNewswire/ -- </c:prefix>
<c:exact>Zila, Inc.</c:exact>
<c:suffix> (Nasdaq: ZILA) Chairman and President Joseph</c:suffix>
<c:offset>131</c:offset>
<c:length>10</c:length>
</rdf:Description>
<rdf:Description rdf:about="http://d.opencalais.com/dochash-1/f1a1cace-8df1-3247-b8e2-331a8fa8363d/Instance/3">
<rdf:type rdf:resource="http://s.opencalais.com/1/type/sys/InstanceInfo"/>
<c:docId rdf:resource="http://d.opencalais.com/dochash-1/f1a1cace-8df1-3247-b8e2-331a8fa8363d"/>
<c:subject rdf:resource="http://d.opencalais.com/comphash-1/f69211ed-b366-31a8-9e04-b85c50b8e0a5"/><!--Company: Zila Inc.; -->
<c:detection>[March 28 /PRNewswire/ -- Zila, Inc. (Nasdaq: ]ZILA[) Chairman and President Joseph Hines announced]</c:detection>
<c:prefix>March 28 /PRNewswire/ -- Zila, Inc. (Nasdaq: </c:prefix>
<c:exact>ZILA</c:exact>
<c:suffix>) Chairman and President Joseph Hines announced</c:suffix>
<c:offset>151</c:offset>
<c:length>4</c:length>
</rdf:Description>
<rdf:Description rdf:about="http://d.opencalais.com/comphash-1/f69211ed-b366-31a8-9e04-b85c50b8e0a5">
<rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/Company"/>
<c:name>Zila Inc.</c:name>
<c:nationality>N/A</c:nationality>
</rdf:Description>
<rdf:Description rdf:about="http://d.opencalais.com/pershash-1/31337438-fcbd-3137-9705-ef2f1a752b88">
<rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/Person"/>
<c:name>Joseph Hines</c:name>
<c:persontype>economic</c:persontype>
<c:nationality>N/A</c:nationality>
<c:commonname>Joseph Hines</c:commonname>
</rdf:Description>
...
</rdf:RDF>
So, I have to build html from it. Html consists from entities lists, which have title and items.
Titles are the last word in <rdf:type> node’s attribute.
Expamle:
<rdf:Description rdf:about="http://d.opencalais.com/pershash-1/31337438-fcbd-3137-9705-ef2f1a752b88">
<rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/Person"/>
<c:name>Joseph Hines</c:name>
<c:persontype>economic</c:persontype>
<c:nationality>N/A</c:nationality>
<c:commonname>Joseph Hines</c:commonname>
</rdf:Description>
This node have to be transformed to
<div class="Block">
<div class="Header Person">Person</div>
<div class="Item">Joseph Hines</div>
</div>
So, I have lots of such blocks, which have Person (or another) Header and Item in <c:name> node.
How can I transform this xml/rdf to html blocks and place all items with same header (e.g. Person) to same block?
It should looks like
<div class="Block">
<div class="Header Person">Person</div>
<div class="Item">Joseph Hines</div>
<div class="Item">another item</div>
...
</div>
<div class="Block">
<div class="Header Company">Company</div>
<div class="Item">Zila Inc.</div>
<div class="Item">another company item</div>
...
</div>
...
Sorry, If the problem isn’t clear. I’ll answer to all questions to help understand my problem.
Thanks in advance.
This XSLT:
Applied to a more descriptive input XML:
Produces this correct result:
EDIT:
And the result:
You can exclude any unnecessary types yourself or provide a criteria for such exclusion.