XSLT stylesheets

Hi Kevin,

At the SIMILE-core telecon you were after sources of information about XSLT.
The obvious source is Michael Kay's book publishe by Wrox Press titled
"XSLT: Programmers Reference". I also found a series of articles published
by XML.com on XSLT very helpful - see

http://www.xml.com/pub/a/2002/03/20/xpath2.html
http://www.xml.com/pub/a/2002/04/10/xslt2.html

http://www.xml.com/pub/a/2003/05/07/tr.html
http://www.xml.com/pub/a/2003/10/01/tr.html
http://www.xml.com/pub/a/2003/09/03/trxml.html
http://www.xml.com/pub/a/2003/08/06/tr.html
http://www.xml.com/pub/a/2003/07/09/xslt.html
http://www.xml.com/pub/a/2003/06/04/tr.html

Beware XSLT 2.0 has changed since the 2002 articles so they are slightly
misleading.

One the phone, you said you were struggling to convert XML elements to
references? I'm guessing you mean you want to convert something like this

<MyObject>
	<topic>thetopicterm</topic>
<MyObject>

to this

<MyObject>
	<topic>
		<rdf:Description
rdf:about="http://example.com/data/topicterms#thetopicterm"/>
			<rdfs:label>thetopicterm</rdfs:label>
	</topic>
</MyObject>

then you can use some XSLT like this:

<xsl:template match="MyObject">
		<MyObject>
			<xsl:if test="not(normalize-space(./topic)='')">
				<topic>
					<rdf:Description>
						<xsl:attribute
name="rdf:about">&namespace;topicterms#<xsl:value-of
select="./topic"/></xsl:attribute>
						<rdfs:label><xsl:value-of
select="./topic"/></rdfs:label>
					</rdf:Description>
				</topic>
			</xsl:if>
		</MyObject>
</xsl:template>

Although note you need to define namespace at the top using an entity
definition e.g.

<!ENTITY namespace 		'http:/example.com/data'>

Any questions please let me know?

Dr Mark H. Butler
Research Scientist                HP Labs Bristol
mark-h_butler@hp.com
Internet: http://www-uk.hpl.hp.com/people/marbut/

Received on Tuesday, 21 October 2003 11:25:51 UTC