我是XSLT的新手,所以如果我的代碼很糟糕,請原諒我。我希望在HTML中有一個表格,每個日常干預都會重複插播細節。在我的代碼momemt我甚至沒有一張桌子。我一直在尋求方法來做到這一點,但沒有無濟於事如何編寫XSLT來重複兄弟節點的值,使其每次出現在同一個HTML表中的兄弟節點中
我的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>
我的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>
所需的輸出
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
由於得到所需的輸出,雖然有一些輕微的問題,我將盡力熨平,回到這裏,如果不解決 – user1704350
什麼問題?如果您發佈示例輸出以幫助理解並確保有用的答案,這將有所幫助。 –
我是新來的論壇,並學習我的方式。一直嘗試附加輸出無濟於事。這個問題(很輕微)是,當一個新的節目輸出時,節目詳細信息首先被輸出,並且它們不與標題一致。我試圖複製下面的輸出數據的樣本。 LOCALID CASENO ADDRESS1 ADDRESS4 POSTCODE FAMILYNAME FIRSTNAME DOBEST ACTIVITYDATE ECG CPOx INVVENTET INVVENTTT 0000000 Where Person1 live他們住在那裏PP1 2PP Person1 PersonF1 0 P333456 0000000 Where Person1 live他們住在那裏PP1 2PP – user1704350