存在するかどうかにかかわらず、4 つの質問を書き出したいと思います。しかし、私は問題を抱えています
「質問 1」 (文字列値)
NTE_3_Comment
を含む場所を選択する質問が存在しない場合、質問 4を書き出します。
の正しい番号も出力する必要があります
SETID
。
注: 質問には実際には番号が含まれていません。ID を使用して出力を並べ替えています。
入力 XML:
<NTE_NotesAndCommentsSegment_2>
<NTE_1_SetIdNotesAndComments>1</NTE_1_SetIdNotesAndComments>
<NTE_2_SourceOfComment></NTE_2_SourceOfComment>
<NTE_3_Comment>Question 1 ? Answer 1</NTE_3_Comment>
</NTE_NotesAndCommentsSegment_2>
<NTE_NotesAndCommentsSegment_2>
<NTE_1_SetIdNotesAndComments>1</NTE_1_SetIdNotesAndComments>
<NTE_2_SourceOfComment></NTE_2_SourceOfComment>
<NTE_3_Comment>Question 2 ? Answer 2</NTE_3_Comment>
</NTE_NotesAndCommentsSegment_2>
<NTE_NotesAndCommentsSegment_2>
<NTE_1_SetIdNotesAndComments>1</NTE_1_SetIdNotesAndComments>
<NTE_2_SourceOfComment></NTE_2_SourceOfComment>
<NTE_3_Comment>Question 3? Answer 3</NTE_3_Comment>
</NTE_NotesAndCommentsSegment_2>
予期される出力 XML:
<NTE_NotesAndCommentsSegment_2>
<NTE_1_SetIdNotesAndComments>1</NTE_1_SetIdNotesAndComments>
<NTE_2_SourceOfComment></NTE_2_SourceOfComment>
<NTE_3_Comment>Question 1 ? Answer 1</NTE_3_Comment>
</NTE_NotesAndCommentsSegment_2>
<NTE_NotesAndCommentsSegment_2>
<NTE_1_SetIdNotesAndComments>2</NTE_1_SetIdNotesAndComments>
<NTE_2_SourceOfComment></NTE_2_SourceOfComment>
<NTE_3_Comment>Question 2 ? Answer 2</NTE_3_Comment>
</NTE_NotesAndCommentsSegment_2>
<NTE_NotesAndCommentsSegment_2>
<NTE_1_SetIdNotesAndComments>3</NTE_1_SetIdNotesAndComments>
<NTE_2_SourceOfComment></NTE_2_SourceOfComment>
<NTE_3_Comment>Question 3 ? Answer 3</NTE_3_Comment>
</NTE_NotesAndCommentsSegment_2>
<NTE_NotesAndCommentsSegment_2>
<NTE_1_SetIdNotesAndComments>4</NTE_1_SetIdNotesAndComments>
<NTE_2_SourceOfComment></NTE_2_SourceOfComment>
<NTE_3_Comment>Question 4 ? *Blank* </NTE_3_Comment>
</NTE_NotesAndCommentsSegment_2>
このソリューションへのアプローチを変更するのに役立つ提案を探しています。前もって感謝します。
解決策: @ORMapper の提案に感謝します。質問が存在するかどうかにかかわらず、4 つの質問すべてが毎回書き出されます。質問がソースに存在しない場合、回答は空白で表示されます。
<NTE_NotesAndCommentsSegment_2>
<NTE_1_SetIdNotesAndComments>1</NTE_1_SetIdNotesAndComments>
<NTE_3_Comment>Question 1 ?<xsl:value-of select="substring-after(//NTE_NotesAndCommentsSegment_2/NTE_3_Comment[starts-with(text(),'Question 1')],'?')"/>
</NTE_3_Comment>
</NTE_NotesAndCommentsSegment_2>
<NTE_NotesAndCommentsSegment_2>
<NTE_1_SetIdNotesAndComments>2</NTE_1_SetIdNotesAndComments>
<NTE_3_Comment>Question 2 ?<xsl:value-of select="substring-after(//NTE_NotesAndCommentsSegment_2/NTE_3_Comment[starts-with(text(),'Question 2')],'?')"/>
</NTE_3_Comment>
</NTE_NotesAndCommentsSegment_2>
<NTE_NotesAndCommentsSegment_2>
<NTE_1_SetIdNotesAndComments>3</NTE_1_SetIdNotesAndComments>
<NTE_3_Comment>Question 3 ?<xsl:value-of select="substring-after(//NTE_NotesAndCommentsSegment_2/NTE_3_Comment[starts-with(text(),'Question 3')],'?')"/>
</NTE_3_Comment>
</NTE_NotesAndCommentsSegment_2>
<NTE_NotesAndCommentsSegment_2>
<NTE_1_SetIdNotesAndComments>4</NTE_1_SetIdNotesAndComments>
<NTE_3_Comment>Question 4 ? <xsl:value-of select="substring-after(//NTE_NotesAndCommentsSegment_2/NTE_3_Comment[starts-with(text(),'Question 4')],'?')"/>
</NTE_3_Comment>
</NTE_NotesAndCommentsSegment_2>