基本的に、これはシェイクスピア劇の抜粋から取った私のXMLです。
<PLAY>
<PERSONA>BENEDICK, a young lord of Padua.</PERSONA>
<PERSONA>LEONATO, governor of Messina.</PERSONA>
<PERSONA>ANTONIO, his brother.</PERSONA>
<PERSONA>BALTHASAR, attendant on Don Pedro.</PERSONA>
<PGROUP>
<PERSONA>CONRADE</PERSONA>
<PERSONA>BORACHIO</PERSONA>
<GRPDESCR>followers of Don John.</GRPDESCR>
</PGROUP>
<PERSONA>FRIAR FRANCIS</PERSONA>
</PLAY>
XSLは次のとおりです。
<xsl:template match="PLAY">
<html>
<body>
<xsl:for-each select="PERSONAE">
<xsl:apply-templates select="PERSONA" />
<xsl:apply-templates select="PGROUP/PERSONA" />
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template match="PERSONA">
<p><xsl:value-of select="." /></p>
</xsl:template>
<xsl:template match="PGROUP/PERSONA">
<xsl:for-each select=".">
<p><xsl:value-of select="." />, </p>
</xsl:for-each>
<xsl:for-each select="..">
<p><xsl:value-of select="GRPDESCR" /></p>
</xsl:for-each>
</xsl:template>
現在のHTML出力:
BENEDICK, a young lord of Padua.
LEONATO, governor of Messina.
ANTONIO, his brother.
BALTHASAR, attendant on Don Pedro.
FRIAR FRANCIS
CONRADE,
followers of Don John.
BORACHIO,
followers of Don John.
そして、これは私が私のHTML出力をどのように見せたいかです:
BENEDICK, a young lord of Padua.
LEONATO, governor of Messina.
ANTONIO, his brother.
BALTHASAR, attendant on Don Pedro.
FRIAR FRANCIS
CONRADE, BORACHIO, followers of Don John.
私はこれに何時間も費やしたので、どんな助けもとても素晴らしいでしょう!