[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[xml] XSLT Help to RDF



Hello,

I need to transform following xml instance to RDF:
<gemq:catalogingOrganization>
  <foaf:name>Learn North Carolina</foaf:name>
  <foaf:phone>919-962-8888</foaf:phone>
  <foaf:homepage>http://www.learnnc.org</foaf:homepage>
  <foaf:mbox>mailto:mthibault learnnc org</foaf:mbox>
</gemq:catalogingOrganization>

<gemq:catalogingOrganization>Carolina Center</gemq:catalogingOrganization>

The expected rdf output might be:

<gemq:catalogingOrganization>
   <foaf:name>Learn North Carolina</foaf:name>
    <rdfs:label>Learn North Carolina</rdfs:label>
  <foaf:phone rdf:resource="http://www.unc.edu"/>919-962-8888</foaf:phone>
<foaf:homepage rdf:resource="http://www.unc.edu"/>http://www.learnnc.org</foaf:homepage>
  <foaf:mbox>mailto:mthibault learnnc org</foaf:mbox>
</gemq:catalogingOrganization>

<gemq:catalogingOrganization>Carolina Center</gemq:catalogingOrganization>

So, if gemq:catalogingOrganization has any foaf element, xslt needs to show. If gemq:catalogingOrganization does not have any foaf element, xsl needs only to show the values.

Could you help me with this?

Here is my xsl.
<xsl:template match="gemq:catalogingOrganization">
  <xsl:choose>
	<xsl:when test="foaf:name">
	 <foaf:name>
	 <xsl:value-of select="normalize-space(foaf:name)"/>
	  </foaf:name></xsl:when>
	<xsl:when test="foaf:phone">
	 <foaf:phone>
	<xsl:attribute name="rdf:resource">
	 <xsl:value-of select="normalize-space(foaf:phone)"/> </xsl:attribute>
	  </foaf:phone></xsl:when>
	<xsl:when test="foaf:mbox">
	 <foaf:mbox>
	<xsl:value-of select="normalize-space(foaf:mbox)"/>
	  </foaf:mbox></xsl:when>
	<xsl:when test="foaf:homepage">
	<foaf:homepage>
	<xsl:attribute name="rdf:resource">
	  <xsl:value-of select="normalize-space(foaf:homapge)"/> </xsl:attribute>
	  </foaf:homepage></xsl:when>
<xsl:otherwise><gemq:catalogingOrganization><xsl:value-of select="normalize-space(.)"/></gemq:catalogingOrganization></xsl:otherwise>
</xsl:choose>
 </xsl:template>

Thanks a lot,

Best regards,
Oknam Park





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]