[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSLT Help to RDF


foaf xslt
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@l...</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@l...</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



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.