I'm new to XSLT, so forgive me if my code is horrible. I would like to have an HTML table with episode details for each daily intervention. In momemt with my code, I don't even have a table. I was looking for ways to do this, but to no avail
My xml
<?xml version="1.0" encoding="UTF-8" ?> <?xml-stylesheet type="text/xsl" href="example_XMLTransformationFile.xsl"?> <ClientImport xmlns:xsi="http://www.w3.org/2001/XMLSchema"> <episode localID="P333456"> <episodeDetails> <caseNo>0000000</caseNo> <address1>where Person1 live</address1> <address4>Do they live there</address4> <postcode>PP1 2PP</postcode> <familyName>Person1</familyName> <firstName>PersonF1</firstName> <dobEst>0</dobEst> </episodeDetails> <dailyInterventions> <dailyIntervention> <activityDate>2012-08-23</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>true</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-24</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>true</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-25</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-26</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>true</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-27</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>true</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-28</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>true</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-29</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>true</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-30</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-31</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> </dailyInterventions> </episode> <episode localID="20120410"> <episodeDetails> <caseNo>0000001</caseNo> <address1>where Person2 Lives</address1> <address4>Street Person2</address4> <postcode>XX1 1XX</postcode> <familyName>Person2</familyName> <firstName>Person2 A</firstName> <dobEst>0</dobEst> </episodeDetails> <dailyInterventions> <dailyIntervention> <activityDate>2012-08-23</activityDate> <noCrit>true</noCrit> </dailyIntervention> </dailyInterventions> </episode> <episode localID="20120411"> <episodeDetails> <caseNo>0000002</caseNo> <address1>Where Person3 Lives</address1> <address4>Person 3 Street</address4> <postcode>WW1 1WW</postcode> <familyName>Person3</familyName> <firstName>Person 3 B</firstName> <dobEst>0</dobEst> </episodeDetails> <dailyInterventions> <dailyIntervention> <activityDate>2012-08-24</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>true</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-25</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>true</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-26</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>true</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-27</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-28</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-29</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> </dailyInterventions> </episode> <episode localID="20120418"> <episodeDetails> <caseNo>000004</caseNo> <address1>where person4 lives</address1> <address4>Person4 Road</address4> <postcode>NN1 1NN</postcode> <familyName>Person4</familyName> <firstName>Person4 B</firstName> <dobEst>0</dobEst> </episodeDetails> <dailyInterventions> <dailyIntervention> <activityDate>2012-08-24</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> </dailyInterventions> </episode> <episode localID="20120419"> <episodeDetails> <caseNo>0000005</caseNo> <address1>Where Person5 Lives</address1> <address4>Person5 Road</address4> <postcode>SS1 1SS</postcode> <familyName>Person5</familyName> <firstName>Person5 K</firstName> <dobEst>0</dobEst> </episodeDetails> <dailyInterventions> <dailyIntervention> <activityDate>2012-08-25</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-26</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-27</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-28</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-29</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-30</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-31</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-09-01</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-09-02</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-09-03</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> </dailyInterventions> </episode> <episode localID="20120420"> <episodeDetails> <caseNo>0000006</caseNo> <address1>Where person6 Lives</address1> <address4>Person6 Road</address4> <postcode>EE1 EE1</postcode> <familyName>Person6</familyName> <firstName>Person6 N</firstName> <dobEst>0</dobEst> </episodeDetails> <dailyInterventions> <dailyIntervention> <activityDate>2012-08-23</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-24</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-25</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-26</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> <dailyIntervention> <activityDate>2012-08-27</activityDate> <ecg>true</ecg> <cpox>true</cpox> <invVentET>false</invVentET> <invVentTT>false</invVentTT> </dailyIntervention> </dailyInterventions> </episode>
My XSLT
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <xsl:apply-templates select="ClientImport"/> </html> </xsl:template> <xsl:template match="ClientImport"> <table border="1"> <tr> <th>LOCALID</th> <th>CASENO</th> <th>ADDRESS1</th> <th>ADDRESS4</th> <th>POSTCODE</th> <th>FAMILYNAME</th> <th>FIRSTNAME</th> <th>DOBEST</th> <th>ACTIVITYDATE</th> <th>ECG</th> <th>CPOX</th> <th>INVVENTET</th> <th>INVVENTTT</th> </tr> <xsl:apply-templates select="episode"/> </table> </xsl:template> <xsl:template match="episode"> <tr> <td><xsl:value-of select="@localID"/></td> <xsl:apply-templates select="dailyInterventions/dailyIntervention"/> </tr> </xsl:template> <xsl:template match="episodeDetails"> <td><xsl:value-of select="caseNo"/></td> <td><xsl:value-of select="address1"/></td> <td><xsl:value-of select="address4"/></td> <td><xsl:value-of select="postcode"/></td> <td><xsl:value-of select="familyName"/></td> <td><xsl:value-of select="firstName"/></td> <td><xsl:value-of select="dobEst"/></td> </xsl:template> <xsl:template match="dailyInterventions/dailyIntervention"> <xsl:apply-templates select="episodeDetails"> <xsl:for-each select="dailyInterventions/dailyIntervention"> <tr> <td><xsl:value-of select="activityDate"/></td> <td><xsl:value-of select="ecg"/></td> <td><xsl:value-of select="cpox"/></td> <td><xsl:value-of select="invVentET"/></td> <td><xsl:value-of select="invVentTT"/></td> </tr> </xsl:for-each> </xsl:template>
Desired output
localID caseNo address1 address4 postcode familyName firstName dobEst activityDate ecg cpox invVentET invVentTT noCrit P333456 0 where Person1 live Do they live there PP1 2PP Person1 PersonF1 0 23/08/2012 TRUE TRUE TRUE FALSE P333456 0 where Person1 live Do they live there PP1 2PP Person1 PersonF1 0 24/08/2012 TRUE TRUE TRUE FALSE P333456 0 where Person1 live Do they live there PP1 2PP Person1 PersonF1 0 25/08/2012 TRUE TRUE FALSE FALSE P333456 0 where Person1 live Do they live there PP1 2PP Person1 PersonF1 0 26/08/2012 TRUE TRUE TRUE FALSE P333456 0 where Person1 live Do they live there PP1 2PP Person1 PersonF1 0 27/08/2012 TRUE TRUE TRUE FALSE P333456 0 where Person1 live Do they live there PP1 2PP Person1 PersonF1 0 28/08/2012 TRUE TRUE TRUE FALSE P333456 0 where Person1 live Do they live there PP1 2PP Person1 PersonF1 0 29/08/2012 TRUE TRUE TRUE FALSE P333456 0 where Person1 live Do they live there PP1 2PP Person1 PersonF1 0 30/08/2012 TRUE TRUE FALSE FALSE P333456 0 where Person1 live Do they live there PP1 2PP Person1 PersonF1 0 31/08/2012 TRUE TRUE FALSE FALSE 20120410 1 where Person2 Lives Street Person2 XX1 1XX Person2 Person2 A 0 23/08/2012 TRUE 20120411 2 Where Person3 Lives Person 3 Street WW1 1WW Person3 Person 3 B 0 24/08/2012 TRUE TRUE TRUE FALSE 20120411 2 Where Person3 Lives Person 3 Street WW1 1WW Person3 Person 3 B 0 25/08/2012 TRUE TRUE TRUE FALSE 20120411 2 Where Person3 Lives Person 3 Street WW1 1WW Person3 Person 3 B 0 26/08/2012 TRUE TRUE TRUE FALSE 20120411 2 Where Person3 Lives Person 3 Street WW1 1WW Person3 Person 3 B 0 27/08/2012 TRUE TRUE FALSE FALSE 20120411 2 Where Person3 Lives Person 3 Street WW1 1WW Person3 Person 3 B 0 28/08/2012 TRUE TRUE FALSE FALSE 20120411 2 Where Person3 Lives Person 3 Street WW1 1WW Person3 Person 3 B 0 29/08/2012 TRUE TRUE FALSE FALSE 20120418 4 where person4 lives Person4 Road NN1 1NN Person4 Person4 B 0 24/08/2012 TRUE TRUE FALSE FALSE 20120419 5 Where Person5 Lives Person5 Road SS1 1SS Person5 Person5 K 0 25/08/2012 TRUE TRUE FALSE FALSE 20120419 5 Where Person5 Lives Person5 Road SS1 1SS Person5 Person5 K 0 26/08/2012 TRUE TRUE FALSE FALSE 20120419 5 Where Person5 Lives Person5 Road SS1 1SS Person5 Person5 K 0 27/08/2012 TRUE TRUE FALSE FALSE 20120419 5 Where Person5 Lives Person5 Road SS1 1SS Person5 Person5 K 0 28/08/2012 TRUE TRUE FALSE FALSE 20120419 5 Where Person5 Lives Person5 Road SS1 1SS Person5 Person5 K 0 29/08/2012 TRUE TRUE FALSE FALSE 20120419 5 Where Person5 Lives Person5 Road SS1 1SS Person5 Person5 K 0 30/08/2012 TRUE TRUE FALSE FALSE 20120419 5 Where Person5 Lives Person5 Road SS1 1SS Person5 Person5 K 0 31/08/2012 TRUE TRUE FALSE FALSE 20120419 5 Where Person5 Lives Person5 Road SS1 1SS Person5 Person5 K 0 01/09/2012 TRUE TRUE FALSE FALSE 20120419 5 Where Person5 Lives Person5 Road SS1 1SS Person5 Person5 K 0 02/09/2012 TRUE TRUE FALSE FALSE 20120419 5 Where Person5 Lives Person5 Road SS1 1SS Person5 Person5 K 0 03/09/2012 TRUE TRUE FALSE FALSE 20120420 6 Where person6 Lives Person6 Road EE1 EE1 Person6 Person6 N 0 23/08/2012 TRUE TRUE FALSE FALSE 20120420 6 Where person6 Lives Person6 Road EE1 EE1 Person6 Person6 N 0 24/08/2012 TRUE TRUE FALSE FALSE 20120420 6 Where person6 Lives Person6 Road EE1 EE1 Person6 Person6 N 0 25/08/2012 TRUE TRUE FALSE FALSE 20120420 6 Where person6 Lives Person6 Road EE1 EE1 Person6 Person6 N 0 26/08/2012 TRUE TRUE FALSE FALSE 20120420 6 Where person6 Lives Person6 Road EE1 EE1 Person6 Person6 N 0 27/08/2012 TRUE TRUE FALSE FALSE
source share