1 Replies - 1130 Views - Last Post: 26 October 2012 - 05:56 AM Rate Topic: -----

#1 kondja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-August 10

Retrieving Data in xml using XSLT with ID, IDREF

Posted 26 October 2012 - 05:37 AM

Hi, im trying to retrieve data from xml document using the key function as i want to retrieve the data in the student entity and use the ID in the student entity of the coure_reg_for to find the actual course details the student is suing, please find the two codes.

Because when im doing it, it does not display anything.

<?xml version="1.0" encoding="UTF-8"?>

<!-- New document created with EditiX at Tue Oct 16 23:02:18 WAST 2012 -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" indent="yes"/>
<xsl:key name="courseID" match="student" use="@course_reg_for_id"/>

<xsl:template match="school">
<html>
<body>
<xsl:for-each select="student[@student_id='s123456']" >

<xsl:value-of select="sfirst_name"/>
&amp;
<xsl:value-of select="slast_name"/>
</xsl:for-each>



</body>
</html>
</xsl:template>

</xsl:stylesheet>




Thank you

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Retrieving Data in xml using XSLT with ID, IDREF

#2 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5780
  • View blog
  • Posts: 12,595
  • Joined: 16-October 07

Re: Retrieving Data in xml using XSLT with ID, IDREF

Posted 26 October 2012 - 05:56 AM

Please use code tags.

I didn't look at your XML. Didn't have to. All XSLT needs a template for match="/". This is were the matching starts. Without this, nothing happens.

Also, avoid for-each. It's a crutch. Use matches to control logic.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1